documentation.d.ts 3.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. }
  1053. }
  1054. declare module BABYLON {
  1055. /**
  1056. * This represents the required contract to create a new type of texture loader.
  1057. */
  1058. export interface IInternalTextureLoader {
  1059. /**
  1060. * Defines wether the loader supports cascade loading the different faces.
  1061. */
  1062. supportCascades: boolean;
  1063. /**
  1064. * This returns if the loader support the current file information.
  1065. * @param extension defines the file extension of the file being loaded
  1066. * @returns true if the loader can load the specified file
  1067. */
  1068. canLoad(extension: string): boolean;
  1069. /**
  1070. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1071. * @param data contains the texture data
  1072. * @param texture defines the BabylonJS internal texture
  1073. * @param createPolynomials will be true if polynomials have been requested
  1074. * @param onLoad defines the callback to trigger once the texture is ready
  1075. * @param onError defines the callback to trigger in case of error
  1076. */
  1077. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1078. /**
  1079. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param callback defines the method to call once ready to upload
  1083. */
  1084. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1085. }
  1086. }
  1087. declare module BABYLON {
  1088. /**
  1089. * Class used to store and describe the pipeline context associated with an effect
  1090. */
  1091. export interface IPipelineContext {
  1092. /**
  1093. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1094. */
  1095. isAsync: boolean;
  1096. /**
  1097. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1098. */
  1099. isReady: boolean;
  1100. /** @hidden */
  1101. _getVertexShaderCode(): string | null;
  1102. /** @hidden */
  1103. _getFragmentShaderCode(): string | null;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module BABYLON {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module BABYLON {
  1143. /** @hidden */
  1144. export interface ProcessingOptions {
  1145. defines: string[];
  1146. indexParameters: any;
  1147. isFragment: boolean;
  1148. shouldUseHighPrecisionShader: boolean;
  1149. supportsUniformBuffers: boolean;
  1150. shadersRepository: string;
  1151. includesShadersStore: {
  1152. [key: string]: string;
  1153. };
  1154. processor?: IShaderProcessor;
  1155. version: string;
  1156. platformName: string;
  1157. lookForClosingBracketForUniformBuffer?: boolean;
  1158. }
  1159. }
  1160. declare module BABYLON {
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1188. process(preprocessors: {
  1189. [key: string]: string;
  1190. }, options: ProcessingOptions): string;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderDefineExpression {
  1196. isTrue(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. private static _OperatorPriority;
  1200. private static _Stack;
  1201. static postfixToInfix(postfix: string[]): string;
  1202. static infixToPostfix(infix: string): string[];
  1203. }
  1204. }
  1205. declare module BABYLON {
  1206. /** @hidden */
  1207. export class ShaderCodeTestNode extends ShaderCodeNode {
  1208. testExpression: ShaderDefineExpression;
  1209. isValid(preprocessors: {
  1210. [key: string]: string;
  1211. }): boolean;
  1212. }
  1213. }
  1214. declare module BABYLON {
  1215. /** @hidden */
  1216. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1217. define: string;
  1218. not: boolean;
  1219. constructor(define: string, not?: boolean);
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1238. leftOperand: ShaderDefineExpression;
  1239. rightOperand: ShaderDefineExpression;
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /** @hidden */
  1247. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1248. define: string;
  1249. operand: string;
  1250. testValue: string;
  1251. constructor(define: string, operand: string, testValue: string);
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. }
  1256. }
  1257. declare module BABYLON {
  1258. /**
  1259. * Class used to enable access to offline support
  1260. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1261. */
  1262. export interface IOfflineProvider {
  1263. /**
  1264. * Gets a boolean indicating if scene must be saved in the database
  1265. */
  1266. enableSceneOffline: boolean;
  1267. /**
  1268. * Gets a boolean indicating if textures must be saved in the database
  1269. */
  1270. enableTexturesOffline: boolean;
  1271. /**
  1272. * Open the offline support and make it available
  1273. * @param successCallback defines the callback to call on success
  1274. * @param errorCallback defines the callback to call on error
  1275. */
  1276. open(successCallback: () => void, errorCallback: () => void): void;
  1277. /**
  1278. * Loads an image from the offline support
  1279. * @param url defines the url to load from
  1280. * @param image defines the target DOM image
  1281. */
  1282. loadImage(url: string, image: HTMLImageElement): void;
  1283. /**
  1284. * Loads a file from offline support
  1285. * @param url defines the URL to load from
  1286. * @param sceneLoaded defines a callback to call on success
  1287. * @param progressCallBack defines a callback to call when progress changed
  1288. * @param errorCallback defines a callback to call on error
  1289. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1290. */
  1291. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class used to help managing file picking and drag'n'drop
  1297. * File Storage
  1298. */
  1299. export class FilesInputStore {
  1300. /**
  1301. * List of files ready to be loaded
  1302. */
  1303. static FilesToLoad: {
  1304. [key: string]: File;
  1305. };
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module BABYLON {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module BABYLON {
  1332. /** @ignore */
  1333. export class LoadFileError extends BaseError {
  1334. request?: WebRequest;
  1335. file?: File;
  1336. /**
  1337. * Creates a new LoadFileError
  1338. * @param message defines the message of the error
  1339. * @param request defines the optional web request
  1340. * @param file defines the optional file
  1341. */
  1342. constructor(message: string, object?: WebRequest | File);
  1343. }
  1344. /** @ignore */
  1345. export class RequestFileError extends BaseError {
  1346. request: WebRequest;
  1347. /**
  1348. * Creates a new LoadFileError
  1349. * @param message defines the message of the error
  1350. * @param request defines the optional web request
  1351. */
  1352. constructor(message: string, request: WebRequest);
  1353. }
  1354. /** @ignore */
  1355. export class ReadFileError extends BaseError {
  1356. file: File;
  1357. /**
  1358. * Creates a new ReadFileError
  1359. * @param message defines the message of the error
  1360. * @param file defines the optional file
  1361. */
  1362. constructor(message: string, file: File);
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export class FileTools {
  1368. /**
  1369. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1370. */
  1371. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1372. /**
  1373. * Gets or sets the base URL to use to load assets
  1374. */
  1375. static BaseUrl: string;
  1376. /**
  1377. * Default behaviour for cors in the application.
  1378. * It can be a string if the expected behavior is identical in the entire app.
  1379. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1380. */
  1381. static CorsBehavior: string | ((url: string | string[]) => string);
  1382. /**
  1383. * Gets or sets a function used to pre-process url before using them to load assets
  1384. */
  1385. static PreprocessUrl: (url: string) => string;
  1386. /**
  1387. * Removes unwanted characters from an url
  1388. * @param url defines the url to clean
  1389. * @returns the cleaned url
  1390. */
  1391. private static _CleanUrl;
  1392. /**
  1393. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1394. * @param url define the url we are trying
  1395. * @param element define the dom element where to configure the cors policy
  1396. */
  1397. static SetCorsBehavior(url: string | string[], element: {
  1398. crossOrigin: string | null;
  1399. }): void;
  1400. /**
  1401. * Loads an image as an HTMLImageElement.
  1402. * @param input url string, ArrayBuffer, or Blob to load
  1403. * @param onLoad callback called when the image successfully loads
  1404. * @param onError callback called when the image fails to load
  1405. * @param offlineProvider offline provider for caching
  1406. * @param mimeType optional mime type
  1407. * @returns the HTMLImageElement of the loaded image
  1408. */
  1409. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1410. /**
  1411. * Reads a file from a File object
  1412. * @param file defines the file to load
  1413. * @param onSuccess defines the callback to call when data is loaded
  1414. * @param onProgress defines the callback to call during loading process
  1415. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1416. * @param onError defines the callback to call when an error occurs
  1417. * @returns a file request object
  1418. */
  1419. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1420. /**
  1421. * Loads a file from a url
  1422. * @param url url to load
  1423. * @param onSuccess callback called when the file successfully loads
  1424. * @param onProgress callback called while file is loading (if the server supports this mode)
  1425. * @param offlineProvider defines the offline provider for caching
  1426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @returns a file request object
  1429. */
  1430. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1431. /**
  1432. * Loads a file
  1433. * @param url url to load
  1434. * @param onSuccess callback called when the file successfully loads
  1435. * @param onProgress callback called while file is loading (if the server supports this mode)
  1436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1437. * @param onError callback called when the file fails to load
  1438. * @param onOpened callback called when the web request is opened
  1439. * @returns a file request object
  1440. */
  1441. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1442. /**
  1443. * Checks if the loaded document was accessed via `file:`-Protocol.
  1444. * @returns boolean
  1445. */
  1446. static IsFileURL(): boolean;
  1447. }
  1448. }
  1449. declare module BABYLON {
  1450. /** @hidden */
  1451. export class ShaderProcessor {
  1452. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1453. private static _ProcessPrecision;
  1454. private static _ExtractOperation;
  1455. private static _BuildSubExpression;
  1456. private static _BuildExpression;
  1457. private static _MoveCursorWithinIf;
  1458. private static _MoveCursor;
  1459. private static _EvaluatePreProcessors;
  1460. private static _PreparePreProcessors;
  1461. private static _ProcessShaderConversion;
  1462. private static _ProcessIncludes;
  1463. /**
  1464. * Loads a file from a url
  1465. * @param url url to load
  1466. * @param onSuccess callback called when the file successfully loads
  1467. * @param onProgress callback called while file is loading (if the server supports this mode)
  1468. * @param offlineProvider defines the offline provider for caching
  1469. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1470. * @param onError callback called when the file fails to load
  1471. * @returns a file request object
  1472. * @hidden
  1473. */
  1474. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1475. }
  1476. }
  1477. declare module BABYLON {
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module BABYLON {
  1545. /**
  1546. * Interface used to define common properties for effect fallbacks
  1547. */
  1548. export interface IEffectFallbacks {
  1549. /**
  1550. * Removes the defines that should be removed when falling back.
  1551. * @param currentDefines defines the current define statements for the shader.
  1552. * @param effect defines the current effect we try to compile
  1553. * @returns The resulting defines with defines of the current rank removed.
  1554. */
  1555. reduce(currentDefines: string, effect: Effect): string;
  1556. /**
  1557. * Removes the fallback from the bound mesh.
  1558. */
  1559. unBindMesh(): void;
  1560. /**
  1561. * Checks to see if more fallbacks are still availible.
  1562. */
  1563. hasMoreFallbacks: boolean;
  1564. }
  1565. }
  1566. declare module BABYLON {
  1567. /**
  1568. * Class used to evalaute queries containing `and` and `or` operators
  1569. */
  1570. export class AndOrNotEvaluator {
  1571. /**
  1572. * Evaluate a query
  1573. * @param query defines the query to evaluate
  1574. * @param evaluateCallback defines the callback used to filter result
  1575. * @returns true if the query matches
  1576. */
  1577. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1578. private static _HandleParenthesisContent;
  1579. private static _SimplifyNegation;
  1580. }
  1581. }
  1582. declare module BABYLON {
  1583. /**
  1584. * Class used to store custom tags
  1585. */
  1586. export class Tags {
  1587. /**
  1588. * Adds support for tags on the given object
  1589. * @param obj defines the object to use
  1590. */
  1591. static EnableFor(obj: any): void;
  1592. /**
  1593. * Removes tags support
  1594. * @param obj defines the object to use
  1595. */
  1596. static DisableFor(obj: any): void;
  1597. /**
  1598. * Gets a boolean indicating if the given object has tags
  1599. * @param obj defines the object to use
  1600. * @returns a boolean
  1601. */
  1602. static HasTags(obj: any): boolean;
  1603. /**
  1604. * Gets the tags available on a given object
  1605. * @param obj defines the object to use
  1606. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1607. * @returns the tags
  1608. */
  1609. static GetTags(obj: any, asString?: boolean): any;
  1610. /**
  1611. * Adds tags to an object
  1612. * @param obj defines the object to use
  1613. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1614. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1615. */
  1616. static AddTagsTo(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _AddTagTo(obj: any, tag: string): void;
  1621. /**
  1622. * Removes specific tags from a specific object
  1623. * @param obj defines the object to use
  1624. * @param tagsString defines the tags to remove
  1625. */
  1626. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1627. /**
  1628. * @hidden
  1629. */
  1630. static _RemoveTagFrom(obj: any, tag: string): void;
  1631. /**
  1632. * Defines if tags hosted on an object match a given query
  1633. * @param obj defines the object to use
  1634. * @param tagsQuery defines the tag query
  1635. * @returns a boolean
  1636. */
  1637. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1638. }
  1639. }
  1640. declare module BABYLON {
  1641. /**
  1642. * Scalar computation library
  1643. */
  1644. export class Scalar {
  1645. /**
  1646. * Two pi constants convenient for computation.
  1647. */
  1648. static TwoPi: number;
  1649. /**
  1650. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1651. * @param a number
  1652. * @param b number
  1653. * @param epsilon (default = 1.401298E-45)
  1654. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1655. */
  1656. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1657. /**
  1658. * Returns a string : the upper case translation of the number i to hexadecimal.
  1659. * @param i number
  1660. * @returns the upper case translation of the number i to hexadecimal.
  1661. */
  1662. static ToHex(i: number): string;
  1663. /**
  1664. * Returns -1 if value is negative and +1 is value is positive.
  1665. * @param value the value
  1666. * @returns the value itself if it's equal to zero.
  1667. */
  1668. static Sign(value: number): number;
  1669. /**
  1670. * Returns the value itself if it's between min and max.
  1671. * Returns min if the value is lower than min.
  1672. * Returns max if the value is greater than max.
  1673. * @param value the value to clmap
  1674. * @param min the min value to clamp to (default: 0)
  1675. * @param max the max value to clamp to (default: 1)
  1676. * @returns the clamped value
  1677. */
  1678. static Clamp(value: number, min?: number, max?: number): number;
  1679. /**
  1680. * the log2 of value.
  1681. * @param value the value to compute log2 of
  1682. * @returns the log2 of value.
  1683. */
  1684. static Log2(value: number): number;
  1685. /**
  1686. * Loops the value, so that it is never larger than length and never smaller than 0.
  1687. *
  1688. * This is similar to the modulo operator but it works with floating point numbers.
  1689. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1690. * With t = 5 and length = 2.5, the result would be 0.0.
  1691. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1692. * @param value the value
  1693. * @param length the length
  1694. * @returns the looped value
  1695. */
  1696. static Repeat(value: number, length: number): number;
  1697. /**
  1698. * Normalize the value between 0.0 and 1.0 using min and max values
  1699. * @param value value to normalize
  1700. * @param min max to normalize between
  1701. * @param max min to normalize between
  1702. * @returns the normalized value
  1703. */
  1704. static Normalize(value: number, min: number, max: number): number;
  1705. /**
  1706. * Denormalize the value from 0.0 and 1.0 using min and max values
  1707. * @param normalized value to denormalize
  1708. * @param min max to denormalize between
  1709. * @param max min to denormalize between
  1710. * @returns the denormalized value
  1711. */
  1712. static Denormalize(normalized: number, min: number, max: number): number;
  1713. /**
  1714. * Calculates the shortest difference between two given angles given in degrees.
  1715. * @param current current angle in degrees
  1716. * @param target target angle in degrees
  1717. * @returns the delta
  1718. */
  1719. static DeltaAngle(current: number, target: number): number;
  1720. /**
  1721. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1722. * @param tx value
  1723. * @param length length
  1724. * @returns The returned value will move back and forth between 0 and length
  1725. */
  1726. static PingPong(tx: number, length: number): number;
  1727. /**
  1728. * Interpolates between min and max with smoothing at the limits.
  1729. *
  1730. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1731. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1732. * @param from from
  1733. * @param to to
  1734. * @param tx value
  1735. * @returns the smooth stepped value
  1736. */
  1737. static SmoothStep(from: number, to: number, tx: number): number;
  1738. /**
  1739. * Moves a value current towards target.
  1740. *
  1741. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1742. * Negative values of maxDelta pushes the value away from target.
  1743. * @param current current value
  1744. * @param target target value
  1745. * @param maxDelta max distance to move
  1746. * @returns resulting value
  1747. */
  1748. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1749. /**
  1750. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1751. *
  1752. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1753. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1754. * @param current current value
  1755. * @param target target value
  1756. * @param maxDelta max distance to move
  1757. * @returns resulting angle
  1758. */
  1759. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1760. /**
  1761. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1762. * @param start start value
  1763. * @param end target value
  1764. * @param amount amount to lerp between
  1765. * @returns the lerped value
  1766. */
  1767. static Lerp(start: number, end: number, amount: number): number;
  1768. /**
  1769. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1771. * @param start start value
  1772. * @param end target value
  1773. * @param amount amount to lerp between
  1774. * @returns the lerped value
  1775. */
  1776. static LerpAngle(start: number, end: number, amount: number): number;
  1777. /**
  1778. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1779. * @param a start value
  1780. * @param b target value
  1781. * @param value value between a and b
  1782. * @returns the inverseLerp value
  1783. */
  1784. static InverseLerp(a: number, b: number, value: number): number;
  1785. /**
  1786. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1787. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1788. * @param value1 spline value
  1789. * @param tangent1 spline value
  1790. * @param value2 spline value
  1791. * @param tangent2 spline value
  1792. * @param amount input value
  1793. * @returns hermite result
  1794. */
  1795. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1796. /**
  1797. * Returns a random float number between and min and max values
  1798. * @param min min value of random
  1799. * @param max max value of random
  1800. * @returns random value
  1801. */
  1802. static RandomRange(min: number, max: number): number;
  1803. /**
  1804. * This function returns percentage of a number in a given range.
  1805. *
  1806. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1807. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1808. * @param number to convert to percentage
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the percentage
  1812. */
  1813. static RangeToPercent(number: number, min: number, max: number): number;
  1814. /**
  1815. * This function returns number that corresponds to the percentage in a given range.
  1816. *
  1817. * PercentToRange(0.34,0,100) will return 34.
  1818. * @param percent to convert to number
  1819. * @param min min range
  1820. * @param max max range
  1821. * @returns the number
  1822. */
  1823. static PercentToRange(percent: number, min: number, max: number): number;
  1824. /**
  1825. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1826. * @param angle The angle to normalize in radian.
  1827. * @return The converted angle.
  1828. */
  1829. static NormalizeRadians(angle: number): number;
  1830. }
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Constant used to convert a value to gamma space
  1835. * @ignorenaming
  1836. */
  1837. export const ToGammaSpace: number;
  1838. /**
  1839. * Constant used to convert a value to linear space
  1840. * @ignorenaming
  1841. */
  1842. export const ToLinearSpace = 2.2;
  1843. /**
  1844. * Constant used to define the minimal number value in Babylon.js
  1845. * @ignorenaming
  1846. */
  1847. let Epsilon: number;
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Class used to represent a viewport on screen
  1852. */
  1853. export class Viewport {
  1854. /** viewport left coordinate */
  1855. x: number;
  1856. /** viewport top coordinate */
  1857. y: number;
  1858. /**viewport width */
  1859. width: number;
  1860. /** viewport height */
  1861. height: number;
  1862. /**
  1863. * Creates a Viewport object located at (x, y) and sized (width, height)
  1864. * @param x defines viewport left coordinate
  1865. * @param y defines viewport top coordinate
  1866. * @param width defines the viewport width
  1867. * @param height defines the viewport height
  1868. */
  1869. constructor(
  1870. /** viewport left coordinate */
  1871. x: number,
  1872. /** viewport top coordinate */
  1873. y: number,
  1874. /**viewport width */
  1875. width: number,
  1876. /** viewport height */
  1877. height: number);
  1878. /**
  1879. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1880. * @param renderWidth defines the rendering width
  1881. * @param renderHeight defines the rendering height
  1882. * @returns a new Viewport
  1883. */
  1884. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1885. /**
  1886. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1887. * @param renderWidth defines the rendering width
  1888. * @param renderHeight defines the rendering height
  1889. * @param ref defines the target viewport
  1890. * @returns the current viewport
  1891. */
  1892. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1893. /**
  1894. * Returns a new Viewport copied from the current one
  1895. * @returns a new Viewport
  1896. */
  1897. clone(): Viewport;
  1898. }
  1899. }
  1900. declare module BABYLON {
  1901. /**
  1902. * Class containing a set of static utilities functions for arrays.
  1903. */
  1904. export class ArrayTools {
  1905. /**
  1906. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1907. * @param size the number of element to construct and put in the array
  1908. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1909. * @returns a new array filled with new objects
  1910. */
  1911. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1912. }
  1913. }
  1914. declare module BABYLON {
  1915. /**
  1916. * Represents a plane by the equation ax + by + cz + d = 0
  1917. */
  1918. export class Plane {
  1919. private static _TmpMatrix;
  1920. /**
  1921. * Normal of the plane (a,b,c)
  1922. */
  1923. normal: Vector3;
  1924. /**
  1925. * d component of the plane
  1926. */
  1927. d: number;
  1928. /**
  1929. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1930. * @param a a component of the plane
  1931. * @param b b component of the plane
  1932. * @param c c component of the plane
  1933. * @param d d component of the plane
  1934. */
  1935. constructor(a: number, b: number, c: number, d: number);
  1936. /**
  1937. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1938. */
  1939. asArray(): number[];
  1940. /**
  1941. * @returns a new plane copied from the current Plane.
  1942. */
  1943. clone(): Plane;
  1944. /**
  1945. * @returns the string "Plane".
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * @returns the Plane hash code.
  1950. */
  1951. getHashCode(): number;
  1952. /**
  1953. * Normalize the current Plane in place.
  1954. * @returns the updated Plane.
  1955. */
  1956. normalize(): Plane;
  1957. /**
  1958. * Applies a transformation the plane and returns the result
  1959. * @param transformation the transformation matrix to be applied to the plane
  1960. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1961. */
  1962. transform(transformation: DeepImmutable<Matrix>): Plane;
  1963. /**
  1964. * Compute the dot product between the point and the plane normal
  1965. * @param point point to calculate the dot product with
  1966. * @returns the dot product (float) of the point coordinates and the plane normal.
  1967. */
  1968. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1969. /**
  1970. * Updates the current Plane from the plane defined by the three given points.
  1971. * @param point1 one of the points used to contruct the plane
  1972. * @param point2 one of the points used to contruct the plane
  1973. * @param point3 one of the points used to contruct the plane
  1974. * @returns the updated Plane.
  1975. */
  1976. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1977. /**
  1978. * Checks if the plane is facing a given direction
  1979. * @param direction the direction to check if the plane is facing
  1980. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1981. * @returns True is the vector "direction" is the same side than the plane normal.
  1982. */
  1983. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1984. /**
  1985. * Calculates the distance to a point
  1986. * @param point point to calculate distance to
  1987. * @returns the signed distance (float) from the given point to the Plane.
  1988. */
  1989. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1990. /**
  1991. * Creates a plane from an array
  1992. * @param array the array to create a plane from
  1993. * @returns a new Plane from the given array.
  1994. */
  1995. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1996. /**
  1997. * Creates a plane from three points
  1998. * @param point1 point used to create the plane
  1999. * @param point2 point used to create the plane
  2000. * @param point3 point used to create the plane
  2001. * @returns a new Plane defined by the three given points.
  2002. */
  2003. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Creates a plane from an origin point and a normal
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @returns a new Plane the normal vector to this plane at the given origin point.
  2009. * Note : the vector "normal" is updated because normalized.
  2010. */
  2011. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2012. /**
  2013. * Calculates the distance from a plane and a point
  2014. * @param origin origin of the plane to be constructed
  2015. * @param normal normal of the plane to be constructed
  2016. * @param point point to calculate distance to
  2017. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2018. */
  2019. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2020. }
  2021. }
  2022. declare module BABYLON {
  2023. /**
  2024. * Class representing a vector containing 2 coordinates
  2025. */
  2026. export class Vector2 {
  2027. /** defines the first coordinate */
  2028. x: number;
  2029. /** defines the second coordinate */
  2030. y: number;
  2031. /**
  2032. * Creates a new Vector2 from the given x and y coordinates
  2033. * @param x defines the first coordinate
  2034. * @param y defines the second coordinate
  2035. */
  2036. constructor(
  2037. /** defines the first coordinate */
  2038. x?: number,
  2039. /** defines the second coordinate */
  2040. y?: number);
  2041. /**
  2042. * Gets a string with the Vector2 coordinates
  2043. * @returns a string with the Vector2 coordinates
  2044. */
  2045. toString(): string;
  2046. /**
  2047. * Gets class name
  2048. * @returns the string "Vector2"
  2049. */
  2050. getClassName(): string;
  2051. /**
  2052. * Gets current vector hash code
  2053. * @returns the Vector2 hash code as a number
  2054. */
  2055. getHashCode(): number;
  2056. /**
  2057. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2058. * @param array defines the source array
  2059. * @param index defines the offset in source array
  2060. * @returns the current Vector2
  2061. */
  2062. toArray(array: FloatArray, index?: number): Vector2;
  2063. /**
  2064. * Copy the current vector to an array
  2065. * @returns a new array with 2 elements: the Vector2 coordinates.
  2066. */
  2067. asArray(): number[];
  2068. /**
  2069. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2070. * @param source defines the source Vector2
  2071. * @returns the current updated Vector2
  2072. */
  2073. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Sets the Vector2 coordinates with the given floats
  2076. * @param x defines the first coordinate
  2077. * @param y defines the second coordinate
  2078. * @returns the current updated Vector2
  2079. */
  2080. copyFromFloats(x: number, y: number): Vector2;
  2081. /**
  2082. * Sets the Vector2 coordinates with the given floats
  2083. * @param x defines the first coordinate
  2084. * @param y defines the second coordinate
  2085. * @returns the current updated Vector2
  2086. */
  2087. set(x: number, y: number): Vector2;
  2088. /**
  2089. * Add another vector with the current one
  2090. * @param otherVector defines the other vector
  2091. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2092. */
  2093. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2096. * @param otherVector defines the other vector
  2097. * @param result defines the target vector
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2101. /**
  2102. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2103. * @param otherVector defines the other vector
  2104. * @returns the current updated Vector2
  2105. */
  2106. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2107. /**
  2108. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2109. * @param otherVector defines the other vector
  2110. * @returns a new Vector2
  2111. */
  2112. addVector3(otherVector: Vector3): Vector2;
  2113. /**
  2114. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2115. * @param otherVector defines the other vector
  2116. * @returns a new Vector2
  2117. */
  2118. subtract(otherVector: Vector2): Vector2;
  2119. /**
  2120. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2121. * @param otherVector defines the other vector
  2122. * @param result defines the target vector
  2123. * @returns the unmodified current Vector2
  2124. */
  2125. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2126. /**
  2127. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2128. * @param otherVector defines the other vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2132. /**
  2133. * Multiplies in place the current Vector2 coordinates by the given ones
  2134. * @param otherVector defines the other vector
  2135. * @returns the current updated Vector2
  2136. */
  2137. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2138. /**
  2139. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns a new Vector2
  2142. */
  2143. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2146. * @param otherVector defines the other vector
  2147. * @param result defines the target vector
  2148. * @returns the unmodified current Vector2
  2149. */
  2150. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns a new Vector2
  2156. */
  2157. multiplyByFloats(x: number, y: number): Vector2;
  2158. /**
  2159. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2
  2162. */
  2163. divide(otherVector: Vector2): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Divides the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 with current Vector2 negated coordinates
  2179. * @returns a new Vector2
  2180. */
  2181. negate(): Vector2;
  2182. /**
  2183. * Negate this vector in place
  2184. * @returns this
  2185. */
  2186. negateInPlace(): Vector2;
  2187. /**
  2188. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2189. * @param result defines the Vector3 object where to store the result
  2190. * @returns the current Vector2
  2191. */
  2192. negateToRef(result: Vector2): Vector2;
  2193. /**
  2194. * Multiply the Vector2 coordinates by scale
  2195. * @param scale defines the scaling factor
  2196. * @returns the current updated Vector2
  2197. */
  2198. scaleInPlace(scale: number): Vector2;
  2199. /**
  2200. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2201. * @param scale defines the scaling factor
  2202. * @returns a new Vector2
  2203. */
  2204. scale(scale: number): Vector2;
  2205. /**
  2206. * Scale the current Vector2 values by a factor to a given Vector2
  2207. * @param scale defines the scale factor
  2208. * @param result defines the Vector2 object where to store the result
  2209. * @returns the unmodified current Vector2
  2210. */
  2211. scaleToRef(scale: number, result: Vector2): Vector2;
  2212. /**
  2213. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2214. * @param scale defines the scale factor
  2215. * @param result defines the Vector2 object where to store the result
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a boolean if two vectors are equals
  2221. * @param otherVector defines the other vector
  2222. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2223. */
  2224. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2225. /**
  2226. * Gets a boolean if two vectors are equals (using an epsilon value)
  2227. * @param otherVector defines the other vector
  2228. * @param epsilon defines the minimal distance to consider equality
  2229. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2230. */
  2231. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2232. /**
  2233. * Gets a new Vector2 from current Vector2 floored values
  2234. * @returns a new Vector2
  2235. */
  2236. floor(): Vector2;
  2237. /**
  2238. * Gets a new Vector2 from current Vector2 floored values
  2239. * @returns a new Vector2
  2240. */
  2241. fract(): Vector2;
  2242. /**
  2243. * Gets the length of the vector
  2244. * @returns the vector length (float)
  2245. */
  2246. length(): number;
  2247. /**
  2248. * Gets the vector squared length
  2249. * @returns the vector squared length (float)
  2250. */
  2251. lengthSquared(): number;
  2252. /**
  2253. * Normalize the vector
  2254. * @returns the current updated Vector2
  2255. */
  2256. normalize(): Vector2;
  2257. /**
  2258. * Gets a new Vector2 copied from the Vector2
  2259. * @returns a new Vector2
  2260. */
  2261. clone(): Vector2;
  2262. /**
  2263. * Gets a new Vector2(0, 0)
  2264. * @returns a new Vector2
  2265. */
  2266. static Zero(): Vector2;
  2267. /**
  2268. * Gets a new Vector2(1, 1)
  2269. * @returns a new Vector2
  2270. */
  2271. static One(): Vector2;
  2272. /**
  2273. * Gets a new Vector2 set from the given index element of the given array
  2274. * @param array defines the data source
  2275. * @param offset defines the offset in the data source
  2276. * @returns a new Vector2
  2277. */
  2278. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2279. /**
  2280. * Sets "result" from the given index element of the given array
  2281. * @param array defines the data source
  2282. * @param offset defines the offset in the data source
  2283. * @param result defines the target vector
  2284. */
  2285. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2286. /**
  2287. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2288. * @param value1 defines 1st point of control
  2289. * @param value2 defines 2nd point of control
  2290. * @param value3 defines 3rd point of control
  2291. * @param value4 defines 4th point of control
  2292. * @param amount defines the interpolation factor
  2293. * @returns a new Vector2
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2296. /**
  2297. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2298. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2299. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2300. * @param value defines the value to clamp
  2301. * @param min defines the lower limit
  2302. * @param max defines the upper limit
  2303. * @returns a new Vector2
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2306. /**
  2307. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2308. * @param value1 defines the 1st control point
  2309. * @param tangent1 defines the outgoing tangent
  2310. * @param value2 defines the 2nd control point
  2311. * @param tangent2 defines the incoming tangent
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2318. * @param start defines the start vector
  2319. * @param end defines the end vector
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * Gets the dot product of the vector "left" and the vector "right"
  2326. * @param left defines first vector
  2327. * @param right defines second vector
  2328. * @returns the dot product (float)
  2329. */
  2330. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2331. /**
  2332. * Returns a new Vector2 equal to the normalized given vector
  2333. * @param vector defines the vector to normalize
  2334. * @returns a new Vector2
  2335. */
  2336. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2337. /**
  2338. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2339. * @param left defines 1st vector
  2340. * @param right defines 2nd vector
  2341. * @returns a new Vector2
  2342. */
  2343. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2344. /**
  2345. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2346. * @param left defines 1st vector
  2347. * @param right defines 2nd vector
  2348. * @returns a new Vector2
  2349. */
  2350. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2351. /**
  2352. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2353. * @param vector defines the vector to transform
  2354. * @param transformation defines the matrix to apply
  2355. * @returns a new Vector2
  2356. */
  2357. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2358. /**
  2359. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2360. * @param vector defines the vector to transform
  2361. * @param transformation defines the matrix to apply
  2362. * @param result defines the target vector
  2363. */
  2364. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2365. /**
  2366. * Determines if a given vector is included in a triangle
  2367. * @param p defines the vector to test
  2368. * @param p0 defines 1st triangle point
  2369. * @param p1 defines 2nd triangle point
  2370. * @param p2 defines 3rd triangle point
  2371. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2372. */
  2373. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2374. /**
  2375. * Gets the distance between the vectors "value1" and "value2"
  2376. * @param value1 defines first vector
  2377. * @param value2 defines second vector
  2378. * @returns the distance between vectors
  2379. */
  2380. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2381. /**
  2382. * Returns the squared distance between the vectors "value1" and "value2"
  2383. * @param value1 defines first vector
  2384. * @param value2 defines second vector
  2385. * @returns the squared distance between vectors
  2386. */
  2387. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2388. /**
  2389. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2390. * @param value1 defines first vector
  2391. * @param value2 defines second vector
  2392. * @returns a new Vector2
  2393. */
  2394. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2395. /**
  2396. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2397. * @param p defines the middle point
  2398. * @param segA defines one point of the segment
  2399. * @param segB defines the other point of the segment
  2400. * @returns the shortest distance
  2401. */
  2402. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2403. }
  2404. /**
  2405. * Class used to store (x,y,z) vector representation
  2406. * A Vector3 is the main object used in 3D geometry
  2407. * It can represent etiher the coordinates of a point the space, either a direction
  2408. * Reminder: js uses a left handed forward facing system
  2409. */
  2410. export class Vector3 {
  2411. private static _UpReadOnly;
  2412. private static _ZeroReadOnly;
  2413. /** @hidden */
  2414. _x: number;
  2415. /** @hidden */
  2416. _y: number;
  2417. /** @hidden */
  2418. _z: number;
  2419. /** @hidden */
  2420. _isDirty: boolean;
  2421. /** Gets or sets the x coordinate */
  2422. get x(): number;
  2423. set x(value: number);
  2424. /** Gets or sets the y coordinate */
  2425. get y(): number;
  2426. set y(value: number);
  2427. /** Gets or sets the z coordinate */
  2428. get z(): number;
  2429. set z(value: number);
  2430. /**
  2431. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2432. * @param x defines the first coordinates (on X axis)
  2433. * @param y defines the second coordinates (on Y axis)
  2434. * @param z defines the third coordinates (on Z axis)
  2435. */
  2436. constructor(x?: number, y?: number, z?: number);
  2437. /**
  2438. * Creates a string representation of the Vector3
  2439. * @returns a string with the Vector3 coordinates.
  2440. */
  2441. toString(): string;
  2442. /**
  2443. * Gets the class name
  2444. * @returns the string "Vector3"
  2445. */
  2446. getClassName(): string;
  2447. /**
  2448. * Creates the Vector3 hash code
  2449. * @returns a number which tends to be unique between Vector3 instances
  2450. */
  2451. getHashCode(): number;
  2452. /**
  2453. * Creates an array containing three elements : the coordinates of the Vector3
  2454. * @returns a new array of numbers
  2455. */
  2456. asArray(): number[];
  2457. /**
  2458. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2459. * @param array defines the destination array
  2460. * @param index defines the offset in the destination array
  2461. * @returns the current Vector3
  2462. */
  2463. toArray(array: FloatArray, index?: number): Vector3;
  2464. /**
  2465. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2466. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2467. */
  2468. toQuaternion(): Quaternion;
  2469. /**
  2470. * Adds the given vector to the current Vector3
  2471. * @param otherVector defines the second operand
  2472. * @returns the current updated Vector3
  2473. */
  2474. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2475. /**
  2476. * Adds the given coordinates to the current Vector3
  2477. * @param x defines the x coordinate of the operand
  2478. * @param y defines the y coordinate of the operand
  2479. * @param z defines the z coordinate of the operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2483. /**
  2484. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the resulting Vector3
  2487. */
  2488. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2491. * @param otherVector defines the second operand
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the current Vector3
  2494. */
  2495. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Subtract the given vector from the current Vector3
  2498. * @param otherVector defines the second operand
  2499. * @returns the current updated Vector3
  2500. */
  2501. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2502. /**
  2503. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2504. * @param otherVector defines the second operand
  2505. * @returns the resulting Vector3
  2506. */
  2507. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2508. /**
  2509. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2510. * @param otherVector defines the second operand
  2511. * @param result defines the Vector3 object where to store the result
  2512. * @returns the current Vector3
  2513. */
  2514. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2515. /**
  2516. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2517. * @param x defines the x coordinate of the operand
  2518. * @param y defines the y coordinate of the operand
  2519. * @param z defines the z coordinate of the operand
  2520. * @returns the resulting Vector3
  2521. */
  2522. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2523. /**
  2524. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2525. * @param x defines the x coordinate of the operand
  2526. * @param y defines the y coordinate of the operand
  2527. * @param z defines the z coordinate of the operand
  2528. * @param result defines the Vector3 object where to store the result
  2529. * @returns the current Vector3
  2530. */
  2531. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2532. /**
  2533. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2534. * @returns a new Vector3
  2535. */
  2536. negate(): Vector3;
  2537. /**
  2538. * Negate this vector in place
  2539. * @returns this
  2540. */
  2541. negateInPlace(): Vector3;
  2542. /**
  2543. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2544. * @param result defines the Vector3 object where to store the result
  2545. * @returns the current Vector3
  2546. */
  2547. negateToRef(result: Vector3): Vector3;
  2548. /**
  2549. * Multiplies the Vector3 coordinates by the float "scale"
  2550. * @param scale defines the multiplier factor
  2551. * @returns the current updated Vector3
  2552. */
  2553. scaleInPlace(scale: number): Vector3;
  2554. /**
  2555. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2556. * @param scale defines the multiplier factor
  2557. * @returns a new Vector3
  2558. */
  2559. scale(scale: number): Vector3;
  2560. /**
  2561. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2562. * @param scale defines the multiplier factor
  2563. * @param result defines the Vector3 object where to store the result
  2564. * @returns the current Vector3
  2565. */
  2566. scaleToRef(scale: number, result: Vector3): Vector3;
  2567. /**
  2568. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2569. * @param scale defines the scale factor
  2570. * @param result defines the Vector3 object where to store the result
  2571. * @returns the unmodified current Vector3
  2572. */
  2573. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2574. /**
  2575. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2576. * @param origin defines the origin of the projection ray
  2577. * @param plane defines the plane to project to
  2578. * @returns the projected vector3
  2579. */
  2580. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2581. /**
  2582. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2583. * @param origin defines the origin of the projection ray
  2584. * @param plane defines the plane to project to
  2585. * @param result defines the Vector3 where to store the result
  2586. */
  2587. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2588. /**
  2589. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2590. * @param otherVector defines the second operand
  2591. * @returns true if both vectors are equals
  2592. */
  2593. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2594. /**
  2595. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2596. * @param otherVector defines the second operand
  2597. * @param epsilon defines the minimal distance to define values as equals
  2598. * @returns true if both vectors are distant less than epsilon
  2599. */
  2600. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2601. /**
  2602. * Returns true if the current Vector3 coordinates equals the given floats
  2603. * @param x defines the x coordinate of the operand
  2604. * @param y defines the y coordinate of the operand
  2605. * @param z defines the z coordinate of the operand
  2606. * @returns true if both vectors are equals
  2607. */
  2608. equalsToFloats(x: number, y: number, z: number): boolean;
  2609. /**
  2610. * Multiplies the current Vector3 coordinates by the given ones
  2611. * @param otherVector defines the second operand
  2612. * @returns the current updated Vector3
  2613. */
  2614. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2615. /**
  2616. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2617. * @param otherVector defines the second operand
  2618. * @returns the new Vector3
  2619. */
  2620. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2621. /**
  2622. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2623. * @param otherVector defines the second operand
  2624. * @param result defines the Vector3 object where to store the result
  2625. * @returns the current Vector3
  2626. */
  2627. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2628. /**
  2629. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2630. * @param x defines the x coordinate of the operand
  2631. * @param y defines the y coordinate of the operand
  2632. * @param z defines the z coordinate of the operand
  2633. * @returns the new Vector3
  2634. */
  2635. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2638. * @param otherVector defines the second operand
  2639. * @returns the new Vector3
  2640. */
  2641. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2642. /**
  2643. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2644. * @param otherVector defines the second operand
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2649. /**
  2650. * Divides the current Vector3 coordinates by the given ones.
  2651. * @param otherVector defines the second operand
  2652. * @returns the current updated Vector3
  2653. */
  2654. divideInPlace(otherVector: Vector3): Vector3;
  2655. /**
  2656. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2657. * @param other defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2663. * @param other defines the second operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2677. * @param x defines the x coordinate of the operand
  2678. * @param y defines the y coordinate of the operand
  2679. * @param z defines the z coordinate of the operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2683. /**
  2684. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2685. * Check if is non uniform within a certain amount of decimal places to account for this
  2686. * @param epsilon the amount the values can differ
  2687. * @returns if the the vector is non uniform to a certain number of decimal places
  2688. */
  2689. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2690. /**
  2691. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2692. */
  2693. get isNonUniform(): boolean;
  2694. /**
  2695. * Gets a new Vector3 from current Vector3 floored values
  2696. * @returns a new Vector3
  2697. */
  2698. floor(): Vector3;
  2699. /**
  2700. * Gets a new Vector3 from current Vector3 floored values
  2701. * @returns a new Vector3
  2702. */
  2703. fract(): Vector3;
  2704. /**
  2705. * Gets the length of the Vector3
  2706. * @returns the length of the Vector3
  2707. */
  2708. length(): number;
  2709. /**
  2710. * Gets the squared length of the Vector3
  2711. * @returns squared length of the Vector3
  2712. */
  2713. lengthSquared(): number;
  2714. /**
  2715. * Normalize the current Vector3.
  2716. * Please note that this is an in place operation.
  2717. * @returns the current updated Vector3
  2718. */
  2719. normalize(): Vector3;
  2720. /**
  2721. * Reorders the x y z properties of the vector in place
  2722. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2723. * @returns the current updated vector
  2724. */
  2725. reorderInPlace(order: string): this;
  2726. /**
  2727. * Rotates the vector around 0,0,0 by a quaternion
  2728. * @param quaternion the rotation quaternion
  2729. * @param result vector to store the result
  2730. * @returns the resulting vector
  2731. */
  2732. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2733. /**
  2734. * Rotates a vector around a given point
  2735. * @param quaternion the rotation quaternion
  2736. * @param point the point to rotate around
  2737. * @param result vector to store the result
  2738. * @returns the resulting vector
  2739. */
  2740. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2741. /**
  2742. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2743. * The cross product is then orthogonal to both current and "other"
  2744. * @param other defines the right operand
  2745. * @returns the cross product
  2746. */
  2747. cross(other: Vector3): Vector3;
  2748. /**
  2749. * Normalize the current Vector3 with the given input length.
  2750. * Please note that this is an in place operation.
  2751. * @param len the length of the vector
  2752. * @returns the current updated Vector3
  2753. */
  2754. normalizeFromLength(len: number): Vector3;
  2755. /**
  2756. * Normalize the current Vector3 to a new vector
  2757. * @returns the new Vector3
  2758. */
  2759. normalizeToNew(): Vector3;
  2760. /**
  2761. * Normalize the current Vector3 to the reference
  2762. * @param reference define the Vector3 to update
  2763. * @returns the updated Vector3
  2764. */
  2765. normalizeToRef(reference: Vector3): Vector3;
  2766. /**
  2767. * Creates a new Vector3 copied from the current Vector3
  2768. * @returns the new Vector3
  2769. */
  2770. clone(): Vector3;
  2771. /**
  2772. * Copies the given vector coordinates to the current Vector3 ones
  2773. * @param source defines the source Vector3
  2774. * @returns the current updated Vector3
  2775. */
  2776. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2777. /**
  2778. * Copies the given floats to the current Vector3 coordinates
  2779. * @param x defines the x coordinate of the operand
  2780. * @param y defines the y coordinate of the operand
  2781. * @param z defines the z coordinate of the operand
  2782. * @returns the current updated Vector3
  2783. */
  2784. copyFromFloats(x: number, y: number, z: number): Vector3;
  2785. /**
  2786. * Copies the given floats to the current Vector3 coordinates
  2787. * @param x defines the x coordinate of the operand
  2788. * @param y defines the y coordinate of the operand
  2789. * @param z defines the z coordinate of the operand
  2790. * @returns the current updated Vector3
  2791. */
  2792. set(x: number, y: number, z: number): Vector3;
  2793. /**
  2794. * Copies the given float to the current Vector3 coordinates
  2795. * @param v defines the x, y and z coordinates of the operand
  2796. * @returns the current updated Vector3
  2797. */
  2798. setAll(v: number): Vector3;
  2799. /**
  2800. * Get the clip factor between two vectors
  2801. * @param vector0 defines the first operand
  2802. * @param vector1 defines the second operand
  2803. * @param axis defines the axis to use
  2804. * @param size defines the size along the axis
  2805. * @returns the clip factor
  2806. */
  2807. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2808. /**
  2809. * Get angle between two vectors
  2810. * @param vector0 angle between vector0 and vector1
  2811. * @param vector1 angle between vector0 and vector1
  2812. * @param normal direction of the normal
  2813. * @return the angle between vector0 and vector1
  2814. */
  2815. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2816. /**
  2817. * Returns a new Vector3 set from the index "offset" of the given array
  2818. * @param array defines the source array
  2819. * @param offset defines the offset in the source array
  2820. * @returns the new Vector3
  2821. */
  2822. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2823. /**
  2824. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2825. * @param array defines the source array
  2826. * @param offset defines the offset in the source array
  2827. * @returns the new Vector3
  2828. * @deprecated Please use FromArray instead.
  2829. */
  2830. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2831. /**
  2832. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2833. * @param array defines the source array
  2834. * @param offset defines the offset in the source array
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2838. /**
  2839. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2840. * @param array defines the source array
  2841. * @param offset defines the offset in the source array
  2842. * @param result defines the Vector3 where to store the result
  2843. * @deprecated Please use FromArrayToRef instead.
  2844. */
  2845. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2846. /**
  2847. * Sets the given vector "result" with the given floats.
  2848. * @param x defines the x coordinate of the source
  2849. * @param y defines the y coordinate of the source
  2850. * @param z defines the z coordinate of the source
  2851. * @param result defines the Vector3 where to store the result
  2852. */
  2853. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2854. /**
  2855. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2856. * @returns a new empty Vector3
  2857. */
  2858. static Zero(): Vector3;
  2859. /**
  2860. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2861. * @returns a new unit Vector3
  2862. */
  2863. static One(): Vector3;
  2864. /**
  2865. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2866. * @returns a new up Vector3
  2867. */
  2868. static Up(): Vector3;
  2869. /**
  2870. * Gets a up Vector3 that must not be updated
  2871. */
  2872. static get UpReadOnly(): DeepImmutable<Vector3>;
  2873. /**
  2874. * Gets a zero Vector3 that must not be updated
  2875. */
  2876. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2877. /**
  2878. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2879. * @returns a new down Vector3
  2880. */
  2881. static Down(): Vector3;
  2882. /**
  2883. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2884. * @param rightHandedSystem is the scene right-handed (negative z)
  2885. * @returns a new forward Vector3
  2886. */
  2887. static Forward(rightHandedSystem?: boolean): Vector3;
  2888. /**
  2889. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2890. * @param rightHandedSystem is the scene right-handed (negative-z)
  2891. * @returns a new forward Vector3
  2892. */
  2893. static Backward(rightHandedSystem?: boolean): Vector3;
  2894. /**
  2895. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2896. * @returns a new right Vector3
  2897. */
  2898. static Right(): Vector3;
  2899. /**
  2900. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2901. * @returns a new left Vector3
  2902. */
  2903. static Left(): Vector3;
  2904. /**
  2905. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2906. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2907. * @param vector defines the Vector3 to transform
  2908. * @param transformation defines the transformation matrix
  2909. * @returns the transformed Vector3
  2910. */
  2911. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2912. /**
  2913. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2914. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2915. * @param vector defines the Vector3 to transform
  2916. * @param transformation defines the transformation matrix
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2922. * This method computes tranformed coordinates only, not transformed direction vectors
  2923. * @param x define the x coordinate of the source vector
  2924. * @param y define the y coordinate of the source vector
  2925. * @param z define the z coordinate of the source vector
  2926. * @param transformation defines the transformation matrix
  2927. * @param result defines the Vector3 where to store the result
  2928. */
  2929. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2930. /**
  2931. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2932. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2933. * @param vector defines the Vector3 to transform
  2934. * @param transformation defines the transformation matrix
  2935. * @returns the new Vector3
  2936. */
  2937. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2938. /**
  2939. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2940. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2941. * @param vector defines the Vector3 to transform
  2942. * @param transformation defines the transformation matrix
  2943. * @param result defines the Vector3 where to store the result
  2944. */
  2945. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2946. /**
  2947. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2948. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2949. * @param x define the x coordinate of the source vector
  2950. * @param y define the y coordinate of the source vector
  2951. * @param z define the z coordinate of the source vector
  2952. * @param transformation defines the transformation matrix
  2953. * @param result defines the Vector3 where to store the result
  2954. */
  2955. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2956. /**
  2957. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2958. * @param value1 defines the first control point
  2959. * @param value2 defines the second control point
  2960. * @param value3 defines the third control point
  2961. * @param value4 defines the fourth control point
  2962. * @param amount defines the amount on the spline to use
  2963. * @returns the new Vector3
  2964. */
  2965. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2966. /**
  2967. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2968. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2969. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2970. * @param value defines the current value
  2971. * @param min defines the lower range value
  2972. * @param max defines the upper range value
  2973. * @returns the new Vector3
  2974. */
  2975. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2976. /**
  2977. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2978. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2979. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2980. * @param value defines the current value
  2981. * @param min defines the lower range value
  2982. * @param max defines the upper range value
  2983. * @param result defines the Vector3 where to store the result
  2984. */
  2985. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2986. /**
  2987. * Checks if a given vector is inside a specific range
  2988. * @param v defines the vector to test
  2989. * @param min defines the minimum range
  2990. * @param max defines the maximum range
  2991. */
  2992. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2993. /**
  2994. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2995. * @param value1 defines the first control point
  2996. * @param tangent1 defines the first tangent vector
  2997. * @param value2 defines the second control point
  2998. * @param tangent2 defines the second tangent vector
  2999. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3000. * @returns the new Vector3
  3001. */
  3002. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3003. /**
  3004. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3005. * @param start defines the start value
  3006. * @param end defines the end value
  3007. * @param amount max defines amount between both (between 0 and 1)
  3008. * @returns the new Vector3
  3009. */
  3010. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3011. /**
  3012. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3013. * @param start defines the start value
  3014. * @param end defines the end value
  3015. * @param amount max defines amount between both (between 0 and 1)
  3016. * @param result defines the Vector3 where to store the result
  3017. */
  3018. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3019. /**
  3020. * Returns the dot product (float) between the vectors "left" and "right"
  3021. * @param left defines the left operand
  3022. * @param right defines the right operand
  3023. * @returns the dot product
  3024. */
  3025. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3026. /**
  3027. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3028. * The cross product is then orthogonal to both "left" and "right"
  3029. * @param left defines the left operand
  3030. * @param right defines the right operand
  3031. * @returns the cross product
  3032. */
  3033. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3034. /**
  3035. * Sets the given vector "result" with the cross product of "left" and "right"
  3036. * The cross product is then orthogonal to both "left" and "right"
  3037. * @param left defines the left operand
  3038. * @param right defines the right operand
  3039. * @param result defines the Vector3 where to store the result
  3040. */
  3041. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3042. /**
  3043. * Returns a new Vector3 as the normalization of the given vector
  3044. * @param vector defines the Vector3 to normalize
  3045. * @returns the new Vector3
  3046. */
  3047. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3048. /**
  3049. * Sets the given vector "result" with the normalization of the given first vector
  3050. * @param vector defines the Vector3 to normalize
  3051. * @param result defines the Vector3 where to store the result
  3052. */
  3053. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3054. /**
  3055. * Project a Vector3 onto screen space
  3056. * @param vector defines the Vector3 to project
  3057. * @param world defines the world matrix to use
  3058. * @param transform defines the transform (view x projection) matrix to use
  3059. * @param viewport defines the screen viewport to use
  3060. * @returns the new Vector3
  3061. */
  3062. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3063. /** @hidden */
  3064. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3065. /**
  3066. * Unproject from screen space to object space
  3067. * @param source defines the screen space Vector3 to use
  3068. * @param viewportWidth defines the current width of the viewport
  3069. * @param viewportHeight defines the current height of the viewport
  3070. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3071. * @param transform defines the transform (view x projection) matrix to use
  3072. * @returns the new Vector3
  3073. */
  3074. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3075. /**
  3076. * Unproject from screen space to object space
  3077. * @param source defines the screen space Vector3 to use
  3078. * @param viewportWidth defines the current width of the viewport
  3079. * @param viewportHeight defines the current height of the viewport
  3080. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3081. * @param view defines the view matrix to use
  3082. * @param projection defines the projection matrix to use
  3083. * @returns the new Vector3
  3084. */
  3085. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3086. /**
  3087. * Unproject from screen space to object space
  3088. * @param source defines the screen space Vector3 to use
  3089. * @param viewportWidth defines the current width of the viewport
  3090. * @param viewportHeight defines the current height of the viewport
  3091. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3092. * @param view defines the view matrix to use
  3093. * @param projection defines the projection matrix to use
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3097. /**
  3098. * Unproject from screen space to object space
  3099. * @param sourceX defines the screen space x coordinate to use
  3100. * @param sourceY defines the screen space y coordinate to use
  3101. * @param sourceZ defines the screen space z coordinate to use
  3102. * @param viewportWidth defines the current width of the viewport
  3103. * @param viewportHeight defines the current height of the viewport
  3104. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3105. * @param view defines the view matrix to use
  3106. * @param projection defines the projection matrix to use
  3107. * @param result defines the Vector3 where to store the result
  3108. */
  3109. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3110. /**
  3111. * Gets the minimal coordinate values between two Vector3
  3112. * @param left defines the first operand
  3113. * @param right defines the second operand
  3114. * @returns the new Vector3
  3115. */
  3116. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3117. /**
  3118. * Gets the maximal coordinate values between two Vector3
  3119. * @param left defines the first operand
  3120. * @param right defines the second operand
  3121. * @returns the new Vector3
  3122. */
  3123. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3124. /**
  3125. * Returns the distance between the vectors "value1" and "value2"
  3126. * @param value1 defines the first operand
  3127. * @param value2 defines the second operand
  3128. * @returns the distance
  3129. */
  3130. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3131. /**
  3132. * Returns the squared distance between the vectors "value1" and "value2"
  3133. * @param value1 defines the first operand
  3134. * @param value2 defines the second operand
  3135. * @returns the squared distance
  3136. */
  3137. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3138. /**
  3139. * Returns a new Vector3 located at the center between "value1" and "value2"
  3140. * @param value1 defines the first operand
  3141. * @param value2 defines the second operand
  3142. * @returns the new Vector3
  3143. */
  3144. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3145. /**
  3146. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3147. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3148. * to something in order to rotate it from its local system to the given target system
  3149. * Note: axis1, axis2 and axis3 are normalized during this operation
  3150. * @param axis1 defines the first axis
  3151. * @param axis2 defines the second axis
  3152. * @param axis3 defines the third axis
  3153. * @returns a new Vector3
  3154. */
  3155. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3156. /**
  3157. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3158. * @param axis1 defines the first axis
  3159. * @param axis2 defines the second axis
  3160. * @param axis3 defines the third axis
  3161. * @param ref defines the Vector3 where to store the result
  3162. */
  3163. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3164. }
  3165. /**
  3166. * Vector4 class created for EulerAngle class conversion to Quaternion
  3167. */
  3168. export class Vector4 {
  3169. /** x value of the vector */
  3170. x: number;
  3171. /** y value of the vector */
  3172. y: number;
  3173. /** z value of the vector */
  3174. z: number;
  3175. /** w value of the vector */
  3176. w: number;
  3177. /**
  3178. * Creates a Vector4 object from the given floats.
  3179. * @param x x value of the vector
  3180. * @param y y value of the vector
  3181. * @param z z value of the vector
  3182. * @param w w value of the vector
  3183. */
  3184. constructor(
  3185. /** x value of the vector */
  3186. x: number,
  3187. /** y value of the vector */
  3188. y: number,
  3189. /** z value of the vector */
  3190. z: number,
  3191. /** w value of the vector */
  3192. w: number);
  3193. /**
  3194. * Returns the string with the Vector4 coordinates.
  3195. * @returns a string containing all the vector values
  3196. */
  3197. toString(): string;
  3198. /**
  3199. * Returns the string "Vector4".
  3200. * @returns "Vector4"
  3201. */
  3202. getClassName(): string;
  3203. /**
  3204. * Returns the Vector4 hash code.
  3205. * @returns a unique hash code
  3206. */
  3207. getHashCode(): number;
  3208. /**
  3209. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3210. * @returns the resulting array
  3211. */
  3212. asArray(): number[];
  3213. /**
  3214. * Populates the given array from the given index with the Vector4 coordinates.
  3215. * @param array array to populate
  3216. * @param index index of the array to start at (default: 0)
  3217. * @returns the Vector4.
  3218. */
  3219. toArray(array: FloatArray, index?: number): Vector4;
  3220. /**
  3221. * Adds the given vector to the current Vector4.
  3222. * @param otherVector the vector to add
  3223. * @returns the updated Vector4.
  3224. */
  3225. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3226. /**
  3227. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3228. * @param otherVector the vector to add
  3229. * @returns the resulting vector
  3230. */
  3231. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3232. /**
  3233. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3234. * @param otherVector the vector to add
  3235. * @param result the vector to store the result
  3236. * @returns the current Vector4.
  3237. */
  3238. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3239. /**
  3240. * Subtract in place the given vector from the current Vector4.
  3241. * @param otherVector the vector to subtract
  3242. * @returns the updated Vector4.
  3243. */
  3244. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3245. /**
  3246. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3247. * @param otherVector the vector to add
  3248. * @returns the new vector with the result
  3249. */
  3250. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3251. /**
  3252. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3253. * @param otherVector the vector to subtract
  3254. * @param result the vector to store the result
  3255. * @returns the current Vector4.
  3256. */
  3257. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3258. /**
  3259. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3260. */
  3261. /**
  3262. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3263. * @param x value to subtract
  3264. * @param y value to subtract
  3265. * @param z value to subtract
  3266. * @param w value to subtract
  3267. * @returns new vector containing the result
  3268. */
  3269. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3270. /**
  3271. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3272. * @param x value to subtract
  3273. * @param y value to subtract
  3274. * @param z value to subtract
  3275. * @param w value to subtract
  3276. * @param result the vector to store the result in
  3277. * @returns the current Vector4.
  3278. */
  3279. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3280. /**
  3281. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3282. * @returns a new vector with the negated values
  3283. */
  3284. negate(): Vector4;
  3285. /**
  3286. * Negate this vector in place
  3287. * @returns this
  3288. */
  3289. negateInPlace(): Vector4;
  3290. /**
  3291. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3292. * @param result defines the Vector3 object where to store the result
  3293. * @returns the current Vector4
  3294. */
  3295. negateToRef(result: Vector4): Vector4;
  3296. /**
  3297. * Multiplies the current Vector4 coordinates by scale (float).
  3298. * @param scale the number to scale with
  3299. * @returns the updated Vector4.
  3300. */
  3301. scaleInPlace(scale: number): Vector4;
  3302. /**
  3303. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3304. * @param scale the number to scale with
  3305. * @returns a new vector with the result
  3306. */
  3307. scale(scale: number): Vector4;
  3308. /**
  3309. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3310. * @param scale the number to scale with
  3311. * @param result a vector to store the result in
  3312. * @returns the current Vector4.
  3313. */
  3314. scaleToRef(scale: number, result: Vector4): Vector4;
  3315. /**
  3316. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3317. * @param scale defines the scale factor
  3318. * @param result defines the Vector4 object where to store the result
  3319. * @returns the unmodified current Vector4
  3320. */
  3321. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3322. /**
  3323. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3324. * @param otherVector the vector to compare against
  3325. * @returns true if they are equal
  3326. */
  3327. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3328. /**
  3329. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3330. * @param otherVector vector to compare against
  3331. * @param epsilon (Default: very small number)
  3332. * @returns true if they are equal
  3333. */
  3334. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3335. /**
  3336. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3337. * @param x x value to compare against
  3338. * @param y y value to compare against
  3339. * @param z z value to compare against
  3340. * @param w w value to compare against
  3341. * @returns true if equal
  3342. */
  3343. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3344. /**
  3345. * Multiplies in place the current Vector4 by the given one.
  3346. * @param otherVector vector to multiple with
  3347. * @returns the updated Vector4.
  3348. */
  3349. multiplyInPlace(otherVector: Vector4): Vector4;
  3350. /**
  3351. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3352. * @param otherVector vector to multiple with
  3353. * @returns resulting new vector
  3354. */
  3355. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3356. /**
  3357. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3358. * @param otherVector vector to multiple with
  3359. * @param result vector to store the result
  3360. * @returns the current Vector4.
  3361. */
  3362. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3363. /**
  3364. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3365. * @param x x value multiply with
  3366. * @param y y value multiply with
  3367. * @param z z value multiply with
  3368. * @param w w value multiply with
  3369. * @returns resulting new vector
  3370. */
  3371. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3372. /**
  3373. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3374. * @param otherVector vector to devide with
  3375. * @returns resulting new vector
  3376. */
  3377. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3378. /**
  3379. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3380. * @param otherVector vector to devide with
  3381. * @param result vector to store the result
  3382. * @returns the current Vector4.
  3383. */
  3384. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3385. /**
  3386. * Divides the current Vector3 coordinates by the given ones.
  3387. * @param otherVector vector to devide with
  3388. * @returns the updated Vector3.
  3389. */
  3390. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3393. * @param other defines the second operand
  3394. * @returns the current updated Vector4
  3395. */
  3396. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3397. /**
  3398. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3399. * @param other defines the second operand
  3400. * @returns the current updated Vector4
  3401. */
  3402. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3403. /**
  3404. * Gets a new Vector4 from current Vector4 floored values
  3405. * @returns a new Vector4
  3406. */
  3407. floor(): Vector4;
  3408. /**
  3409. * Gets a new Vector4 from current Vector3 floored values
  3410. * @returns a new Vector4
  3411. */
  3412. fract(): Vector4;
  3413. /**
  3414. * Returns the Vector4 length (float).
  3415. * @returns the length
  3416. */
  3417. length(): number;
  3418. /**
  3419. * Returns the Vector4 squared length (float).
  3420. * @returns the length squared
  3421. */
  3422. lengthSquared(): number;
  3423. /**
  3424. * Normalizes in place the Vector4.
  3425. * @returns the updated Vector4.
  3426. */
  3427. normalize(): Vector4;
  3428. /**
  3429. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3430. * @returns this converted to a new vector3
  3431. */
  3432. toVector3(): Vector3;
  3433. /**
  3434. * Returns a new Vector4 copied from the current one.
  3435. * @returns the new cloned vector
  3436. */
  3437. clone(): Vector4;
  3438. /**
  3439. * Updates the current Vector4 with the given one coordinates.
  3440. * @param source the source vector to copy from
  3441. * @returns the updated Vector4.
  3442. */
  3443. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the current Vector4 coordinates with the given floats.
  3446. * @param x float to copy from
  3447. * @param y float to copy from
  3448. * @param z float to copy from
  3449. * @param w float to copy from
  3450. * @returns the updated Vector4.
  3451. */
  3452. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3453. /**
  3454. * Updates the current Vector4 coordinates with the given floats.
  3455. * @param x float to set from
  3456. * @param y float to set from
  3457. * @param z float to set from
  3458. * @param w float to set from
  3459. * @returns the updated Vector4.
  3460. */
  3461. set(x: number, y: number, z: number, w: number): Vector4;
  3462. /**
  3463. * Copies the given float to the current Vector3 coordinates
  3464. * @param v defines the x, y, z and w coordinates of the operand
  3465. * @returns the current updated Vector3
  3466. */
  3467. setAll(v: number): Vector4;
  3468. /**
  3469. * Returns a new Vector4 set from the starting index of the given array.
  3470. * @param array the array to pull values from
  3471. * @param offset the offset into the array to start at
  3472. * @returns the new vector
  3473. */
  3474. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3475. /**
  3476. * Updates the given vector "result" from the starting index of the given array.
  3477. * @param array the array to pull values from
  3478. * @param offset the offset into the array to start at
  3479. * @param result the vector to store the result in
  3480. */
  3481. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3482. /**
  3483. * Updates the given vector "result" from the starting index of the given Float32Array.
  3484. * @param array the array to pull values from
  3485. * @param offset the offset into the array to start at
  3486. * @param result the vector to store the result in
  3487. */
  3488. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3489. /**
  3490. * Updates the given vector "result" coordinates from the given floats.
  3491. * @param x float to set from
  3492. * @param y float to set from
  3493. * @param z float to set from
  3494. * @param w float to set from
  3495. * @param result the vector to the floats in
  3496. */
  3497. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3498. /**
  3499. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3500. * @returns the new vector
  3501. */
  3502. static Zero(): Vector4;
  3503. /**
  3504. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3505. * @returns the new vector
  3506. */
  3507. static One(): Vector4;
  3508. /**
  3509. * Returns a new normalized Vector4 from the given one.
  3510. * @param vector the vector to normalize
  3511. * @returns the vector
  3512. */
  3513. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3514. /**
  3515. * Updates the given vector "result" from the normalization of the given one.
  3516. * @param vector the vector to normalize
  3517. * @param result the vector to store the result in
  3518. */
  3519. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3520. /**
  3521. * Returns a vector with the minimum values from the left and right vectors
  3522. * @param left left vector to minimize
  3523. * @param right right vector to minimize
  3524. * @returns a new vector with the minimum of the left and right vector values
  3525. */
  3526. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3527. /**
  3528. * Returns a vector with the maximum values from the left and right vectors
  3529. * @param left left vector to maximize
  3530. * @param right right vector to maximize
  3531. * @returns a new vector with the maximum of the left and right vector values
  3532. */
  3533. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3534. /**
  3535. * Returns the distance (float) between the vectors "value1" and "value2".
  3536. * @param value1 value to calulate the distance between
  3537. * @param value2 value to calulate the distance between
  3538. * @return the distance between the two vectors
  3539. */
  3540. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3541. /**
  3542. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3543. * @param value1 value to calulate the distance between
  3544. * @param value2 value to calulate the distance between
  3545. * @return the distance between the two vectors squared
  3546. */
  3547. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3548. /**
  3549. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3550. * @param value1 value to calulate the center between
  3551. * @param value2 value to calulate the center between
  3552. * @return the center between the two vectors
  3553. */
  3554. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3555. /**
  3556. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3557. * This methods computes transformed normalized direction vectors only.
  3558. * @param vector the vector to transform
  3559. * @param transformation the transformation matrix to apply
  3560. * @returns the new vector
  3561. */
  3562. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3563. /**
  3564. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3565. * This methods computes transformed normalized direction vectors only.
  3566. * @param vector the vector to transform
  3567. * @param transformation the transformation matrix to apply
  3568. * @param result the vector to store the result in
  3569. */
  3570. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3571. /**
  3572. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3573. * This methods computes transformed normalized direction vectors only.
  3574. * @param x value to transform
  3575. * @param y value to transform
  3576. * @param z value to transform
  3577. * @param w value to transform
  3578. * @param transformation the transformation matrix to apply
  3579. * @param result the vector to store the results in
  3580. */
  3581. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3582. /**
  3583. * Creates a new Vector4 from a Vector3
  3584. * @param source defines the source data
  3585. * @param w defines the 4th component (default is 0)
  3586. * @returns a new Vector4
  3587. */
  3588. static FromVector3(source: Vector3, w?: number): Vector4;
  3589. }
  3590. /**
  3591. * Class used to store quaternion data
  3592. * @see https://en.wikipedia.org/wiki/Quaternion
  3593. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3594. */
  3595. export class Quaternion {
  3596. /** @hidden */
  3597. _x: number;
  3598. /** @hidden */
  3599. _y: number;
  3600. /** @hidden */
  3601. _z: number;
  3602. /** @hidden */
  3603. _w: number;
  3604. /** @hidden */
  3605. _isDirty: boolean;
  3606. /** Gets or sets the x coordinate */
  3607. get x(): number;
  3608. set x(value: number);
  3609. /** Gets or sets the y coordinate */
  3610. get y(): number;
  3611. set y(value: number);
  3612. /** Gets or sets the z coordinate */
  3613. get z(): number;
  3614. set z(value: number);
  3615. /** Gets or sets the w coordinate */
  3616. get w(): number;
  3617. set w(value: number);
  3618. /**
  3619. * Creates a new Quaternion from the given floats
  3620. * @param x defines the first component (0 by default)
  3621. * @param y defines the second component (0 by default)
  3622. * @param z defines the third component (0 by default)
  3623. * @param w defines the fourth component (1.0 by default)
  3624. */
  3625. constructor(x?: number, y?: number, z?: number, w?: number);
  3626. /**
  3627. * Gets a string representation for the current quaternion
  3628. * @returns a string with the Quaternion coordinates
  3629. */
  3630. toString(): string;
  3631. /**
  3632. * Gets the class name of the quaternion
  3633. * @returns the string "Quaternion"
  3634. */
  3635. getClassName(): string;
  3636. /**
  3637. * Gets a hash code for this quaternion
  3638. * @returns the quaternion hash code
  3639. */
  3640. getHashCode(): number;
  3641. /**
  3642. * Copy the quaternion to an array
  3643. * @returns a new array populated with 4 elements from the quaternion coordinates
  3644. */
  3645. asArray(): number[];
  3646. /**
  3647. * Check if two quaternions are equals
  3648. * @param otherQuaternion defines the second operand
  3649. * @return true if the current quaternion and the given one coordinates are strictly equals
  3650. */
  3651. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3652. /**
  3653. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3654. * @param otherQuaternion defines the other quaternion
  3655. * @param epsilon defines the minimal distance to consider equality
  3656. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3657. */
  3658. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3659. /**
  3660. * Clone the current quaternion
  3661. * @returns a new quaternion copied from the current one
  3662. */
  3663. clone(): Quaternion;
  3664. /**
  3665. * Copy a quaternion to the current one
  3666. * @param other defines the other quaternion
  3667. * @returns the updated current quaternion
  3668. */
  3669. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3670. /**
  3671. * Updates the current quaternion with the given float coordinates
  3672. * @param x defines the x coordinate
  3673. * @param y defines the y coordinate
  3674. * @param z defines the z coordinate
  3675. * @param w defines the w coordinate
  3676. * @returns the updated current quaternion
  3677. */
  3678. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3679. /**
  3680. * Updates the current quaternion from the given float coordinates
  3681. * @param x defines the x coordinate
  3682. * @param y defines the y coordinate
  3683. * @param z defines the z coordinate
  3684. * @param w defines the w coordinate
  3685. * @returns the updated current quaternion
  3686. */
  3687. set(x: number, y: number, z: number, w: number): Quaternion;
  3688. /**
  3689. * Adds two quaternions
  3690. * @param other defines the second operand
  3691. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3692. */
  3693. add(other: DeepImmutable<Quaternion>): Quaternion;
  3694. /**
  3695. * Add a quaternion to the current one
  3696. * @param other defines the quaternion to add
  3697. * @returns the current quaternion
  3698. */
  3699. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3700. /**
  3701. * Subtract two quaternions
  3702. * @param other defines the second operand
  3703. * @returns a new quaternion as the subtraction result of the given one from the current one
  3704. */
  3705. subtract(other: Quaternion): Quaternion;
  3706. /**
  3707. * Multiplies the current quaternion by a scale factor
  3708. * @param value defines the scale factor
  3709. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3710. */
  3711. scale(value: number): Quaternion;
  3712. /**
  3713. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3714. * @param scale defines the scale factor
  3715. * @param result defines the Quaternion object where to store the result
  3716. * @returns the unmodified current quaternion
  3717. */
  3718. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3719. /**
  3720. * Multiplies in place the current quaternion by a scale factor
  3721. * @param value defines the scale factor
  3722. * @returns the current modified quaternion
  3723. */
  3724. scaleInPlace(value: number): Quaternion;
  3725. /**
  3726. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3727. * @param scale defines the scale factor
  3728. * @param result defines the Quaternion object where to store the result
  3729. * @returns the unmodified current quaternion
  3730. */
  3731. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Multiplies two quaternions
  3734. * @param q1 defines the second operand
  3735. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3736. */
  3737. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3738. /**
  3739. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3740. * @param q1 defines the second operand
  3741. * @param result defines the target quaternion
  3742. * @returns the current quaternion
  3743. */
  3744. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3745. /**
  3746. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3747. * @param q1 defines the second operand
  3748. * @returns the currentupdated quaternion
  3749. */
  3750. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3751. /**
  3752. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3753. * @param ref defines the target quaternion
  3754. * @returns the current quaternion
  3755. */
  3756. conjugateToRef(ref: Quaternion): Quaternion;
  3757. /**
  3758. * Conjugates in place (1-q) the current quaternion
  3759. * @returns the current updated quaternion
  3760. */
  3761. conjugateInPlace(): Quaternion;
  3762. /**
  3763. * Conjugates in place (1-q) the current quaternion
  3764. * @returns a new quaternion
  3765. */
  3766. conjugate(): Quaternion;
  3767. /**
  3768. * Gets length of current quaternion
  3769. * @returns the quaternion length (float)
  3770. */
  3771. length(): number;
  3772. /**
  3773. * Normalize in place the current quaternion
  3774. * @returns the current updated quaternion
  3775. */
  3776. normalize(): Quaternion;
  3777. /**
  3778. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3779. * @param order is a reserved parameter and is ignore for now
  3780. * @returns a new Vector3 containing the Euler angles
  3781. */
  3782. toEulerAngles(order?: string): Vector3;
  3783. /**
  3784. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3785. * @param result defines the vector which will be filled with the Euler angles
  3786. * @param order is a reserved parameter and is ignore for now
  3787. * @returns the current unchanged quaternion
  3788. */
  3789. toEulerAnglesToRef(result: Vector3): Quaternion;
  3790. /**
  3791. * Updates the given rotation matrix with the current quaternion values
  3792. * @param result defines the target matrix
  3793. * @returns the current unchanged quaternion
  3794. */
  3795. toRotationMatrix(result: Matrix): Quaternion;
  3796. /**
  3797. * Updates the current quaternion from the given rotation matrix values
  3798. * @param matrix defines the source matrix
  3799. * @returns the current updated quaternion
  3800. */
  3801. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3802. /**
  3803. * Creates a new quaternion from a rotation matrix
  3804. * @param matrix defines the source matrix
  3805. * @returns a new quaternion created from the given rotation matrix values
  3806. */
  3807. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3808. /**
  3809. * Updates the given quaternion with the given rotation matrix values
  3810. * @param matrix defines the source matrix
  3811. * @param result defines the target quaternion
  3812. */
  3813. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3814. /**
  3815. * Returns the dot product (float) between the quaternions "left" and "right"
  3816. * @param left defines the left operand
  3817. * @param right defines the right operand
  3818. * @returns the dot product
  3819. */
  3820. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3821. /**
  3822. * Checks if the two quaternions are close to each other
  3823. * @param quat0 defines the first quaternion to check
  3824. * @param quat1 defines the second quaternion to check
  3825. * @returns true if the two quaternions are close to each other
  3826. */
  3827. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3828. /**
  3829. * Creates an empty quaternion
  3830. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3831. */
  3832. static Zero(): Quaternion;
  3833. /**
  3834. * Inverse a given quaternion
  3835. * @param q defines the source quaternion
  3836. * @returns a new quaternion as the inverted current quaternion
  3837. */
  3838. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3839. /**
  3840. * Inverse a given quaternion
  3841. * @param q defines the source quaternion
  3842. * @param result the quaternion the result will be stored in
  3843. * @returns the result quaternion
  3844. */
  3845. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3846. /**
  3847. * Creates an identity quaternion
  3848. * @returns the identity quaternion
  3849. */
  3850. static Identity(): Quaternion;
  3851. /**
  3852. * Gets a boolean indicating if the given quaternion is identity
  3853. * @param quaternion defines the quaternion to check
  3854. * @returns true if the quaternion is identity
  3855. */
  3856. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3857. /**
  3858. * Creates a quaternion from a rotation around an axis
  3859. * @param axis defines the axis to use
  3860. * @param angle defines the angle to use
  3861. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3862. */
  3863. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3864. /**
  3865. * Creates a rotation around an axis and stores it into the given quaternion
  3866. * @param axis defines the axis to use
  3867. * @param angle defines the angle to use
  3868. * @param result defines the target quaternion
  3869. * @returns the target quaternion
  3870. */
  3871. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3872. /**
  3873. * Creates a new quaternion from data stored into an array
  3874. * @param array defines the data source
  3875. * @param offset defines the offset in the source array where the data starts
  3876. * @returns a new quaternion
  3877. */
  3878. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3879. /**
  3880. * Updates the given quaternion "result" from the starting index of the given array.
  3881. * @param array the array to pull values from
  3882. * @param offset the offset into the array to start at
  3883. * @param result the quaternion to store the result in
  3884. */
  3885. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3886. /**
  3887. * Create a quaternion from Euler rotation angles
  3888. * @param x Pitch
  3889. * @param y Yaw
  3890. * @param z Roll
  3891. * @returns the new Quaternion
  3892. */
  3893. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3894. /**
  3895. * Updates a quaternion from Euler rotation angles
  3896. * @param x Pitch
  3897. * @param y Yaw
  3898. * @param z Roll
  3899. * @param result the quaternion to store the result
  3900. * @returns the updated quaternion
  3901. */
  3902. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3903. /**
  3904. * Create a quaternion from Euler rotation vector
  3905. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3906. * @returns the new Quaternion
  3907. */
  3908. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3909. /**
  3910. * Updates a quaternion from Euler rotation vector
  3911. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3912. * @param result the quaternion to store the result
  3913. * @returns the updated quaternion
  3914. */
  3915. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3916. /**
  3917. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3918. * @param yaw defines the rotation around Y axis
  3919. * @param pitch defines the rotation around X axis
  3920. * @param roll defines the rotation around Z axis
  3921. * @returns the new quaternion
  3922. */
  3923. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3924. /**
  3925. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3926. * @param yaw defines the rotation around Y axis
  3927. * @param pitch defines the rotation around X axis
  3928. * @param roll defines the rotation around Z axis
  3929. * @param result defines the target quaternion
  3930. */
  3931. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3932. /**
  3933. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3934. * @param alpha defines the rotation around first axis
  3935. * @param beta defines the rotation around second axis
  3936. * @param gamma defines the rotation around third axis
  3937. * @returns the new quaternion
  3938. */
  3939. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3940. /**
  3941. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3942. * @param alpha defines the rotation around first axis
  3943. * @param beta defines the rotation around second axis
  3944. * @param gamma defines the rotation around third axis
  3945. * @param result defines the target quaternion
  3946. */
  3947. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3948. /**
  3949. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3950. * @param axis1 defines the first axis
  3951. * @param axis2 defines the second axis
  3952. * @param axis3 defines the third axis
  3953. * @returns the new quaternion
  3954. */
  3955. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3956. /**
  3957. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3958. * @param axis1 defines the first axis
  3959. * @param axis2 defines the second axis
  3960. * @param axis3 defines the third axis
  3961. * @param ref defines the target quaternion
  3962. */
  3963. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3964. /**
  3965. * Interpolates between two quaternions
  3966. * @param left defines first quaternion
  3967. * @param right defines second quaternion
  3968. * @param amount defines the gradient to use
  3969. * @returns the new interpolated quaternion
  3970. */
  3971. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3972. /**
  3973. * Interpolates between two quaternions and stores it into a target quaternion
  3974. * @param left defines first quaternion
  3975. * @param right defines second quaternion
  3976. * @param amount defines the gradient to use
  3977. * @param result defines the target quaternion
  3978. */
  3979. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3980. /**
  3981. * Interpolate between two quaternions using Hermite interpolation
  3982. * @param value1 defines first quaternion
  3983. * @param tangent1 defines the incoming tangent
  3984. * @param value2 defines second quaternion
  3985. * @param tangent2 defines the outgoing tangent
  3986. * @param amount defines the target quaternion
  3987. * @returns the new interpolated quaternion
  3988. */
  3989. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3990. }
  3991. /**
  3992. * Class used to store matrix data (4x4)
  3993. */
  3994. export class Matrix {
  3995. private static _updateFlagSeed;
  3996. private static _identityReadOnly;
  3997. private _isIdentity;
  3998. private _isIdentityDirty;
  3999. private _isIdentity3x2;
  4000. private _isIdentity3x2Dirty;
  4001. /**
  4002. * Gets the update flag of the matrix which is an unique number for the matrix.
  4003. * It will be incremented every time the matrix data change.
  4004. * You can use it to speed the comparison between two versions of the same matrix.
  4005. */
  4006. updateFlag: number;
  4007. private readonly _m;
  4008. /**
  4009. * Gets the internal data of the matrix
  4010. */
  4011. get m(): DeepImmutable<Float32Array>;
  4012. /** @hidden */
  4013. _markAsUpdated(): void;
  4014. /** @hidden */
  4015. private _updateIdentityStatus;
  4016. /**
  4017. * Creates an empty matrix (filled with zeros)
  4018. */
  4019. constructor();
  4020. /**
  4021. * Check if the current matrix is identity
  4022. * @returns true is the matrix is the identity matrix
  4023. */
  4024. isIdentity(): boolean;
  4025. /**
  4026. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4027. * @returns true is the matrix is the identity matrix
  4028. */
  4029. isIdentityAs3x2(): boolean;
  4030. /**
  4031. * Gets the determinant of the matrix
  4032. * @returns the matrix determinant
  4033. */
  4034. determinant(): number;
  4035. /**
  4036. * Returns the matrix as a Float32Array
  4037. * @returns the matrix underlying array
  4038. */
  4039. toArray(): DeepImmutable<Float32Array>;
  4040. /**
  4041. * Returns the matrix as a Float32Array
  4042. * @returns the matrix underlying array.
  4043. */
  4044. asArray(): DeepImmutable<Float32Array>;
  4045. /**
  4046. * Inverts the current matrix in place
  4047. * @returns the current inverted matrix
  4048. */
  4049. invert(): Matrix;
  4050. /**
  4051. * Sets all the matrix elements to zero
  4052. * @returns the current matrix
  4053. */
  4054. reset(): Matrix;
  4055. /**
  4056. * Adds the current matrix with a second one
  4057. * @param other defines the matrix to add
  4058. * @returns a new matrix as the addition of the current matrix and the given one
  4059. */
  4060. add(other: DeepImmutable<Matrix>): Matrix;
  4061. /**
  4062. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4063. * @param other defines the matrix to add
  4064. * @param result defines the target matrix
  4065. * @returns the current matrix
  4066. */
  4067. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4068. /**
  4069. * Adds in place the given matrix to the current matrix
  4070. * @param other defines the second operand
  4071. * @returns the current updated matrix
  4072. */
  4073. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4074. /**
  4075. * Sets the given matrix to the current inverted Matrix
  4076. * @param other defines the target matrix
  4077. * @returns the unmodified current matrix
  4078. */
  4079. invertToRef(other: Matrix): Matrix;
  4080. /**
  4081. * add a value at the specified position in the current Matrix
  4082. * @param index the index of the value within the matrix. between 0 and 15.
  4083. * @param value the value to be added
  4084. * @returns the current updated matrix
  4085. */
  4086. addAtIndex(index: number, value: number): Matrix;
  4087. /**
  4088. * mutiply the specified position in the current Matrix by a value
  4089. * @param index the index of the value within the matrix. between 0 and 15.
  4090. * @param value the value to be added
  4091. * @returns the current updated matrix
  4092. */
  4093. multiplyAtIndex(index: number, value: number): Matrix;
  4094. /**
  4095. * Inserts the translation vector (using 3 floats) in the current matrix
  4096. * @param x defines the 1st component of the translation
  4097. * @param y defines the 2nd component of the translation
  4098. * @param z defines the 3rd component of the translation
  4099. * @returns the current updated matrix
  4100. */
  4101. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4102. /**
  4103. * Adds the translation vector (using 3 floats) in the current matrix
  4104. * @param x defines the 1st component of the translation
  4105. * @param y defines the 2nd component of the translation
  4106. * @param z defines the 3rd component of the translation
  4107. * @returns the current updated matrix
  4108. */
  4109. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4110. /**
  4111. * Inserts the translation vector in the current matrix
  4112. * @param vector3 defines the translation to insert
  4113. * @returns the current updated matrix
  4114. */
  4115. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4116. /**
  4117. * Gets the translation value of the current matrix
  4118. * @returns a new Vector3 as the extracted translation from the matrix
  4119. */
  4120. getTranslation(): Vector3;
  4121. /**
  4122. * Fill a Vector3 with the extracted translation from the matrix
  4123. * @param result defines the Vector3 where to store the translation
  4124. * @returns the current matrix
  4125. */
  4126. getTranslationToRef(result: Vector3): Matrix;
  4127. /**
  4128. * Remove rotation and scaling part from the matrix
  4129. * @returns the updated matrix
  4130. */
  4131. removeRotationAndScaling(): Matrix;
  4132. /**
  4133. * Multiply two matrices
  4134. * @param other defines the second operand
  4135. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4136. */
  4137. multiply(other: DeepImmutable<Matrix>): Matrix;
  4138. /**
  4139. * Copy the current matrix from the given one
  4140. * @param other defines the source matrix
  4141. * @returns the current updated matrix
  4142. */
  4143. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4144. /**
  4145. * Populates the given array from the starting index with the current matrix values
  4146. * @param array defines the target array
  4147. * @param offset defines the offset in the target array where to start storing values
  4148. * @returns the current matrix
  4149. */
  4150. copyToArray(array: Float32Array, offset?: number): Matrix;
  4151. /**
  4152. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4153. * @param other defines the second operand
  4154. * @param result defines the matrix where to store the multiplication
  4155. * @returns the current matrix
  4156. */
  4157. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4158. /**
  4159. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4160. * @param other defines the second operand
  4161. * @param result defines the array where to store the multiplication
  4162. * @param offset defines the offset in the target array where to start storing values
  4163. * @returns the current matrix
  4164. */
  4165. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4166. /**
  4167. * Check equality between this matrix and a second one
  4168. * @param value defines the second matrix to compare
  4169. * @returns true is the current matrix and the given one values are strictly equal
  4170. */
  4171. equals(value: DeepImmutable<Matrix>): boolean;
  4172. /**
  4173. * Clone the current matrix
  4174. * @returns a new matrix from the current matrix
  4175. */
  4176. clone(): Matrix;
  4177. /**
  4178. * Returns the name of the current matrix class
  4179. * @returns the string "Matrix"
  4180. */
  4181. getClassName(): string;
  4182. /**
  4183. * Gets the hash code of the current matrix
  4184. * @returns the hash code
  4185. */
  4186. getHashCode(): number;
  4187. /**
  4188. * Decomposes the current Matrix into a translation, rotation and scaling components
  4189. * @param scale defines the scale vector3 given as a reference to update
  4190. * @param rotation defines the rotation quaternion given as a reference to update
  4191. * @param translation defines the translation vector3 given as a reference to update
  4192. * @returns true if operation was successful
  4193. */
  4194. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4195. /**
  4196. * Gets specific row of the matrix
  4197. * @param index defines the number of the row to get
  4198. * @returns the index-th row of the current matrix as a new Vector4
  4199. */
  4200. getRow(index: number): Nullable<Vector4>;
  4201. /**
  4202. * Sets the index-th row of the current matrix to the vector4 values
  4203. * @param index defines the number of the row to set
  4204. * @param row defines the target vector4
  4205. * @returns the updated current matrix
  4206. */
  4207. setRow(index: number, row: Vector4): Matrix;
  4208. /**
  4209. * Compute the transpose of the matrix
  4210. * @returns the new transposed matrix
  4211. */
  4212. transpose(): Matrix;
  4213. /**
  4214. * Compute the transpose of the matrix and store it in a given matrix
  4215. * @param result defines the target matrix
  4216. * @returns the current matrix
  4217. */
  4218. transposeToRef(result: Matrix): Matrix;
  4219. /**
  4220. * Sets the index-th row of the current matrix with the given 4 x float values
  4221. * @param index defines the row index
  4222. * @param x defines the x component to set
  4223. * @param y defines the y component to set
  4224. * @param z defines the z component to set
  4225. * @param w defines the w component to set
  4226. * @returns the updated current matrix
  4227. */
  4228. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4229. /**
  4230. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4231. * @param scale defines the scale factor
  4232. * @returns a new matrix
  4233. */
  4234. scale(scale: number): Matrix;
  4235. /**
  4236. * Scale the current matrix values by a factor to a given result matrix
  4237. * @param scale defines the scale factor
  4238. * @param result defines the matrix to store the result
  4239. * @returns the current matrix
  4240. */
  4241. scaleToRef(scale: number, result: Matrix): Matrix;
  4242. /**
  4243. * Scale the current matrix values by a factor and add the result to a given matrix
  4244. * @param scale defines the scale factor
  4245. * @param result defines the Matrix to store the result
  4246. * @returns the current matrix
  4247. */
  4248. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4249. /**
  4250. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4251. * @param ref matrix to store the result
  4252. */
  4253. toNormalMatrix(ref: Matrix): void;
  4254. /**
  4255. * Gets only rotation part of the current matrix
  4256. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4257. */
  4258. getRotationMatrix(): Matrix;
  4259. /**
  4260. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4261. * @param result defines the target matrix to store data to
  4262. * @returns the current matrix
  4263. */
  4264. getRotationMatrixToRef(result: Matrix): Matrix;
  4265. /**
  4266. * Toggles model matrix from being right handed to left handed in place and vice versa
  4267. */
  4268. toggleModelMatrixHandInPlace(): void;
  4269. /**
  4270. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4271. */
  4272. toggleProjectionMatrixHandInPlace(): void;
  4273. /**
  4274. * Creates a matrix from an array
  4275. * @param array defines the source array
  4276. * @param offset defines an offset in the source array
  4277. * @returns a new Matrix set from the starting index of the given array
  4278. */
  4279. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4280. /**
  4281. * Copy the content of an array into a given matrix
  4282. * @param array defines the source array
  4283. * @param offset defines an offset in the source array
  4284. * @param result defines the target matrix
  4285. */
  4286. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4287. /**
  4288. * Stores an array into a matrix after having multiplied each component by a given factor
  4289. * @param array defines the source array
  4290. * @param offset defines the offset in the source array
  4291. * @param scale defines the scaling factor
  4292. * @param result defines the target matrix
  4293. */
  4294. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4295. /**
  4296. * Gets an identity matrix that must not be updated
  4297. */
  4298. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4299. /**
  4300. * Stores a list of values (16) inside a given matrix
  4301. * @param initialM11 defines 1st value of 1st row
  4302. * @param initialM12 defines 2nd value of 1st row
  4303. * @param initialM13 defines 3rd value of 1st row
  4304. * @param initialM14 defines 4th value of 1st row
  4305. * @param initialM21 defines 1st value of 2nd row
  4306. * @param initialM22 defines 2nd value of 2nd row
  4307. * @param initialM23 defines 3rd value of 2nd row
  4308. * @param initialM24 defines 4th value of 2nd row
  4309. * @param initialM31 defines 1st value of 3rd row
  4310. * @param initialM32 defines 2nd value of 3rd row
  4311. * @param initialM33 defines 3rd value of 3rd row
  4312. * @param initialM34 defines 4th value of 3rd row
  4313. * @param initialM41 defines 1st value of 4th row
  4314. * @param initialM42 defines 2nd value of 4th row
  4315. * @param initialM43 defines 3rd value of 4th row
  4316. * @param initialM44 defines 4th value of 4th row
  4317. * @param result defines the target matrix
  4318. */
  4319. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4320. /**
  4321. * Creates new matrix from a list of values (16)
  4322. * @param initialM11 defines 1st value of 1st row
  4323. * @param initialM12 defines 2nd value of 1st row
  4324. * @param initialM13 defines 3rd value of 1st row
  4325. * @param initialM14 defines 4th value of 1st row
  4326. * @param initialM21 defines 1st value of 2nd row
  4327. * @param initialM22 defines 2nd value of 2nd row
  4328. * @param initialM23 defines 3rd value of 2nd row
  4329. * @param initialM24 defines 4th value of 2nd row
  4330. * @param initialM31 defines 1st value of 3rd row
  4331. * @param initialM32 defines 2nd value of 3rd row
  4332. * @param initialM33 defines 3rd value of 3rd row
  4333. * @param initialM34 defines 4th value of 3rd row
  4334. * @param initialM41 defines 1st value of 4th row
  4335. * @param initialM42 defines 2nd value of 4th row
  4336. * @param initialM43 defines 3rd value of 4th row
  4337. * @param initialM44 defines 4th value of 4th row
  4338. * @returns the new matrix
  4339. */
  4340. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4341. /**
  4342. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4343. * @param scale defines the scale vector3
  4344. * @param rotation defines the rotation quaternion
  4345. * @param translation defines the translation vector3
  4346. * @returns a new matrix
  4347. */
  4348. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4349. /**
  4350. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4351. * @param scale defines the scale vector3
  4352. * @param rotation defines the rotation quaternion
  4353. * @param translation defines the translation vector3
  4354. * @param result defines the target matrix
  4355. */
  4356. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4357. /**
  4358. * Creates a new identity matrix
  4359. * @returns a new identity matrix
  4360. */
  4361. static Identity(): Matrix;
  4362. /**
  4363. * Creates a new identity matrix and stores the result in a given matrix
  4364. * @param result defines the target matrix
  4365. */
  4366. static IdentityToRef(result: Matrix): void;
  4367. /**
  4368. * Creates a new zero matrix
  4369. * @returns a new zero matrix
  4370. */
  4371. static Zero(): Matrix;
  4372. /**
  4373. * Creates a new rotation matrix for "angle" radians around the X axis
  4374. * @param angle defines the angle (in radians) to use
  4375. * @return the new matrix
  4376. */
  4377. static RotationX(angle: number): Matrix;
  4378. /**
  4379. * Creates a new matrix as the invert of a given matrix
  4380. * @param source defines the source matrix
  4381. * @returns the new matrix
  4382. */
  4383. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4384. /**
  4385. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4386. * @param angle defines the angle (in radians) to use
  4387. * @param result defines the target matrix
  4388. */
  4389. static RotationXToRef(angle: number, result: Matrix): void;
  4390. /**
  4391. * Creates a new rotation matrix for "angle" radians around the Y axis
  4392. * @param angle defines the angle (in radians) to use
  4393. * @return the new matrix
  4394. */
  4395. static RotationY(angle: number): Matrix;
  4396. /**
  4397. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4398. * @param angle defines the angle (in radians) to use
  4399. * @param result defines the target matrix
  4400. */
  4401. static RotationYToRef(angle: number, result: Matrix): void;
  4402. /**
  4403. * Creates a new rotation matrix for "angle" radians around the Z axis
  4404. * @param angle defines the angle (in radians) to use
  4405. * @return the new matrix
  4406. */
  4407. static RotationZ(angle: number): Matrix;
  4408. /**
  4409. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4410. * @param angle defines the angle (in radians) to use
  4411. * @param result defines the target matrix
  4412. */
  4413. static RotationZToRef(angle: number, result: Matrix): void;
  4414. /**
  4415. * Creates a new rotation matrix for "angle" radians around the given axis
  4416. * @param axis defines the axis to use
  4417. * @param angle defines the angle (in radians) to use
  4418. * @return the new matrix
  4419. */
  4420. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4423. * @param axis defines the axis to use
  4424. * @param angle defines the angle (in radians) to use
  4425. * @param result defines the target matrix
  4426. */
  4427. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4428. /**
  4429. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4430. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4431. * @param from defines the vector to align
  4432. * @param to defines the vector to align to
  4433. * @param result defines the target matrix
  4434. */
  4435. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4436. /**
  4437. * Creates a rotation matrix
  4438. * @param yaw defines the yaw angle in radians (Y axis)
  4439. * @param pitch defines the pitch angle in radians (X axis)
  4440. * @param roll defines the roll angle in radians (X axis)
  4441. * @returns the new rotation matrix
  4442. */
  4443. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4444. /**
  4445. * Creates a rotation matrix and stores it in a given matrix
  4446. * @param yaw defines the yaw angle in radians (Y axis)
  4447. * @param pitch defines the pitch angle in radians (X axis)
  4448. * @param roll defines the roll angle in radians (X axis)
  4449. * @param result defines the target matrix
  4450. */
  4451. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4452. /**
  4453. * Creates a scaling matrix
  4454. * @param x defines the scale factor on X axis
  4455. * @param y defines the scale factor on Y axis
  4456. * @param z defines the scale factor on Z axis
  4457. * @returns the new matrix
  4458. */
  4459. static Scaling(x: number, y: number, z: number): Matrix;
  4460. /**
  4461. * Creates a scaling matrix and stores it in a given matrix
  4462. * @param x defines the scale factor on X axis
  4463. * @param y defines the scale factor on Y axis
  4464. * @param z defines the scale factor on Z axis
  4465. * @param result defines the target matrix
  4466. */
  4467. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4468. /**
  4469. * Creates a translation matrix
  4470. * @param x defines the translation on X axis
  4471. * @param y defines the translation on Y axis
  4472. * @param z defines the translationon Z axis
  4473. * @returns the new matrix
  4474. */
  4475. static Translation(x: number, y: number, z: number): Matrix;
  4476. /**
  4477. * Creates a translation matrix and stores it in a given matrix
  4478. * @param x defines the translation on X axis
  4479. * @param y defines the translation on Y axis
  4480. * @param z defines the translationon Z axis
  4481. * @param result defines the target matrix
  4482. */
  4483. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4484. /**
  4485. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4486. * @param startValue defines the start value
  4487. * @param endValue defines the end value
  4488. * @param gradient defines the gradient factor
  4489. * @returns the new matrix
  4490. */
  4491. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4492. /**
  4493. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4494. * @param startValue defines the start value
  4495. * @param endValue defines the end value
  4496. * @param gradient defines the gradient factor
  4497. * @param result defines the Matrix object where to store data
  4498. */
  4499. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4500. /**
  4501. * Builds a new matrix whose values are computed by:
  4502. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4503. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4504. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4505. * @param startValue defines the first matrix
  4506. * @param endValue defines the second matrix
  4507. * @param gradient defines the gradient between the two matrices
  4508. * @returns the new matrix
  4509. */
  4510. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4511. /**
  4512. * Update a matrix to values which are computed by:
  4513. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4514. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4515. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4516. * @param startValue defines the first matrix
  4517. * @param endValue defines the second matrix
  4518. * @param gradient defines the gradient between the two matrices
  4519. * @param result defines the target matrix
  4520. */
  4521. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4522. /**
  4523. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4524. * This function works in left handed mode
  4525. * @param eye defines the final position of the entity
  4526. * @param target defines where the entity should look at
  4527. * @param up defines the up vector for the entity
  4528. * @returns the new matrix
  4529. */
  4530. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4531. /**
  4532. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4533. * This function works in left handed mode
  4534. * @param eye defines the final position of the entity
  4535. * @param target defines where the entity should look at
  4536. * @param up defines the up vector for the entity
  4537. * @param result defines the target matrix
  4538. */
  4539. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4540. /**
  4541. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4542. * This function works in right handed mode
  4543. * @param eye defines the final position of the entity
  4544. * @param target defines where the entity should look at
  4545. * @param up defines the up vector for the entity
  4546. * @returns the new matrix
  4547. */
  4548. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4549. /**
  4550. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4551. * This function works in right handed mode
  4552. * @param eye defines the final position of the entity
  4553. * @param target defines where the entity should look at
  4554. * @param up defines the up vector for the entity
  4555. * @param result defines the target matrix
  4556. */
  4557. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4558. /**
  4559. * Create a left-handed orthographic projection matrix
  4560. * @param width defines the viewport width
  4561. * @param height defines the viewport height
  4562. * @param znear defines the near clip plane
  4563. * @param zfar defines the far clip plane
  4564. * @returns a new matrix as a left-handed orthographic projection matrix
  4565. */
  4566. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4567. /**
  4568. * Store a left-handed orthographic projection to a given matrix
  4569. * @param width defines the viewport width
  4570. * @param height defines the viewport height
  4571. * @param znear defines the near clip plane
  4572. * @param zfar defines the far clip plane
  4573. * @param result defines the target matrix
  4574. */
  4575. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4576. /**
  4577. * Create a left-handed orthographic projection matrix
  4578. * @param left defines the viewport left coordinate
  4579. * @param right defines the viewport right coordinate
  4580. * @param bottom defines the viewport bottom coordinate
  4581. * @param top defines the viewport top coordinate
  4582. * @param znear defines the near clip plane
  4583. * @param zfar defines the far clip plane
  4584. * @returns a new matrix as a left-handed orthographic projection matrix
  4585. */
  4586. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4587. /**
  4588. * Stores a left-handed orthographic projection into a given matrix
  4589. * @param left defines the viewport left coordinate
  4590. * @param right defines the viewport right coordinate
  4591. * @param bottom defines the viewport bottom coordinate
  4592. * @param top defines the viewport top coordinate
  4593. * @param znear defines the near clip plane
  4594. * @param zfar defines the far clip plane
  4595. * @param result defines the target matrix
  4596. */
  4597. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4598. /**
  4599. * Creates a right-handed orthographic projection matrix
  4600. * @param left defines the viewport left coordinate
  4601. * @param right defines the viewport right coordinate
  4602. * @param bottom defines the viewport bottom coordinate
  4603. * @param top defines the viewport top coordinate
  4604. * @param znear defines the near clip plane
  4605. * @param zfar defines the far clip plane
  4606. * @returns a new matrix as a right-handed orthographic projection matrix
  4607. */
  4608. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4609. /**
  4610. * Stores a right-handed orthographic projection into a given matrix
  4611. * @param left defines the viewport left coordinate
  4612. * @param right defines the viewport right coordinate
  4613. * @param bottom defines the viewport bottom coordinate
  4614. * @param top defines the viewport top coordinate
  4615. * @param znear defines the near clip plane
  4616. * @param zfar defines the far clip plane
  4617. * @param result defines the target matrix
  4618. */
  4619. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4620. /**
  4621. * Creates a left-handed perspective projection matrix
  4622. * @param width defines the viewport width
  4623. * @param height defines the viewport height
  4624. * @param znear defines the near clip plane
  4625. * @param zfar defines the far clip plane
  4626. * @returns a new matrix as a left-handed perspective projection matrix
  4627. */
  4628. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4629. /**
  4630. * Creates a left-handed perspective projection matrix
  4631. * @param fov defines the horizontal field of view
  4632. * @param aspect defines the aspect ratio
  4633. * @param znear defines the near clip plane
  4634. * @param zfar defines the far clip plane
  4635. * @returns a new matrix as a left-handed perspective projection matrix
  4636. */
  4637. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4638. /**
  4639. * Stores a left-handed perspective projection into a given matrix
  4640. * @param fov defines the horizontal field of view
  4641. * @param aspect defines the aspect ratio
  4642. * @param znear defines the near clip plane
  4643. * @param zfar defines the far clip plane
  4644. * @param result defines the target matrix
  4645. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4646. */
  4647. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4648. /**
  4649. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4650. * @param fov defines the horizontal field of view
  4651. * @param aspect defines the aspect ratio
  4652. * @param znear defines the near clip plane
  4653. * @param zfar not used as infinity is used as far clip
  4654. * @param result defines the target matrix
  4655. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4656. */
  4657. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4658. /**
  4659. * Creates a right-handed perspective projection matrix
  4660. * @param fov defines the horizontal field of view
  4661. * @param aspect defines the aspect ratio
  4662. * @param znear defines the near clip plane
  4663. * @param zfar defines the far clip plane
  4664. * @returns a new matrix as a right-handed perspective projection matrix
  4665. */
  4666. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4667. /**
  4668. * Stores a right-handed perspective projection into a given matrix
  4669. * @param fov defines the horizontal field of view
  4670. * @param aspect defines the aspect ratio
  4671. * @param znear defines the near clip plane
  4672. * @param zfar defines the far clip plane
  4673. * @param result defines the target matrix
  4674. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4675. */
  4676. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4677. /**
  4678. * Stores a right-handed perspective projection into a given matrix
  4679. * @param fov defines the horizontal field of view
  4680. * @param aspect defines the aspect ratio
  4681. * @param znear defines the near clip plane
  4682. * @param zfar not used as infinity is used as far clip
  4683. * @param result defines the target matrix
  4684. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4685. */
  4686. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4687. /**
  4688. * Stores a perspective projection for WebVR info a given matrix
  4689. * @param fov defines the field of view
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4694. */
  4695. static PerspectiveFovWebVRToRef(fov: {
  4696. upDegrees: number;
  4697. downDegrees: number;
  4698. leftDegrees: number;
  4699. rightDegrees: number;
  4700. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4701. /**
  4702. * Computes a complete transformation matrix
  4703. * @param viewport defines the viewport to use
  4704. * @param world defines the world matrix
  4705. * @param view defines the view matrix
  4706. * @param projection defines the projection matrix
  4707. * @param zmin defines the near clip plane
  4708. * @param zmax defines the far clip plane
  4709. * @returns the transformation matrix
  4710. */
  4711. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4712. /**
  4713. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4714. * @param matrix defines the matrix to use
  4715. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4716. */
  4717. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4718. /**
  4719. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4720. * @param matrix defines the matrix to use
  4721. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4722. */
  4723. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4724. /**
  4725. * Compute the transpose of a given matrix
  4726. * @param matrix defines the matrix to transpose
  4727. * @returns the new matrix
  4728. */
  4729. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4730. /**
  4731. * Compute the transpose of a matrix and store it in a target matrix
  4732. * @param matrix defines the matrix to transpose
  4733. * @param result defines the target matrix
  4734. */
  4735. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4736. /**
  4737. * Computes a reflection matrix from a plane
  4738. * @param plane defines the reflection plane
  4739. * @returns a new matrix
  4740. */
  4741. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4742. /**
  4743. * Computes a reflection matrix from a plane
  4744. * @param plane defines the reflection plane
  4745. * @param result defines the target matrix
  4746. */
  4747. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4748. /**
  4749. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4750. * @param xaxis defines the value of the 1st axis
  4751. * @param yaxis defines the value of the 2nd axis
  4752. * @param zaxis defines the value of the 3rd axis
  4753. * @param result defines the target matrix
  4754. */
  4755. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4756. /**
  4757. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4758. * @param quat defines the quaternion to use
  4759. * @param result defines the target matrix
  4760. */
  4761. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4762. }
  4763. /**
  4764. * @hidden
  4765. */
  4766. export class TmpVectors {
  4767. static Vector2: Vector2[];
  4768. static Vector3: Vector3[];
  4769. static Vector4: Vector4[];
  4770. static Quaternion: Quaternion[];
  4771. static Matrix: Matrix[];
  4772. }
  4773. }
  4774. declare module BABYLON {
  4775. /**
  4776. * Defines potential orientation for back face culling
  4777. */
  4778. export enum Orientation {
  4779. /**
  4780. * Clockwise
  4781. */
  4782. CW = 0,
  4783. /** Counter clockwise */
  4784. CCW = 1
  4785. }
  4786. /** Class used to represent a Bezier curve */
  4787. export class BezierCurve {
  4788. /**
  4789. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4790. * @param t defines the time
  4791. * @param x1 defines the left coordinate on X axis
  4792. * @param y1 defines the left coordinate on Y axis
  4793. * @param x2 defines the right coordinate on X axis
  4794. * @param y2 defines the right coordinate on Y axis
  4795. * @returns the interpolated value
  4796. */
  4797. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4798. }
  4799. /**
  4800. * Defines angle representation
  4801. */
  4802. export class Angle {
  4803. private _radians;
  4804. /**
  4805. * Creates an Angle object of "radians" radians (float).
  4806. * @param radians the angle in radians
  4807. */
  4808. constructor(radians: number);
  4809. /**
  4810. * Get value in degrees
  4811. * @returns the Angle value in degrees (float)
  4812. */
  4813. degrees(): number;
  4814. /**
  4815. * Get value in radians
  4816. * @returns the Angle value in radians (float)
  4817. */
  4818. radians(): number;
  4819. /**
  4820. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4821. * @param a defines first vector
  4822. * @param b defines second vector
  4823. * @returns a new Angle
  4824. */
  4825. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4826. /**
  4827. * Gets a new Angle object from the given float in radians
  4828. * @param radians defines the angle value in radians
  4829. * @returns a new Angle
  4830. */
  4831. static FromRadians(radians: number): Angle;
  4832. /**
  4833. * Gets a new Angle object from the given float in degrees
  4834. * @param degrees defines the angle value in degrees
  4835. * @returns a new Angle
  4836. */
  4837. static FromDegrees(degrees: number): Angle;
  4838. }
  4839. /**
  4840. * This represents an arc in a 2d space.
  4841. */
  4842. export class Arc2 {
  4843. /** Defines the start point of the arc */
  4844. startPoint: Vector2;
  4845. /** Defines the mid point of the arc */
  4846. midPoint: Vector2;
  4847. /** Defines the end point of the arc */
  4848. endPoint: Vector2;
  4849. /**
  4850. * Defines the center point of the arc.
  4851. */
  4852. centerPoint: Vector2;
  4853. /**
  4854. * Defines the radius of the arc.
  4855. */
  4856. radius: number;
  4857. /**
  4858. * Defines the angle of the arc (from mid point to end point).
  4859. */
  4860. angle: Angle;
  4861. /**
  4862. * Defines the start angle of the arc (from start point to middle point).
  4863. */
  4864. startAngle: Angle;
  4865. /**
  4866. * Defines the orientation of the arc (clock wise/counter clock wise).
  4867. */
  4868. orientation: Orientation;
  4869. /**
  4870. * Creates an Arc object from the three given points : start, middle and end.
  4871. * @param startPoint Defines the start point of the arc
  4872. * @param midPoint Defines the midlle point of the arc
  4873. * @param endPoint Defines the end point of the arc
  4874. */
  4875. constructor(
  4876. /** Defines the start point of the arc */
  4877. startPoint: Vector2,
  4878. /** Defines the mid point of the arc */
  4879. midPoint: Vector2,
  4880. /** Defines the end point of the arc */
  4881. endPoint: Vector2);
  4882. }
  4883. /**
  4884. * Represents a 2D path made up of multiple 2D points
  4885. */
  4886. export class Path2 {
  4887. private _points;
  4888. private _length;
  4889. /**
  4890. * If the path start and end point are the same
  4891. */
  4892. closed: boolean;
  4893. /**
  4894. * Creates a Path2 object from the starting 2D coordinates x and y.
  4895. * @param x the starting points x value
  4896. * @param y the starting points y value
  4897. */
  4898. constructor(x: number, y: number);
  4899. /**
  4900. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4901. * @param x the added points x value
  4902. * @param y the added points y value
  4903. * @returns the updated Path2.
  4904. */
  4905. addLineTo(x: number, y: number): Path2;
  4906. /**
  4907. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4908. * @param midX middle point x value
  4909. * @param midY middle point y value
  4910. * @param endX end point x value
  4911. * @param endY end point y value
  4912. * @param numberOfSegments (default: 36)
  4913. * @returns the updated Path2.
  4914. */
  4915. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4916. /**
  4917. * Closes the Path2.
  4918. * @returns the Path2.
  4919. */
  4920. close(): Path2;
  4921. /**
  4922. * Gets the sum of the distance between each sequential point in the path
  4923. * @returns the Path2 total length (float).
  4924. */
  4925. length(): number;
  4926. /**
  4927. * Gets the points which construct the path
  4928. * @returns the Path2 internal array of points.
  4929. */
  4930. getPoints(): Vector2[];
  4931. /**
  4932. * Retreives the point at the distance aways from the starting point
  4933. * @param normalizedLengthPosition the length along the path to retreive the point from
  4934. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4935. */
  4936. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4937. /**
  4938. * Creates a new path starting from an x and y position
  4939. * @param x starting x value
  4940. * @param y starting y value
  4941. * @returns a new Path2 starting at the coordinates (x, y).
  4942. */
  4943. static StartingAt(x: number, y: number): Path2;
  4944. }
  4945. /**
  4946. * Represents a 3D path made up of multiple 3D points
  4947. */
  4948. export class Path3D {
  4949. /**
  4950. * an array of Vector3, the curve axis of the Path3D
  4951. */
  4952. path: Vector3[];
  4953. private _curve;
  4954. private _distances;
  4955. private _tangents;
  4956. private _normals;
  4957. private _binormals;
  4958. private _raw;
  4959. private _alignTangentsWithPath;
  4960. private readonly _pointAtData;
  4961. /**
  4962. * new Path3D(path, normal, raw)
  4963. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4964. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4965. * @param path an array of Vector3, the curve axis of the Path3D
  4966. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4967. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4968. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4969. */
  4970. constructor(
  4971. /**
  4972. * an array of Vector3, the curve axis of the Path3D
  4973. */
  4974. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4975. /**
  4976. * Returns the Path3D array of successive Vector3 designing its curve.
  4977. * @returns the Path3D array of successive Vector3 designing its curve.
  4978. */
  4979. getCurve(): Vector3[];
  4980. /**
  4981. * Returns the Path3D array of successive Vector3 designing its curve.
  4982. * @returns the Path3D array of successive Vector3 designing its curve.
  4983. */
  4984. getPoints(): Vector3[];
  4985. /**
  4986. * @returns the computed length (float) of the path.
  4987. */
  4988. length(): number;
  4989. /**
  4990. * Returns an array populated with tangent vectors on each Path3D curve point.
  4991. * @returns an array populated with tangent vectors on each Path3D curve point.
  4992. */
  4993. getTangents(): Vector3[];
  4994. /**
  4995. * Returns an array populated with normal vectors on each Path3D curve point.
  4996. * @returns an array populated with normal vectors on each Path3D curve point.
  4997. */
  4998. getNormals(): Vector3[];
  4999. /**
  5000. * Returns an array populated with binormal vectors on each Path3D curve point.
  5001. * @returns an array populated with binormal vectors on each Path3D curve point.
  5002. */
  5003. getBinormals(): Vector3[];
  5004. /**
  5005. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5006. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. */
  5008. getDistances(): number[];
  5009. /**
  5010. * Returns an interpolated point along this path
  5011. * @param position the position of the point along this path, from 0.0 to 1.0
  5012. * @returns a new Vector3 as the point
  5013. */
  5014. getPointAt(position: number): Vector3;
  5015. /**
  5016. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5017. * @param position the position of the point along this path, from 0.0 to 1.0
  5018. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5019. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5020. */
  5021. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5022. /**
  5023. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5024. * @param position the position of the point along this path, from 0.0 to 1.0
  5025. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5026. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5027. */
  5028. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5029. /**
  5030. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5031. * @param position the position of the point along this path, from 0.0 to 1.0
  5032. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5033. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5034. */
  5035. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5036. /**
  5037. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5038. * @param position the position of the point along this path, from 0.0 to 1.0
  5039. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5040. */
  5041. getDistanceAt(position: number): number;
  5042. /**
  5043. * Returns the array index of the previous point of an interpolated point along this path
  5044. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5045. * @returns the array index
  5046. */
  5047. getPreviousPointIndexAt(position: number): number;
  5048. /**
  5049. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5050. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5051. * @returns the sub position
  5052. */
  5053. getSubPositionAt(position: number): number;
  5054. /**
  5055. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5056. * @param target the vector of which to get the closest position to
  5057. * @returns the position of the closest virtual point on this path to the target vector
  5058. */
  5059. getClosestPositionTo(target: Vector3): number;
  5060. /**
  5061. * Returns a sub path (slice) of this path
  5062. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5063. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5064. * @returns a sub path (slice) of this path
  5065. */
  5066. slice(start?: number, end?: number): Path3D;
  5067. /**
  5068. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5069. * @param path path which all values are copied into the curves points
  5070. * @param firstNormal which should be projected onto the curve
  5071. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5072. * @returns the same object updated.
  5073. */
  5074. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5075. private _compute;
  5076. private _getFirstNonNullVector;
  5077. private _getLastNonNullVector;
  5078. private _normalVector;
  5079. /**
  5080. * Updates the point at data for an interpolated point along this curve
  5081. * @param position the position of the point along this curve, from 0.0 to 1.0
  5082. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5083. * @returns the (updated) point at data
  5084. */
  5085. private _updatePointAtData;
  5086. /**
  5087. * Updates the point at data from the specified parameters
  5088. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5089. * @param point the interpolated point
  5090. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5091. */
  5092. private _setPointAtData;
  5093. /**
  5094. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5095. */
  5096. private _updateInterpolationMatrix;
  5097. }
  5098. /**
  5099. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5100. * A Curve3 is designed from a series of successive Vector3.
  5101. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5102. */
  5103. export class Curve3 {
  5104. private _points;
  5105. private _length;
  5106. /**
  5107. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5108. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5109. * @param v1 (Vector3) the control point
  5110. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5111. * @param nbPoints (integer) the wanted number of points in the curve
  5112. * @returns the created Curve3
  5113. */
  5114. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5115. /**
  5116. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5117. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5118. * @param v1 (Vector3) the first control point
  5119. * @param v2 (Vector3) the second control point
  5120. * @param v3 (Vector3) the end point of the Cubic Bezier
  5121. * @param nbPoints (integer) the wanted number of points in the curve
  5122. * @returns the created Curve3
  5123. */
  5124. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5125. /**
  5126. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5127. * @param p1 (Vector3) the origin point of the Hermite Spline
  5128. * @param t1 (Vector3) the tangent vector at the origin point
  5129. * @param p2 (Vector3) the end point of the Hermite Spline
  5130. * @param t2 (Vector3) the tangent vector at the end point
  5131. * @param nbPoints (integer) the wanted number of points in the curve
  5132. * @returns the created Curve3
  5133. */
  5134. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5135. /**
  5136. * Returns a Curve3 object along a CatmullRom Spline curve :
  5137. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5138. * @param nbPoints (integer) the wanted number of points between each curve control points
  5139. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5140. * @returns the created Curve3
  5141. */
  5142. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5143. /**
  5144. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5145. * A Curve3 is designed from a series of successive Vector3.
  5146. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5147. * @param points points which make up the curve
  5148. */
  5149. constructor(points: Vector3[]);
  5150. /**
  5151. * @returns the Curve3 stored array of successive Vector3
  5152. */
  5153. getPoints(): Vector3[];
  5154. /**
  5155. * @returns the computed length (float) of the curve.
  5156. */
  5157. length(): number;
  5158. /**
  5159. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5160. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5161. * curveA and curveB keep unchanged.
  5162. * @param curve the curve to continue from this curve
  5163. * @returns the newly constructed curve
  5164. */
  5165. continue(curve: DeepImmutable<Curve3>): Curve3;
  5166. private _computeLength;
  5167. }
  5168. }
  5169. declare module BABYLON {
  5170. /**
  5171. * This represents the main contract an easing function should follow.
  5172. * Easing functions are used throughout the animation system.
  5173. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5174. */
  5175. export interface IEasingFunction {
  5176. /**
  5177. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5178. * of the easing function.
  5179. * The link below provides some of the most common examples of easing functions.
  5180. * @see https://easings.net/
  5181. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5182. * @returns the corresponding value on the curve defined by the easing function
  5183. */
  5184. ease(gradient: number): number;
  5185. }
  5186. /**
  5187. * Base class used for every default easing function.
  5188. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5189. */
  5190. export class EasingFunction implements IEasingFunction {
  5191. /**
  5192. * Interpolation follows the mathematical formula associated with the easing function.
  5193. */
  5194. static readonly EASINGMODE_EASEIN: number;
  5195. /**
  5196. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5197. */
  5198. static readonly EASINGMODE_EASEOUT: number;
  5199. /**
  5200. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5201. */
  5202. static readonly EASINGMODE_EASEINOUT: number;
  5203. private _easingMode;
  5204. /**
  5205. * Sets the easing mode of the current function.
  5206. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5207. */
  5208. setEasingMode(easingMode: number): void;
  5209. /**
  5210. * Gets the current easing mode.
  5211. * @returns the easing mode
  5212. */
  5213. getEasingMode(): number;
  5214. /**
  5215. * @hidden
  5216. */
  5217. easeInCore(gradient: number): number;
  5218. /**
  5219. * Given an input gradient between 0 and 1, this returns the corresponding value
  5220. * of the easing function.
  5221. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5222. * @returns the corresponding value on the curve defined by the easing function
  5223. */
  5224. ease(gradient: number): number;
  5225. }
  5226. /**
  5227. * Easing function with a circle shape (see link below).
  5228. * @see https://easings.net/#easeInCirc
  5229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5230. */
  5231. export class CircleEase extends EasingFunction implements IEasingFunction {
  5232. /** @hidden */
  5233. easeInCore(gradient: number): number;
  5234. }
  5235. /**
  5236. * Easing function with a ease back shape (see link below).
  5237. * @see https://easings.net/#easeInBack
  5238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5239. */
  5240. export class BackEase extends EasingFunction implements IEasingFunction {
  5241. /** Defines the amplitude of the function */
  5242. amplitude: number;
  5243. /**
  5244. * Instantiates a back ease easing
  5245. * @see https://easings.net/#easeInBack
  5246. * @param amplitude Defines the amplitude of the function
  5247. */
  5248. constructor(
  5249. /** Defines the amplitude of the function */
  5250. amplitude?: number);
  5251. /** @hidden */
  5252. easeInCore(gradient: number): number;
  5253. }
  5254. /**
  5255. * Easing function with a bouncing shape (see link below).
  5256. * @see https://easings.net/#easeInBounce
  5257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5258. */
  5259. export class BounceEase extends EasingFunction implements IEasingFunction {
  5260. /** Defines the number of bounces */
  5261. bounces: number;
  5262. /** Defines the amplitude of the bounce */
  5263. bounciness: number;
  5264. /**
  5265. * Instantiates a bounce easing
  5266. * @see https://easings.net/#easeInBounce
  5267. * @param bounces Defines the number of bounces
  5268. * @param bounciness Defines the amplitude of the bounce
  5269. */
  5270. constructor(
  5271. /** Defines the number of bounces */
  5272. bounces?: number,
  5273. /** Defines the amplitude of the bounce */
  5274. bounciness?: number);
  5275. /** @hidden */
  5276. easeInCore(gradient: number): number;
  5277. }
  5278. /**
  5279. * Easing function with a power of 3 shape (see link below).
  5280. * @see https://easings.net/#easeInCubic
  5281. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5282. */
  5283. export class CubicEase extends EasingFunction implements IEasingFunction {
  5284. /** @hidden */
  5285. easeInCore(gradient: number): number;
  5286. }
  5287. /**
  5288. * Easing function with an elastic shape (see link below).
  5289. * @see https://easings.net/#easeInElastic
  5290. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5291. */
  5292. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5293. /** Defines the number of oscillations*/
  5294. oscillations: number;
  5295. /** Defines the amplitude of the oscillations*/
  5296. springiness: number;
  5297. /**
  5298. * Instantiates an elastic easing function
  5299. * @see https://easings.net/#easeInElastic
  5300. * @param oscillations Defines the number of oscillations
  5301. * @param springiness Defines the amplitude of the oscillations
  5302. */
  5303. constructor(
  5304. /** Defines the number of oscillations*/
  5305. oscillations?: number,
  5306. /** Defines the amplitude of the oscillations*/
  5307. springiness?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with an exponential shape (see link below).
  5313. * @see https://easings.net/#easeInExpo
  5314. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the exponent of the function */
  5318. exponent: number;
  5319. /**
  5320. * Instantiates an exponential easing function
  5321. * @see https://easings.net/#easeInExpo
  5322. * @param exponent Defines the exponent of the function
  5323. */
  5324. constructor(
  5325. /** Defines the exponent of the function */
  5326. exponent?: number);
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a power shape (see link below).
  5332. * @see https://easings.net/#easeInQuad
  5333. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class PowerEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the power of the function */
  5337. power: number;
  5338. /**
  5339. * Instantiates an power base easing function
  5340. * @see https://easings.net/#easeInQuad
  5341. * @param power Defines the power of the function
  5342. */
  5343. constructor(
  5344. /** Defines the power of the function */
  5345. power?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a power of 2 shape (see link below).
  5351. * @see https://easings.net/#easeInQuad
  5352. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5355. /** @hidden */
  5356. easeInCore(gradient: number): number;
  5357. }
  5358. /**
  5359. * Easing function with a power of 4 shape (see link below).
  5360. * @see https://easings.net/#easeInQuart
  5361. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5362. */
  5363. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5364. /** @hidden */
  5365. easeInCore(gradient: number): number;
  5366. }
  5367. /**
  5368. * Easing function with a power of 5 shape (see link below).
  5369. * @see https://easings.net/#easeInQuint
  5370. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5371. */
  5372. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5373. /** @hidden */
  5374. easeInCore(gradient: number): number;
  5375. }
  5376. /**
  5377. * Easing function with a sin shape (see link below).
  5378. * @see https://easings.net/#easeInSine
  5379. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5380. */
  5381. export class SineEase extends EasingFunction implements IEasingFunction {
  5382. /** @hidden */
  5383. easeInCore(gradient: number): number;
  5384. }
  5385. /**
  5386. * Easing function with a bezier shape (see link below).
  5387. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5388. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5389. */
  5390. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5391. /** Defines the x component of the start tangent in the bezier curve */
  5392. x1: number;
  5393. /** Defines the y component of the start tangent in the bezier curve */
  5394. y1: number;
  5395. /** Defines the x component of the end tangent in the bezier curve */
  5396. x2: number;
  5397. /** Defines the y component of the end tangent in the bezier curve */
  5398. y2: number;
  5399. /**
  5400. * Instantiates a bezier function
  5401. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5402. * @param x1 Defines the x component of the start tangent in the bezier curve
  5403. * @param y1 Defines the y component of the start tangent in the bezier curve
  5404. * @param x2 Defines the x component of the end tangent in the bezier curve
  5405. * @param y2 Defines the y component of the end tangent in the bezier curve
  5406. */
  5407. constructor(
  5408. /** Defines the x component of the start tangent in the bezier curve */
  5409. x1?: number,
  5410. /** Defines the y component of the start tangent in the bezier curve */
  5411. y1?: number,
  5412. /** Defines the x component of the end tangent in the bezier curve */
  5413. x2?: number,
  5414. /** Defines the y component of the end tangent in the bezier curve */
  5415. y2?: number);
  5416. /** @hidden */
  5417. easeInCore(gradient: number): number;
  5418. }
  5419. }
  5420. declare module BABYLON {
  5421. /**
  5422. * Class used to hold a RBG color
  5423. */
  5424. export class Color3 {
  5425. /**
  5426. * Defines the red component (between 0 and 1, default is 0)
  5427. */
  5428. r: number;
  5429. /**
  5430. * Defines the green component (between 0 and 1, default is 0)
  5431. */
  5432. g: number;
  5433. /**
  5434. * Defines the blue component (between 0 and 1, default is 0)
  5435. */
  5436. b: number;
  5437. /**
  5438. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5439. * @param r defines the red component (between 0 and 1, default is 0)
  5440. * @param g defines the green component (between 0 and 1, default is 0)
  5441. * @param b defines the blue component (between 0 and 1, default is 0)
  5442. */
  5443. constructor(
  5444. /**
  5445. * Defines the red component (between 0 and 1, default is 0)
  5446. */
  5447. r?: number,
  5448. /**
  5449. * Defines the green component (between 0 and 1, default is 0)
  5450. */
  5451. g?: number,
  5452. /**
  5453. * Defines the blue component (between 0 and 1, default is 0)
  5454. */
  5455. b?: number);
  5456. /**
  5457. * Creates a string with the Color3 current values
  5458. * @returns the string representation of the Color3 object
  5459. */
  5460. toString(): string;
  5461. /**
  5462. * Returns the string "Color3"
  5463. * @returns "Color3"
  5464. */
  5465. getClassName(): string;
  5466. /**
  5467. * Compute the Color3 hash code
  5468. * @returns an unique number that can be used to hash Color3 objects
  5469. */
  5470. getHashCode(): number;
  5471. /**
  5472. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5473. * @param array defines the array where to store the r,g,b components
  5474. * @param index defines an optional index in the target array to define where to start storing values
  5475. * @returns the current Color3 object
  5476. */
  5477. toArray(array: FloatArray, index?: number): Color3;
  5478. /**
  5479. * Returns a new Color4 object from the current Color3 and the given alpha
  5480. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5481. * @returns a new Color4 object
  5482. */
  5483. toColor4(alpha?: number): Color4;
  5484. /**
  5485. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5486. * @returns the new array
  5487. */
  5488. asArray(): number[];
  5489. /**
  5490. * Returns the luminance value
  5491. * @returns a float value
  5492. */
  5493. toLuminance(): number;
  5494. /**
  5495. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5496. * @param otherColor defines the second operand
  5497. * @returns the new Color3 object
  5498. */
  5499. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5500. /**
  5501. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5502. * @param otherColor defines the second operand
  5503. * @param result defines the Color3 object where to store the result
  5504. * @returns the current Color3
  5505. */
  5506. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5507. /**
  5508. * Determines equality between Color3 objects
  5509. * @param otherColor defines the second operand
  5510. * @returns true if the rgb values are equal to the given ones
  5511. */
  5512. equals(otherColor: DeepImmutable<Color3>): boolean;
  5513. /**
  5514. * Determines equality between the current Color3 object and a set of r,b,g values
  5515. * @param r defines the red component to check
  5516. * @param g defines the green component to check
  5517. * @param b defines the blue component to check
  5518. * @returns true if the rgb values are equal to the given ones
  5519. */
  5520. equalsFloats(r: number, g: number, b: number): boolean;
  5521. /**
  5522. * Multiplies in place each rgb value by scale
  5523. * @param scale defines the scaling factor
  5524. * @returns the updated Color3
  5525. */
  5526. scale(scale: number): Color3;
  5527. /**
  5528. * Multiplies the rgb values by scale and stores the result into "result"
  5529. * @param scale defines the scaling factor
  5530. * @param result defines the Color3 object where to store the result
  5531. * @returns the unmodified current Color3
  5532. */
  5533. scaleToRef(scale: number, result: Color3): Color3;
  5534. /**
  5535. * Scale the current Color3 values by a factor and add the result to a given Color3
  5536. * @param scale defines the scale factor
  5537. * @param result defines color to store the result into
  5538. * @returns the unmodified current Color3
  5539. */
  5540. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5541. /**
  5542. * Clamps the rgb values by the min and max values and stores the result into "result"
  5543. * @param min defines minimum clamping value (default is 0)
  5544. * @param max defines maximum clamping value (default is 1)
  5545. * @param result defines color to store the result into
  5546. * @returns the original Color3
  5547. */
  5548. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5549. /**
  5550. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5551. * @param otherColor defines the second operand
  5552. * @returns the new Color3
  5553. */
  5554. add(otherColor: DeepImmutable<Color3>): Color3;
  5555. /**
  5556. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5557. * @param otherColor defines the second operand
  5558. * @param result defines Color3 object to store the result into
  5559. * @returns the unmodified current Color3
  5560. */
  5561. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5562. /**
  5563. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5564. * @param otherColor defines the second operand
  5565. * @returns the new Color3
  5566. */
  5567. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5568. /**
  5569. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5570. * @param otherColor defines the second operand
  5571. * @param result defines Color3 object to store the result into
  5572. * @returns the unmodified current Color3
  5573. */
  5574. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5575. /**
  5576. * Copy the current object
  5577. * @returns a new Color3 copied the current one
  5578. */
  5579. clone(): Color3;
  5580. /**
  5581. * Copies the rgb values from the source in the current Color3
  5582. * @param source defines the source Color3 object
  5583. * @returns the updated Color3 object
  5584. */
  5585. copyFrom(source: DeepImmutable<Color3>): Color3;
  5586. /**
  5587. * Updates the Color3 rgb values from the given floats
  5588. * @param r defines the red component to read from
  5589. * @param g defines the green component to read from
  5590. * @param b defines the blue component to read from
  5591. * @returns the current Color3 object
  5592. */
  5593. copyFromFloats(r: number, g: number, b: number): Color3;
  5594. /**
  5595. * Updates the Color3 rgb values from the given floats
  5596. * @param r defines the red component to read from
  5597. * @param g defines the green component to read from
  5598. * @param b defines the blue component to read from
  5599. * @returns the current Color3 object
  5600. */
  5601. set(r: number, g: number, b: number): Color3;
  5602. /**
  5603. * Compute the Color3 hexadecimal code as a string
  5604. * @returns a string containing the hexadecimal representation of the Color3 object
  5605. */
  5606. toHexString(): string;
  5607. /**
  5608. * Computes a new Color3 converted from the current one to linear space
  5609. * @returns a new Color3 object
  5610. */
  5611. toLinearSpace(): Color3;
  5612. /**
  5613. * Converts current color in rgb space to HSV values
  5614. * @returns a new color3 representing the HSV values
  5615. */
  5616. toHSV(): Color3;
  5617. /**
  5618. * Converts current color in rgb space to HSV values
  5619. * @param result defines the Color3 where to store the HSV values
  5620. */
  5621. toHSVToRef(result: Color3): void;
  5622. /**
  5623. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5624. * @param convertedColor defines the Color3 object where to store the linear space version
  5625. * @returns the unmodified Color3
  5626. */
  5627. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5628. /**
  5629. * Computes a new Color3 converted from the current one to gamma space
  5630. * @returns a new Color3 object
  5631. */
  5632. toGammaSpace(): Color3;
  5633. /**
  5634. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5635. * @param convertedColor defines the Color3 object where to store the gamma space version
  5636. * @returns the unmodified Color3
  5637. */
  5638. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5639. private static _BlackReadOnly;
  5640. /**
  5641. * Convert Hue, saturation and value to a Color3 (RGB)
  5642. * @param hue defines the hue
  5643. * @param saturation defines the saturation
  5644. * @param value defines the value
  5645. * @param result defines the Color3 where to store the RGB values
  5646. */
  5647. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5648. /**
  5649. * Creates a new Color3 from the string containing valid hexadecimal values
  5650. * @param hex defines a string containing valid hexadecimal values
  5651. * @returns a new Color3 object
  5652. */
  5653. static FromHexString(hex: string): Color3;
  5654. /**
  5655. * Creates a new Color3 from the starting index of the given array
  5656. * @param array defines the source array
  5657. * @param offset defines an offset in the source array
  5658. * @returns a new Color3 object
  5659. */
  5660. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5661. /**
  5662. * Creates a new Color3 from integer values (< 256)
  5663. * @param r defines the red component to read from (value between 0 and 255)
  5664. * @param g defines the green component to read from (value between 0 and 255)
  5665. * @param b defines the blue component to read from (value between 0 and 255)
  5666. * @returns a new Color3 object
  5667. */
  5668. static FromInts(r: number, g: number, b: number): Color3;
  5669. /**
  5670. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5671. * @param start defines the start Color3 value
  5672. * @param end defines the end Color3 value
  5673. * @param amount defines the gradient value between start and end
  5674. * @returns a new Color3 object
  5675. */
  5676. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5677. /**
  5678. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5679. * @param left defines the start value
  5680. * @param right defines the end value
  5681. * @param amount defines the gradient factor
  5682. * @param result defines the Color3 object where to store the result
  5683. */
  5684. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5685. /**
  5686. * Returns a Color3 value containing a red color
  5687. * @returns a new Color3 object
  5688. */
  5689. static Red(): Color3;
  5690. /**
  5691. * Returns a Color3 value containing a green color
  5692. * @returns a new Color3 object
  5693. */
  5694. static Green(): Color3;
  5695. /**
  5696. * Returns a Color3 value containing a blue color
  5697. * @returns a new Color3 object
  5698. */
  5699. static Blue(): Color3;
  5700. /**
  5701. * Returns a Color3 value containing a black color
  5702. * @returns a new Color3 object
  5703. */
  5704. static Black(): Color3;
  5705. /**
  5706. * Gets a Color3 value containing a black color that must not be updated
  5707. */
  5708. static get BlackReadOnly(): DeepImmutable<Color3>;
  5709. /**
  5710. * Returns a Color3 value containing a white color
  5711. * @returns a new Color3 object
  5712. */
  5713. static White(): Color3;
  5714. /**
  5715. * Returns a Color3 value containing a purple color
  5716. * @returns a new Color3 object
  5717. */
  5718. static Purple(): Color3;
  5719. /**
  5720. * Returns a Color3 value containing a magenta color
  5721. * @returns a new Color3 object
  5722. */
  5723. static Magenta(): Color3;
  5724. /**
  5725. * Returns a Color3 value containing a yellow color
  5726. * @returns a new Color3 object
  5727. */
  5728. static Yellow(): Color3;
  5729. /**
  5730. * Returns a Color3 value containing a gray color
  5731. * @returns a new Color3 object
  5732. */
  5733. static Gray(): Color3;
  5734. /**
  5735. * Returns a Color3 value containing a teal color
  5736. * @returns a new Color3 object
  5737. */
  5738. static Teal(): Color3;
  5739. /**
  5740. * Returns a Color3 value containing a random color
  5741. * @returns a new Color3 object
  5742. */
  5743. static Random(): Color3;
  5744. }
  5745. /**
  5746. * Class used to hold a RBGA color
  5747. */
  5748. export class Color4 {
  5749. /**
  5750. * Defines the red component (between 0 and 1, default is 0)
  5751. */
  5752. r: number;
  5753. /**
  5754. * Defines the green component (between 0 and 1, default is 0)
  5755. */
  5756. g: number;
  5757. /**
  5758. * Defines the blue component (between 0 and 1, default is 0)
  5759. */
  5760. b: number;
  5761. /**
  5762. * Defines the alpha component (between 0 and 1, default is 1)
  5763. */
  5764. a: number;
  5765. /**
  5766. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5767. * @param r defines the red component (between 0 and 1, default is 0)
  5768. * @param g defines the green component (between 0 and 1, default is 0)
  5769. * @param b defines the blue component (between 0 and 1, default is 0)
  5770. * @param a defines the alpha component (between 0 and 1, default is 1)
  5771. */
  5772. constructor(
  5773. /**
  5774. * Defines the red component (between 0 and 1, default is 0)
  5775. */
  5776. r?: number,
  5777. /**
  5778. * Defines the green component (between 0 and 1, default is 0)
  5779. */
  5780. g?: number,
  5781. /**
  5782. * Defines the blue component (between 0 and 1, default is 0)
  5783. */
  5784. b?: number,
  5785. /**
  5786. * Defines the alpha component (between 0 and 1, default is 1)
  5787. */
  5788. a?: number);
  5789. /**
  5790. * Adds in place the given Color4 values to the current Color4 object
  5791. * @param right defines the second operand
  5792. * @returns the current updated Color4 object
  5793. */
  5794. addInPlace(right: DeepImmutable<Color4>): Color4;
  5795. /**
  5796. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5797. * @returns the new array
  5798. */
  5799. asArray(): number[];
  5800. /**
  5801. * Stores from the starting index in the given array the Color4 successive values
  5802. * @param array defines the array where to store the r,g,b components
  5803. * @param index defines an optional index in the target array to define where to start storing values
  5804. * @returns the current Color4 object
  5805. */
  5806. toArray(array: number[], index?: number): Color4;
  5807. /**
  5808. * Determines equality between Color4 objects
  5809. * @param otherColor defines the second operand
  5810. * @returns true if the rgba values are equal to the given ones
  5811. */
  5812. equals(otherColor: DeepImmutable<Color4>): boolean;
  5813. /**
  5814. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5815. * @param right defines the second operand
  5816. * @returns a new Color4 object
  5817. */
  5818. add(right: DeepImmutable<Color4>): Color4;
  5819. /**
  5820. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5821. * @param right defines the second operand
  5822. * @returns a new Color4 object
  5823. */
  5824. subtract(right: DeepImmutable<Color4>): Color4;
  5825. /**
  5826. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5827. * @param right defines the second operand
  5828. * @param result defines the Color4 object where to store the result
  5829. * @returns the current Color4 object
  5830. */
  5831. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5832. /**
  5833. * Creates a new Color4 with the current Color4 values multiplied by scale
  5834. * @param scale defines the scaling factor to apply
  5835. * @returns a new Color4 object
  5836. */
  5837. scale(scale: number): Color4;
  5838. /**
  5839. * Multiplies the current Color4 values by scale and stores the result in "result"
  5840. * @param scale defines the scaling factor to apply
  5841. * @param result defines the Color4 object where to store the result
  5842. * @returns the current unmodified Color4
  5843. */
  5844. scaleToRef(scale: number, result: Color4): Color4;
  5845. /**
  5846. * Scale the current Color4 values by a factor and add the result to a given Color4
  5847. * @param scale defines the scale factor
  5848. * @param result defines the Color4 object where to store the result
  5849. * @returns the unmodified current Color4
  5850. */
  5851. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5852. /**
  5853. * Clamps the rgb values by the min and max values and stores the result into "result"
  5854. * @param min defines minimum clamping value (default is 0)
  5855. * @param max defines maximum clamping value (default is 1)
  5856. * @param result defines color to store the result into.
  5857. * @returns the cuurent Color4
  5858. */
  5859. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5860. /**
  5861. * Multipy an Color4 value by another and return a new Color4 object
  5862. * @param color defines the Color4 value to multiply by
  5863. * @returns a new Color4 object
  5864. */
  5865. multiply(color: Color4): Color4;
  5866. /**
  5867. * Multipy a Color4 value by another and push the result in a reference value
  5868. * @param color defines the Color4 value to multiply by
  5869. * @param result defines the Color4 to fill the result in
  5870. * @returns the result Color4
  5871. */
  5872. multiplyToRef(color: Color4, result: Color4): Color4;
  5873. /**
  5874. * Creates a string with the Color4 current values
  5875. * @returns the string representation of the Color4 object
  5876. */
  5877. toString(): string;
  5878. /**
  5879. * Returns the string "Color4"
  5880. * @returns "Color4"
  5881. */
  5882. getClassName(): string;
  5883. /**
  5884. * Compute the Color4 hash code
  5885. * @returns an unique number that can be used to hash Color4 objects
  5886. */
  5887. getHashCode(): number;
  5888. /**
  5889. * Creates a new Color4 copied from the current one
  5890. * @returns a new Color4 object
  5891. */
  5892. clone(): Color4;
  5893. /**
  5894. * Copies the given Color4 values into the current one
  5895. * @param source defines the source Color4 object
  5896. * @returns the current updated Color4 object
  5897. */
  5898. copyFrom(source: Color4): Color4;
  5899. /**
  5900. * Copies the given float values into the current one
  5901. * @param r defines the red component to read from
  5902. * @param g defines the green component to read from
  5903. * @param b defines the blue component to read from
  5904. * @param a defines the alpha component to read from
  5905. * @returns the current updated Color4 object
  5906. */
  5907. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5908. /**
  5909. * Copies the given float values into the current one
  5910. * @param r defines the red component to read from
  5911. * @param g defines the green component to read from
  5912. * @param b defines the blue component to read from
  5913. * @param a defines the alpha component to read from
  5914. * @returns the current updated Color4 object
  5915. */
  5916. set(r: number, g: number, b: number, a: number): Color4;
  5917. /**
  5918. * Compute the Color4 hexadecimal code as a string
  5919. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5920. * @returns a string containing the hexadecimal representation of the Color4 object
  5921. */
  5922. toHexString(returnAsColor3?: boolean): string;
  5923. /**
  5924. * Computes a new Color4 converted from the current one to linear space
  5925. * @returns a new Color4 object
  5926. */
  5927. toLinearSpace(): Color4;
  5928. /**
  5929. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5930. * @param convertedColor defines the Color4 object where to store the linear space version
  5931. * @returns the unmodified Color4
  5932. */
  5933. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5934. /**
  5935. * Computes a new Color4 converted from the current one to gamma space
  5936. * @returns a new Color4 object
  5937. */
  5938. toGammaSpace(): Color4;
  5939. /**
  5940. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5941. * @param convertedColor defines the Color4 object where to store the gamma space version
  5942. * @returns the unmodified Color4
  5943. */
  5944. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5945. /**
  5946. * Creates a new Color4 from the string containing valid hexadecimal values
  5947. * @param hex defines a string containing valid hexadecimal values
  5948. * @returns a new Color4 object
  5949. */
  5950. static FromHexString(hex: string): Color4;
  5951. /**
  5952. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5953. * @param left defines the start value
  5954. * @param right defines the end value
  5955. * @param amount defines the gradient factor
  5956. * @returns a new Color4 object
  5957. */
  5958. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5959. /**
  5960. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5961. * @param left defines the start value
  5962. * @param right defines the end value
  5963. * @param amount defines the gradient factor
  5964. * @param result defines the Color4 object where to store data
  5965. */
  5966. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5967. /**
  5968. * Creates a new Color4 from a Color3 and an alpha value
  5969. * @param color3 defines the source Color3 to read from
  5970. * @param alpha defines the alpha component (1.0 by default)
  5971. * @returns a new Color4 object
  5972. */
  5973. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5974. /**
  5975. * Creates a new Color4 from the starting index element of the given array
  5976. * @param array defines the source array to read from
  5977. * @param offset defines the offset in the source array
  5978. * @returns a new Color4 object
  5979. */
  5980. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5981. /**
  5982. * Creates a new Color3 from integer values (< 256)
  5983. * @param r defines the red component to read from (value between 0 and 255)
  5984. * @param g defines the green component to read from (value between 0 and 255)
  5985. * @param b defines the blue component to read from (value between 0 and 255)
  5986. * @param a defines the alpha component to read from (value between 0 and 255)
  5987. * @returns a new Color3 object
  5988. */
  5989. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5990. /**
  5991. * Check the content of a given array and convert it to an array containing RGBA data
  5992. * If the original array was already containing count * 4 values then it is returned directly
  5993. * @param colors defines the array to check
  5994. * @param count defines the number of RGBA data to expect
  5995. * @returns an array containing count * 4 values (RGBA)
  5996. */
  5997. static CheckColors4(colors: number[], count: number): number[];
  5998. }
  5999. /**
  6000. * @hidden
  6001. */
  6002. export class TmpColors {
  6003. static Color3: Color3[];
  6004. static Color4: Color4[];
  6005. }
  6006. }
  6007. declare module BABYLON {
  6008. /**
  6009. * Defines an interface which represents an animation key frame
  6010. */
  6011. export interface IAnimationKey {
  6012. /**
  6013. * Frame of the key frame
  6014. */
  6015. frame: number;
  6016. /**
  6017. * Value at the specifies key frame
  6018. */
  6019. value: any;
  6020. /**
  6021. * The input tangent for the cubic hermite spline
  6022. */
  6023. inTangent?: any;
  6024. /**
  6025. * The output tangent for the cubic hermite spline
  6026. */
  6027. outTangent?: any;
  6028. /**
  6029. * The animation interpolation type
  6030. */
  6031. interpolation?: AnimationKeyInterpolation;
  6032. }
  6033. /**
  6034. * Enum for the animation key frame interpolation type
  6035. */
  6036. export enum AnimationKeyInterpolation {
  6037. /**
  6038. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6039. */
  6040. STEP = 1
  6041. }
  6042. }
  6043. declare module BABYLON {
  6044. /**
  6045. * Represents the range of an animation
  6046. */
  6047. export class AnimationRange {
  6048. /**The name of the animation range**/
  6049. name: string;
  6050. /**The starting frame of the animation */
  6051. from: number;
  6052. /**The ending frame of the animation*/
  6053. to: number;
  6054. /**
  6055. * Initializes the range of an animation
  6056. * @param name The name of the animation range
  6057. * @param from The starting frame of the animation
  6058. * @param to The ending frame of the animation
  6059. */
  6060. constructor(
  6061. /**The name of the animation range**/
  6062. name: string,
  6063. /**The starting frame of the animation */
  6064. from: number,
  6065. /**The ending frame of the animation*/
  6066. to: number);
  6067. /**
  6068. * Makes a copy of the animation range
  6069. * @returns A copy of the animation range
  6070. */
  6071. clone(): AnimationRange;
  6072. }
  6073. }
  6074. declare module BABYLON {
  6075. /**
  6076. * Composed of a frame, and an action function
  6077. */
  6078. export class AnimationEvent {
  6079. /** The frame for which the event is triggered **/
  6080. frame: number;
  6081. /** The event to perform when triggered **/
  6082. action: (currentFrame: number) => void;
  6083. /** Specifies if the event should be triggered only once**/
  6084. onlyOnce?: boolean | undefined;
  6085. /**
  6086. * Specifies if the animation event is done
  6087. */
  6088. isDone: boolean;
  6089. /**
  6090. * Initializes the animation event
  6091. * @param frame The frame for which the event is triggered
  6092. * @param action The event to perform when triggered
  6093. * @param onlyOnce Specifies if the event should be triggered only once
  6094. */
  6095. constructor(
  6096. /** The frame for which the event is triggered **/
  6097. frame: number,
  6098. /** The event to perform when triggered **/
  6099. action: (currentFrame: number) => void,
  6100. /** Specifies if the event should be triggered only once**/
  6101. onlyOnce?: boolean | undefined);
  6102. /** @hidden */
  6103. _clone(): AnimationEvent;
  6104. }
  6105. }
  6106. declare module BABYLON {
  6107. /**
  6108. * Interface used to define a behavior
  6109. */
  6110. export interface Behavior<T> {
  6111. /** gets or sets behavior's name */
  6112. name: string;
  6113. /**
  6114. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6115. */
  6116. init(): void;
  6117. /**
  6118. * Called when the behavior is attached to a target
  6119. * @param target defines the target where the behavior is attached to
  6120. */
  6121. attach(target: T): void;
  6122. /**
  6123. * Called when the behavior is detached from its target
  6124. */
  6125. detach(): void;
  6126. }
  6127. /**
  6128. * Interface implemented by classes supporting behaviors
  6129. */
  6130. export interface IBehaviorAware<T> {
  6131. /**
  6132. * Attach a behavior
  6133. * @param behavior defines the behavior to attach
  6134. * @returns the current host
  6135. */
  6136. addBehavior(behavior: Behavior<T>): T;
  6137. /**
  6138. * Remove a behavior from the current object
  6139. * @param behavior defines the behavior to detach
  6140. * @returns the current host
  6141. */
  6142. removeBehavior(behavior: Behavior<T>): T;
  6143. /**
  6144. * Gets a behavior using its name to search
  6145. * @param name defines the name to search
  6146. * @returns the behavior or null if not found
  6147. */
  6148. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6149. }
  6150. }
  6151. declare module BABYLON {
  6152. /**
  6153. * Defines an array and its length.
  6154. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6155. */
  6156. export interface ISmartArrayLike<T> {
  6157. /**
  6158. * The data of the array.
  6159. */
  6160. data: Array<T>;
  6161. /**
  6162. * The active length of the array.
  6163. */
  6164. length: number;
  6165. }
  6166. /**
  6167. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6168. */
  6169. export class SmartArray<T> implements ISmartArrayLike<T> {
  6170. /**
  6171. * The full set of data from the array.
  6172. */
  6173. data: Array<T>;
  6174. /**
  6175. * The active length of the array.
  6176. */
  6177. length: number;
  6178. protected _id: number;
  6179. /**
  6180. * Instantiates a Smart Array.
  6181. * @param capacity defines the default capacity of the array.
  6182. */
  6183. constructor(capacity: number);
  6184. /**
  6185. * Pushes a value at the end of the active data.
  6186. * @param value defines the object to push in the array.
  6187. */
  6188. push(value: T): void;
  6189. /**
  6190. * Iterates over the active data and apply the lambda to them.
  6191. * @param func defines the action to apply on each value.
  6192. */
  6193. forEach(func: (content: T) => void): void;
  6194. /**
  6195. * Sorts the full sets of data.
  6196. * @param compareFn defines the comparison function to apply.
  6197. */
  6198. sort(compareFn: (a: T, b: T) => number): void;
  6199. /**
  6200. * Resets the active data to an empty array.
  6201. */
  6202. reset(): void;
  6203. /**
  6204. * Releases all the data from the array as well as the array.
  6205. */
  6206. dispose(): void;
  6207. /**
  6208. * Concats the active data with a given array.
  6209. * @param array defines the data to concatenate with.
  6210. */
  6211. concat(array: any): void;
  6212. /**
  6213. * Returns the position of a value in the active data.
  6214. * @param value defines the value to find the index for
  6215. * @returns the index if found in the active data otherwise -1
  6216. */
  6217. indexOf(value: T): number;
  6218. /**
  6219. * Returns whether an element is part of the active data.
  6220. * @param value defines the value to look for
  6221. * @returns true if found in the active data otherwise false
  6222. */
  6223. contains(value: T): boolean;
  6224. private static _GlobalId;
  6225. }
  6226. /**
  6227. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6228. * The data in this array can only be present once
  6229. */
  6230. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6231. private _duplicateId;
  6232. /**
  6233. * Pushes a value at the end of the active data.
  6234. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6235. * @param value defines the object to push in the array.
  6236. */
  6237. push(value: T): void;
  6238. /**
  6239. * Pushes a value at the end of the active data.
  6240. * If the data is already present, it won t be added again
  6241. * @param value defines the object to push in the array.
  6242. * @returns true if added false if it was already present
  6243. */
  6244. pushNoDuplicate(value: T): boolean;
  6245. /**
  6246. * Resets the active data to an empty array.
  6247. */
  6248. reset(): void;
  6249. /**
  6250. * Concats the active data with a given array.
  6251. * This ensures no dupplicate will be present in the result.
  6252. * @param array defines the data to concatenate with.
  6253. */
  6254. concatWithNoDuplicate(array: any): void;
  6255. }
  6256. }
  6257. declare module BABYLON {
  6258. /**
  6259. * @ignore
  6260. * This is a list of all the different input types that are available in the application.
  6261. * Fo instance: ArcRotateCameraGamepadInput...
  6262. */
  6263. export var CameraInputTypes: {};
  6264. /**
  6265. * This is the contract to implement in order to create a new input class.
  6266. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6267. */
  6268. export interface ICameraInput<TCamera extends Camera> {
  6269. /**
  6270. * Defines the camera the input is attached to.
  6271. */
  6272. camera: Nullable<TCamera>;
  6273. /**
  6274. * Gets the class name of the current intput.
  6275. * @returns the class name
  6276. */
  6277. getClassName(): string;
  6278. /**
  6279. * Get the friendly name associated with the input class.
  6280. * @returns the input friendly name
  6281. */
  6282. getSimpleName(): string;
  6283. /**
  6284. * Attach the input controls to a specific dom element to get the input from.
  6285. * @param element Defines the element the controls should be listened from
  6286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6287. */
  6288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6289. /**
  6290. * Detach the current controls from the specified dom element.
  6291. * @param element Defines the element to stop listening the inputs from
  6292. */
  6293. detachControl(element: Nullable<HTMLElement>): void;
  6294. /**
  6295. * Update the current camera state depending on the inputs that have been used this frame.
  6296. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6297. */
  6298. checkInputs?: () => void;
  6299. }
  6300. /**
  6301. * Represents a map of input types to input instance or input index to input instance.
  6302. */
  6303. export interface CameraInputsMap<TCamera extends Camera> {
  6304. /**
  6305. * Accessor to the input by input type.
  6306. */
  6307. [name: string]: ICameraInput<TCamera>;
  6308. /**
  6309. * Accessor to the input by input index.
  6310. */
  6311. [idx: number]: ICameraInput<TCamera>;
  6312. }
  6313. /**
  6314. * This represents the input manager used within a camera.
  6315. * It helps dealing with all the different kind of input attached to a camera.
  6316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6317. */
  6318. export class CameraInputsManager<TCamera extends Camera> {
  6319. /**
  6320. * Defines the list of inputs attahed to the camera.
  6321. */
  6322. attached: CameraInputsMap<TCamera>;
  6323. /**
  6324. * Defines the dom element the camera is collecting inputs from.
  6325. * This is null if the controls have not been attached.
  6326. */
  6327. attachedElement: Nullable<HTMLElement>;
  6328. /**
  6329. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. noPreventDefault: boolean;
  6332. /**
  6333. * Defined the camera the input manager belongs to.
  6334. */
  6335. camera: TCamera;
  6336. /**
  6337. * Update the current camera state depending on the inputs that have been used this frame.
  6338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6339. */
  6340. checkInputs: () => void;
  6341. /**
  6342. * Instantiate a new Camera Input Manager.
  6343. * @param camera Defines the camera the input manager blongs to
  6344. */
  6345. constructor(camera: TCamera);
  6346. /**
  6347. * Add an input method to a camera
  6348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6349. * @param input camera input method
  6350. */
  6351. add(input: ICameraInput<TCamera>): void;
  6352. /**
  6353. * Remove a specific input method from a camera
  6354. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6355. * @param inputToRemove camera input method
  6356. */
  6357. remove(inputToRemove: ICameraInput<TCamera>): void;
  6358. /**
  6359. * Remove a specific input type from a camera
  6360. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6361. * @param inputType the type of the input to remove
  6362. */
  6363. removeByType(inputType: string): void;
  6364. private _addCheckInputs;
  6365. /**
  6366. * Attach the input controls to the currently attached dom element to listen the events from.
  6367. * @param input Defines the input to attach
  6368. */
  6369. attachInput(input: ICameraInput<TCamera>): void;
  6370. /**
  6371. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6372. * @param element Defines the dom element to collect the events from
  6373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6374. */
  6375. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6376. /**
  6377. * Detach the current manager inputs controls from a specific dom element.
  6378. * @param element Defines the dom element to collect the events from
  6379. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6380. */
  6381. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6382. /**
  6383. * Rebuild the dynamic inputCheck function from the current list of
  6384. * defined inputs in the manager.
  6385. */
  6386. rebuildInputCheck(): void;
  6387. /**
  6388. * Remove all attached input methods from a camera
  6389. */
  6390. clear(): void;
  6391. /**
  6392. * Serialize the current input manager attached to a camera.
  6393. * This ensures than once parsed,
  6394. * the input associated to the camera will be identical to the current ones
  6395. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6396. */
  6397. serialize(serializedCamera: any): void;
  6398. /**
  6399. * Parses an input manager serialized JSON to restore the previous list of inputs
  6400. * and states associated to a camera.
  6401. * @param parsedCamera Defines the JSON to parse
  6402. */
  6403. parse(parsedCamera: any): void;
  6404. }
  6405. }
  6406. declare module BABYLON {
  6407. /**
  6408. * Class used to store data that will be store in GPU memory
  6409. */
  6410. export class Buffer {
  6411. private _engine;
  6412. private _buffer;
  6413. /** @hidden */
  6414. _data: Nullable<DataArray>;
  6415. private _updatable;
  6416. private _instanced;
  6417. private _divisor;
  6418. /**
  6419. * Gets the byte stride.
  6420. */
  6421. readonly byteStride: number;
  6422. /**
  6423. * Constructor
  6424. * @param engine the engine
  6425. * @param data the data to use for this buffer
  6426. * @param updatable whether the data is updatable
  6427. * @param stride the stride (optional)
  6428. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6429. * @param instanced whether the buffer is instanced (optional)
  6430. * @param useBytes set to true if the stride in in bytes (optional)
  6431. * @param divisor sets an optional divisor for instances (1 by default)
  6432. */
  6433. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6434. /**
  6435. * Create a new VertexBuffer based on the current buffer
  6436. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6437. * @param offset defines offset in the buffer (0 by default)
  6438. * @param size defines the size in floats of attributes (position is 3 for instance)
  6439. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6440. * @param instanced defines if the vertex buffer contains indexed data
  6441. * @param useBytes defines if the offset and stride are in bytes *
  6442. * @param divisor sets an optional divisor for instances (1 by default)
  6443. * @returns the new vertex buffer
  6444. */
  6445. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6446. /**
  6447. * Gets a boolean indicating if the Buffer is updatable?
  6448. * @returns true if the buffer is updatable
  6449. */
  6450. isUpdatable(): boolean;
  6451. /**
  6452. * Gets current buffer's data
  6453. * @returns a DataArray or null
  6454. */
  6455. getData(): Nullable<DataArray>;
  6456. /**
  6457. * Gets underlying native buffer
  6458. * @returns underlying native buffer
  6459. */
  6460. getBuffer(): Nullable<DataBuffer>;
  6461. /**
  6462. * Gets the stride in float32 units (i.e. byte stride / 4).
  6463. * May not be an integer if the byte stride is not divisible by 4.
  6464. * @returns the stride in float32 units
  6465. * @deprecated Please use byteStride instead.
  6466. */
  6467. getStrideSize(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: Nullable<DataArray>): void;
  6473. /** @hidden */
  6474. _rebuild(): void;
  6475. /**
  6476. * Update current buffer data
  6477. * @param data defines the data to store
  6478. */
  6479. update(data: DataArray): void;
  6480. /**
  6481. * Updates the data directly.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param vertexCount the vertex count (optional)
  6485. * @param useBytes set to true if the offset is in bytes
  6486. */
  6487. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6488. /**
  6489. * Release all resources
  6490. */
  6491. dispose(): void;
  6492. }
  6493. /**
  6494. * Specialized buffer used to store vertex data
  6495. */
  6496. export class VertexBuffer {
  6497. /** @hidden */
  6498. _buffer: Buffer;
  6499. private _kind;
  6500. private _size;
  6501. private _ownsBuffer;
  6502. private _instanced;
  6503. private _instanceDivisor;
  6504. /**
  6505. * The byte type.
  6506. */
  6507. static readonly BYTE: number;
  6508. /**
  6509. * The unsigned byte type.
  6510. */
  6511. static readonly UNSIGNED_BYTE: number;
  6512. /**
  6513. * The short type.
  6514. */
  6515. static readonly SHORT: number;
  6516. /**
  6517. * The unsigned short type.
  6518. */
  6519. static readonly UNSIGNED_SHORT: number;
  6520. /**
  6521. * The integer type.
  6522. */
  6523. static readonly INT: number;
  6524. /**
  6525. * The unsigned integer type.
  6526. */
  6527. static readonly UNSIGNED_INT: number;
  6528. /**
  6529. * The float type.
  6530. */
  6531. static readonly FLOAT: number;
  6532. /**
  6533. * Gets or sets the instance divisor when in instanced mode
  6534. */
  6535. get instanceDivisor(): number;
  6536. set instanceDivisor(value: number);
  6537. /**
  6538. * Gets the byte stride.
  6539. */
  6540. readonly byteStride: number;
  6541. /**
  6542. * Gets the byte offset.
  6543. */
  6544. readonly byteOffset: number;
  6545. /**
  6546. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6547. */
  6548. readonly normalized: boolean;
  6549. /**
  6550. * Gets the data type of each component in the array.
  6551. */
  6552. readonly type: number;
  6553. /**
  6554. * Constructor
  6555. * @param engine the engine
  6556. * @param data the data to use for this vertex buffer
  6557. * @param kind the vertex buffer kind
  6558. * @param updatable whether the data is updatable
  6559. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6560. * @param stride the stride (optional)
  6561. * @param instanced whether the buffer is instanced (optional)
  6562. * @param offset the offset of the data (optional)
  6563. * @param size the number of components (optional)
  6564. * @param type the type of the component (optional)
  6565. * @param normalized whether the data contains normalized data (optional)
  6566. * @param useBytes set to true if stride and offset are in bytes (optional)
  6567. * @param divisor defines the instance divisor to use (1 by default)
  6568. */
  6569. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6570. /** @hidden */
  6571. _rebuild(): void;
  6572. /**
  6573. * Returns the kind of the VertexBuffer (string)
  6574. * @returns a string
  6575. */
  6576. getKind(): string;
  6577. /**
  6578. * Gets a boolean indicating if the VertexBuffer is updatable?
  6579. * @returns true if the buffer is updatable
  6580. */
  6581. isUpdatable(): boolean;
  6582. /**
  6583. * Gets current buffer's data
  6584. * @returns a DataArray or null
  6585. */
  6586. getData(): Nullable<DataArray>;
  6587. /**
  6588. * Gets underlying native buffer
  6589. * @returns underlying native buffer
  6590. */
  6591. getBuffer(): Nullable<DataBuffer>;
  6592. /**
  6593. * Gets the stride in float32 units (i.e. byte stride / 4).
  6594. * May not be an integer if the byte stride is not divisible by 4.
  6595. * @returns the stride in float32 units
  6596. * @deprecated Please use byteStride instead.
  6597. */
  6598. getStrideSize(): number;
  6599. /**
  6600. * Returns the offset as a multiple of the type byte length.
  6601. * @returns the offset in bytes
  6602. * @deprecated Please use byteOffset instead.
  6603. */
  6604. getOffset(): number;
  6605. /**
  6606. * Returns the number of components per vertex attribute (integer)
  6607. * @returns the size in float
  6608. */
  6609. getSize(): number;
  6610. /**
  6611. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6612. * @returns true if this buffer is instanced
  6613. */
  6614. getIsInstanced(): boolean;
  6615. /**
  6616. * Returns the instancing divisor, zero for non-instanced (integer).
  6617. * @returns a number
  6618. */
  6619. getInstanceDivisor(): number;
  6620. /**
  6621. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6622. * @param data defines the data to store
  6623. */
  6624. create(data?: DataArray): void;
  6625. /**
  6626. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6627. * This function will create a new buffer if the current one is not updatable
  6628. * @param data defines the data to store
  6629. */
  6630. update(data: DataArray): void;
  6631. /**
  6632. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6633. * Returns the directly updated WebGLBuffer.
  6634. * @param data the new data
  6635. * @param offset the new offset
  6636. * @param useBytes set to true if the offset is in bytes
  6637. */
  6638. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6639. /**
  6640. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6641. */
  6642. dispose(): void;
  6643. /**
  6644. * Enumerates each value of this vertex buffer as numbers.
  6645. * @param count the number of values to enumerate
  6646. * @param callback the callback function called for each value
  6647. */
  6648. forEach(count: number, callback: (value: number, index: number) => void): void;
  6649. /**
  6650. * Positions
  6651. */
  6652. static readonly PositionKind: string;
  6653. /**
  6654. * Normals
  6655. */
  6656. static readonly NormalKind: string;
  6657. /**
  6658. * Tangents
  6659. */
  6660. static readonly TangentKind: string;
  6661. /**
  6662. * Texture coordinates
  6663. */
  6664. static readonly UVKind: string;
  6665. /**
  6666. * Texture coordinates 2
  6667. */
  6668. static readonly UV2Kind: string;
  6669. /**
  6670. * Texture coordinates 3
  6671. */
  6672. static readonly UV3Kind: string;
  6673. /**
  6674. * Texture coordinates 4
  6675. */
  6676. static readonly UV4Kind: string;
  6677. /**
  6678. * Texture coordinates 5
  6679. */
  6680. static readonly UV5Kind: string;
  6681. /**
  6682. * Texture coordinates 6
  6683. */
  6684. static readonly UV6Kind: string;
  6685. /**
  6686. * Colors
  6687. */
  6688. static readonly ColorKind: string;
  6689. /**
  6690. * Matrix indices (for bones)
  6691. */
  6692. static readonly MatricesIndicesKind: string;
  6693. /**
  6694. * Matrix weights (for bones)
  6695. */
  6696. static readonly MatricesWeightsKind: string;
  6697. /**
  6698. * Additional matrix indices (for bones)
  6699. */
  6700. static readonly MatricesIndicesExtraKind: string;
  6701. /**
  6702. * Additional matrix weights (for bones)
  6703. */
  6704. static readonly MatricesWeightsExtraKind: string;
  6705. /**
  6706. * Deduces the stride given a kind.
  6707. * @param kind The kind string to deduce
  6708. * @returns The deduced stride
  6709. */
  6710. static DeduceStride(kind: string): number;
  6711. /**
  6712. * Gets the byte length of the given type.
  6713. * @param type the type
  6714. * @returns the number of bytes
  6715. */
  6716. static GetTypeByteLength(type: number): number;
  6717. /**
  6718. * Enumerates each value of the given parameters as numbers.
  6719. * @param data the data to enumerate
  6720. * @param byteOffset the byte offset of the data
  6721. * @param byteStride the byte stride of the data
  6722. * @param componentCount the number of components per element
  6723. * @param componentType the type of the component
  6724. * @param count the number of values to enumerate
  6725. * @param normalized whether the data is normalized
  6726. * @param callback the callback function called for each value
  6727. */
  6728. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6729. private static _GetFloatValue;
  6730. }
  6731. }
  6732. declare module BABYLON {
  6733. /**
  6734. * @hidden
  6735. */
  6736. export class IntersectionInfo {
  6737. bu: Nullable<number>;
  6738. bv: Nullable<number>;
  6739. distance: number;
  6740. faceId: number;
  6741. subMeshId: number;
  6742. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6743. }
  6744. }
  6745. declare module BABYLON {
  6746. /**
  6747. * Class used to store bounding sphere information
  6748. */
  6749. export class BoundingSphere {
  6750. /**
  6751. * Gets the center of the bounding sphere in local space
  6752. */
  6753. readonly center: Vector3;
  6754. /**
  6755. * Radius of the bounding sphere in local space
  6756. */
  6757. radius: number;
  6758. /**
  6759. * Gets the center of the bounding sphere in world space
  6760. */
  6761. readonly centerWorld: Vector3;
  6762. /**
  6763. * Radius of the bounding sphere in world space
  6764. */
  6765. radiusWorld: number;
  6766. /**
  6767. * Gets the minimum vector in local space
  6768. */
  6769. readonly minimum: Vector3;
  6770. /**
  6771. * Gets the maximum vector in local space
  6772. */
  6773. readonly maximum: Vector3;
  6774. private _worldMatrix;
  6775. private static readonly TmpVector3;
  6776. /**
  6777. * Creates a new bounding sphere
  6778. * @param min defines the minimum vector (in local space)
  6779. * @param max defines the maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6783. /**
  6784. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6785. * @param min defines the new minimum vector (in local space)
  6786. * @param max defines the new maximum vector (in local space)
  6787. * @param worldMatrix defines the new world matrix
  6788. */
  6789. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6790. /**
  6791. * Scale the current bounding sphere by applying a scale factor
  6792. * @param factor defines the scale factor to apply
  6793. * @returns the current bounding box
  6794. */
  6795. scale(factor: number): BoundingSphere;
  6796. /**
  6797. * Gets the world matrix of the bounding box
  6798. * @returns a matrix
  6799. */
  6800. getWorldMatrix(): DeepImmutable<Matrix>;
  6801. /** @hidden */
  6802. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6803. /**
  6804. * Tests if the bounding sphere is intersecting the frustum planes
  6805. * @param frustumPlanes defines the frustum planes to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6809. /**
  6810. * Tests if the bounding sphere center is in between the frustum planes.
  6811. * Used for optimistic fast inclusion.
  6812. * @param frustumPlanes defines the frustum planes to test
  6813. * @returns true if the sphere center is in between the frustum planes
  6814. */
  6815. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6816. /**
  6817. * Tests if a point is inside the bounding sphere
  6818. * @param point defines the point to test
  6819. * @returns true if the point is inside the bounding sphere
  6820. */
  6821. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6822. /**
  6823. * Checks if two sphere intersct
  6824. * @param sphere0 sphere 0
  6825. * @param sphere1 sphere 1
  6826. * @returns true if the speres intersect
  6827. */
  6828. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6829. }
  6830. }
  6831. declare module BABYLON {
  6832. /**
  6833. * Class used to store bounding box information
  6834. */
  6835. export class BoundingBox implements ICullable {
  6836. /**
  6837. * Gets the 8 vectors representing the bounding box in local space
  6838. */
  6839. readonly vectors: Vector3[];
  6840. /**
  6841. * Gets the center of the bounding box in local space
  6842. */
  6843. readonly center: Vector3;
  6844. /**
  6845. * Gets the center of the bounding box in world space
  6846. */
  6847. readonly centerWorld: Vector3;
  6848. /**
  6849. * Gets the extend size in local space
  6850. */
  6851. readonly extendSize: Vector3;
  6852. /**
  6853. * Gets the extend size in world space
  6854. */
  6855. readonly extendSizeWorld: Vector3;
  6856. /**
  6857. * Gets the OBB (object bounding box) directions
  6858. */
  6859. readonly directions: Vector3[];
  6860. /**
  6861. * Gets the 8 vectors representing the bounding box in world space
  6862. */
  6863. readonly vectorsWorld: Vector3[];
  6864. /**
  6865. * Gets the minimum vector in world space
  6866. */
  6867. readonly minimumWorld: Vector3;
  6868. /**
  6869. * Gets the maximum vector in world space
  6870. */
  6871. readonly maximumWorld: Vector3;
  6872. /**
  6873. * Gets the minimum vector in local space
  6874. */
  6875. readonly minimum: Vector3;
  6876. /**
  6877. * Gets the maximum vector in local space
  6878. */
  6879. readonly maximum: Vector3;
  6880. private _worldMatrix;
  6881. private static readonly TmpVector3;
  6882. /**
  6883. * @hidden
  6884. */
  6885. _tag: number;
  6886. /**
  6887. * Creates a new bounding box
  6888. * @param min defines the minimum vector (in local space)
  6889. * @param max defines the maximum vector (in local space)
  6890. * @param worldMatrix defines the new world matrix
  6891. */
  6892. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6893. /**
  6894. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6895. * @param min defines the new minimum vector (in local space)
  6896. * @param max defines the new maximum vector (in local space)
  6897. * @param worldMatrix defines the new world matrix
  6898. */
  6899. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6900. /**
  6901. * Scale the current bounding box by applying a scale factor
  6902. * @param factor defines the scale factor to apply
  6903. * @returns the current bounding box
  6904. */
  6905. scale(factor: number): BoundingBox;
  6906. /**
  6907. * Gets the world matrix of the bounding box
  6908. * @returns a matrix
  6909. */
  6910. getWorldMatrix(): DeepImmutable<Matrix>;
  6911. /** @hidden */
  6912. _update(world: DeepImmutable<Matrix>): void;
  6913. /**
  6914. * Tests if the bounding box is intersecting the frustum planes
  6915. * @param frustumPlanes defines the frustum planes to test
  6916. * @returns true if there is an intersection
  6917. */
  6918. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6919. /**
  6920. * Tests if the bounding box is entirely inside the frustum planes
  6921. * @param frustumPlanes defines the frustum planes to test
  6922. * @returns true if there is an inclusion
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6925. /**
  6926. * Tests if a point is inside the bounding box
  6927. * @param point defines the point to test
  6928. * @returns true if the point is inside the bounding box
  6929. */
  6930. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6931. /**
  6932. * Tests if the bounding box intersects with a bounding sphere
  6933. * @param sphere defines the sphere to test
  6934. * @returns true if there is an intersection
  6935. */
  6936. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6937. /**
  6938. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6939. * @param min defines the min vector to use
  6940. * @param max defines the max vector to use
  6941. * @returns true if there is an intersection
  6942. */
  6943. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6944. /**
  6945. * Tests if two bounding boxes are intersections
  6946. * @param box0 defines the first box to test
  6947. * @param box1 defines the second box to test
  6948. * @returns true if there is an intersection
  6949. */
  6950. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6951. /**
  6952. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6953. * @param minPoint defines the minimum vector of the bounding box
  6954. * @param maxPoint defines the maximum vector of the bounding box
  6955. * @param sphereCenter defines the sphere center
  6956. * @param sphereRadius defines the sphere radius
  6957. * @returns true if there is an intersection
  6958. */
  6959. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6960. /**
  6961. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6962. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6963. * @param frustumPlanes defines the frustum planes to test
  6964. * @return true if there is an inclusion
  6965. */
  6966. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6967. /**
  6968. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6969. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6970. * @param frustumPlanes defines the frustum planes to test
  6971. * @return true if there is an intersection
  6972. */
  6973. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6974. }
  6975. }
  6976. declare module BABYLON {
  6977. /** @hidden */
  6978. export class Collider {
  6979. /** Define if a collision was found */
  6980. collisionFound: boolean;
  6981. /**
  6982. * Define last intersection point in local space
  6983. */
  6984. intersectionPoint: Vector3;
  6985. /**
  6986. * Define last collided mesh
  6987. */
  6988. collidedMesh: Nullable<AbstractMesh>;
  6989. private _collisionPoint;
  6990. private _planeIntersectionPoint;
  6991. private _tempVector;
  6992. private _tempVector2;
  6993. private _tempVector3;
  6994. private _tempVector4;
  6995. private _edge;
  6996. private _baseToVertex;
  6997. private _destinationPoint;
  6998. private _slidePlaneNormal;
  6999. private _displacementVector;
  7000. /** @hidden */
  7001. _radius: Vector3;
  7002. /** @hidden */
  7003. _retry: number;
  7004. private _velocity;
  7005. private _basePoint;
  7006. private _epsilon;
  7007. /** @hidden */
  7008. _velocityWorldLength: number;
  7009. /** @hidden */
  7010. _basePointWorld: Vector3;
  7011. private _velocityWorld;
  7012. private _normalizedVelocity;
  7013. /** @hidden */
  7014. _initialVelocity: Vector3;
  7015. /** @hidden */
  7016. _initialPosition: Vector3;
  7017. private _nearestDistance;
  7018. private _collisionMask;
  7019. get collisionMask(): number;
  7020. set collisionMask(mask: number);
  7021. /**
  7022. * Gets the plane normal used to compute the sliding response (in local space)
  7023. */
  7024. get slidePlaneNormal(): Vector3;
  7025. /** @hidden */
  7026. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7027. /** @hidden */
  7028. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7029. /** @hidden */
  7030. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7031. /** @hidden */
  7032. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7033. /** @hidden */
  7034. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7035. /** @hidden */
  7036. _getResponse(pos: Vector3, vel: Vector3): void;
  7037. }
  7038. }
  7039. declare module BABYLON {
  7040. /**
  7041. * Interface for cullable objects
  7042. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7043. */
  7044. export interface ICullable {
  7045. /**
  7046. * Checks if the object or part of the object is in the frustum
  7047. * @param frustumPlanes Camera near/planes
  7048. * @returns true if the object is in frustum otherwise false
  7049. */
  7050. isInFrustum(frustumPlanes: Plane[]): boolean;
  7051. /**
  7052. * Checks if a cullable object (mesh...) is in the camera frustum
  7053. * Unlike isInFrustum this cheks the full bounding box
  7054. * @param frustumPlanes Camera near/planes
  7055. * @returns true if the object is in frustum otherwise false
  7056. */
  7057. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7058. }
  7059. /**
  7060. * Info for a bounding data of a mesh
  7061. */
  7062. export class BoundingInfo implements ICullable {
  7063. /**
  7064. * Bounding box for the mesh
  7065. */
  7066. readonly boundingBox: BoundingBox;
  7067. /**
  7068. * Bounding sphere for the mesh
  7069. */
  7070. readonly boundingSphere: BoundingSphere;
  7071. private _isLocked;
  7072. private static readonly TmpVector3;
  7073. /**
  7074. * Constructs bounding info
  7075. * @param minimum min vector of the bounding box/sphere
  7076. * @param maximum max vector of the bounding box/sphere
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7080. /**
  7081. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7082. * @param min defines the new minimum vector (in local space)
  7083. * @param max defines the new maximum vector (in local space)
  7084. * @param worldMatrix defines the new world matrix
  7085. */
  7086. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7087. /**
  7088. * min vector of the bounding box/sphere
  7089. */
  7090. get minimum(): Vector3;
  7091. /**
  7092. * max vector of the bounding box/sphere
  7093. */
  7094. get maximum(): Vector3;
  7095. /**
  7096. * If the info is locked and won't be updated to avoid perf overhead
  7097. */
  7098. get isLocked(): boolean;
  7099. set isLocked(value: boolean);
  7100. /**
  7101. * Updates the bounding sphere and box
  7102. * @param world world matrix to be used to update
  7103. */
  7104. update(world: DeepImmutable<Matrix>): void;
  7105. /**
  7106. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7107. * @param center New center of the bounding info
  7108. * @param extend New extend of the bounding info
  7109. * @returns the current bounding info
  7110. */
  7111. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7112. /**
  7113. * Scale the current bounding info by applying a scale factor
  7114. * @param factor defines the scale factor to apply
  7115. * @returns the current bounding info
  7116. */
  7117. scale(factor: number): BoundingInfo;
  7118. /**
  7119. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7120. * @param frustumPlanes defines the frustum to test
  7121. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7122. * @returns true if the bounding info is in the frustum planes
  7123. */
  7124. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7125. /**
  7126. * Gets the world distance between the min and max points of the bounding box
  7127. */
  7128. get diagonalLength(): number;
  7129. /**
  7130. * Checks if a cullable object (mesh...) is in the camera frustum
  7131. * Unlike isInFrustum this cheks the full bounding box
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7136. /** @hidden */
  7137. _checkCollision(collider: Collider): boolean;
  7138. /**
  7139. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7140. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7141. * @param point the point to check intersection with
  7142. * @returns if the point intersects
  7143. */
  7144. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7145. /**
  7146. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7147. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7148. * @param boundingInfo the bounding info to check intersection with
  7149. * @param precise if the intersection should be done using OBB
  7150. * @returns if the bounding info intersects
  7151. */
  7152. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7153. }
  7154. }
  7155. declare module BABYLON {
  7156. /**
  7157. * Extracts minimum and maximum values from a list of indexed positions
  7158. * @param positions defines the positions to use
  7159. * @param indices defines the indices to the positions
  7160. * @param indexStart defines the start index
  7161. * @param indexCount defines the end index
  7162. * @param bias defines bias value to add to the result
  7163. * @return minimum and maximum values
  7164. */
  7165. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7166. minimum: Vector3;
  7167. maximum: Vector3;
  7168. };
  7169. /**
  7170. * Extracts minimum and maximum values from a list of positions
  7171. * @param positions defines the positions to use
  7172. * @param start defines the start index in the positions array
  7173. * @param count defines the number of positions to handle
  7174. * @param bias defines bias value to add to the result
  7175. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7176. * @return minimum and maximum values
  7177. */
  7178. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7179. minimum: Vector3;
  7180. maximum: Vector3;
  7181. };
  7182. }
  7183. declare module BABYLON {
  7184. /** @hidden */
  7185. export class WebGLDataBuffer extends DataBuffer {
  7186. private _buffer;
  7187. constructor(resource: WebGLBuffer);
  7188. get underlyingResource(): any;
  7189. }
  7190. }
  7191. declare module BABYLON {
  7192. /** @hidden */
  7193. export class WebGLPipelineContext implements IPipelineContext {
  7194. engine: ThinEngine;
  7195. program: Nullable<WebGLProgram>;
  7196. context?: WebGLRenderingContext;
  7197. vertexShader?: WebGLShader;
  7198. fragmentShader?: WebGLShader;
  7199. isParallelCompiled: boolean;
  7200. onCompiled?: () => void;
  7201. transformFeedback?: WebGLTransformFeedback | null;
  7202. vertexCompilationError: Nullable<string>;
  7203. fragmentCompilationError: Nullable<string>;
  7204. programLinkError: Nullable<string>;
  7205. programValidationError: Nullable<string>;
  7206. get isAsync(): boolean;
  7207. get isReady(): boolean;
  7208. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7209. _getVertexShaderCode(): string | null;
  7210. _getFragmentShaderCode(): string | null;
  7211. }
  7212. }
  7213. declare module BABYLON {
  7214. interface ThinEngine {
  7215. /**
  7216. * Create an uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Create a dynamic uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param elements defines the content of the uniform buffer
  7226. * @returns the webGL uniform buffer
  7227. */
  7228. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7229. /**
  7230. * Update an existing uniform buffer
  7231. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7232. * @param uniformBuffer defines the target uniform buffer
  7233. * @param elements defines the content to update
  7234. * @param offset defines the offset in the uniform buffer where update should start
  7235. * @param count defines the size of the data to update
  7236. */
  7237. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7238. /**
  7239. * Bind an uniform buffer to the current webGL context
  7240. * @param buffer defines the buffer to bind
  7241. */
  7242. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7243. /**
  7244. * Bind a buffer to the current webGL context at a given location
  7245. * @param buffer defines the buffer to bind
  7246. * @param location defines the index where to bind the buffer
  7247. */
  7248. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7249. /**
  7250. * Bind a specific block at a given index in a specific shader program
  7251. * @param pipelineContext defines the pipeline context to use
  7252. * @param blockName defines the block name
  7253. * @param index defines the index where to bind the block
  7254. */
  7255. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7256. }
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Uniform buffer objects.
  7261. *
  7262. * Handles blocks of uniform on the GPU.
  7263. *
  7264. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7265. *
  7266. * For more information, please refer to :
  7267. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7268. */
  7269. export class UniformBuffer {
  7270. private _engine;
  7271. private _buffer;
  7272. private _data;
  7273. private _bufferData;
  7274. private _dynamic?;
  7275. private _uniformLocations;
  7276. private _uniformSizes;
  7277. private _uniformLocationPointer;
  7278. private _needSync;
  7279. private _noUBO;
  7280. private _currentEffect;
  7281. /** @hidden */
  7282. _alreadyBound: boolean;
  7283. private static _MAX_UNIFORM_SIZE;
  7284. private static _tempBuffer;
  7285. /**
  7286. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7291. /**
  7292. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7297. /**
  7298. * Lambda to Update a single float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat: (name: string, x: number) => void;
  7303. /**
  7304. * Lambda to Update a vec2 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a vec3 of float in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7315. /**
  7316. * Lambda to Update a vec4 of float in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7321. /**
  7322. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateMatrix: (name: string, mat: Matrix) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateVector3: (name: string, vector: Vector3) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateVector4: (name: string, vector: Vector4) => void;
  7339. /**
  7340. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7345. /**
  7346. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7351. /**
  7352. * Instantiates a new Uniform buffer objects.
  7353. *
  7354. * Handles blocks of uniform on the GPU.
  7355. *
  7356. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7357. *
  7358. * For more information, please refer to :
  7359. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7360. * @param engine Define the engine the buffer is associated with
  7361. * @param data Define the data contained in the buffer
  7362. * @param dynamic Define if the buffer is updatable
  7363. */
  7364. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7365. /**
  7366. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7367. * or just falling back on setUniformXXX calls.
  7368. */
  7369. get useUbo(): boolean;
  7370. /**
  7371. * Indicates if the WebGL underlying uniform buffer is in sync
  7372. * with the javascript cache data.
  7373. */
  7374. get isSync(): boolean;
  7375. /**
  7376. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7377. * Also, a dynamic UniformBuffer will disable cache verification and always
  7378. * update the underlying WebGL uniform buffer to the GPU.
  7379. * @returns if Dynamic, otherwise false
  7380. */
  7381. isDynamic(): boolean;
  7382. /**
  7383. * The data cache on JS side.
  7384. * @returns the underlying data as a float array
  7385. */
  7386. getData(): Float32Array;
  7387. /**
  7388. * The underlying WebGL Uniform buffer.
  7389. * @returns the webgl buffer
  7390. */
  7391. getBuffer(): Nullable<DataBuffer>;
  7392. /**
  7393. * std140 layout specifies how to align data within an UBO structure.
  7394. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7395. * for specs.
  7396. */
  7397. private _fillAlignment;
  7398. /**
  7399. * Adds an uniform in the buffer.
  7400. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7401. * for the layout to be correct !
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param size Data size, or data directly.
  7404. */
  7405. addUniform(name: string, size: number | number[]): void;
  7406. /**
  7407. * Adds a Matrix 4x4 to the uniform buffer.
  7408. * @param name Name of the uniform, as used in the uniform block in the shader.
  7409. * @param mat A 4x4 matrix.
  7410. */
  7411. addMatrix(name: string, mat: Matrix): void;
  7412. /**
  7413. * Adds a vec2 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param x Define the x component value of the vec2
  7416. * @param y Define the y component value of the vec2
  7417. */
  7418. addFloat2(name: string, x: number, y: number): void;
  7419. /**
  7420. * Adds a vec3 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. * @param x Define the x component value of the vec3
  7423. * @param y Define the y component value of the vec3
  7424. * @param z Define the z component value of the vec3
  7425. */
  7426. addFloat3(name: string, x: number, y: number, z: number): void;
  7427. /**
  7428. * Adds a vec3 to the uniform buffer.
  7429. * @param name Name of the uniform, as used in the uniform block in the shader.
  7430. * @param color Define the vec3 from a Color
  7431. */
  7432. addColor3(name: string, color: Color3): void;
  7433. /**
  7434. * Adds a vec4 to the uniform buffer.
  7435. * @param name Name of the uniform, as used in the uniform block in the shader.
  7436. * @param color Define the rgb components from a Color
  7437. * @param alpha Define the a component of the vec4
  7438. */
  7439. addColor4(name: string, color: Color3, alpha: number): void;
  7440. /**
  7441. * Adds a vec3 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param vector Define the vec3 components from a Vector
  7444. */
  7445. addVector3(name: string, vector: Vector3): void;
  7446. /**
  7447. * Adds a Matrix 3x3 to the uniform buffer.
  7448. * @param name Name of the uniform, as used in the uniform block in the shader.
  7449. */
  7450. addMatrix3x3(name: string): void;
  7451. /**
  7452. * Adds a Matrix 2x2 to the uniform buffer.
  7453. * @param name Name of the uniform, as used in the uniform block in the shader.
  7454. */
  7455. addMatrix2x2(name: string): void;
  7456. /**
  7457. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7458. */
  7459. create(): void;
  7460. /** @hidden */
  7461. _rebuild(): void;
  7462. /**
  7463. * Updates the WebGL Uniform Buffer on the GPU.
  7464. * If the `dynamic` flag is set to true, no cache comparison is done.
  7465. * Otherwise, the buffer will be updated only if the cache differs.
  7466. */
  7467. update(): void;
  7468. /**
  7469. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7470. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7471. * @param data Define the flattened data
  7472. * @param size Define the size of the data.
  7473. */
  7474. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7475. private _valueCache;
  7476. private _cacheMatrix;
  7477. private _updateMatrix3x3ForUniform;
  7478. private _updateMatrix3x3ForEffect;
  7479. private _updateMatrix2x2ForEffect;
  7480. private _updateMatrix2x2ForUniform;
  7481. private _updateFloatForEffect;
  7482. private _updateFloatForUniform;
  7483. private _updateFloat2ForEffect;
  7484. private _updateFloat2ForUniform;
  7485. private _updateFloat3ForEffect;
  7486. private _updateFloat3ForUniform;
  7487. private _updateFloat4ForEffect;
  7488. private _updateFloat4ForUniform;
  7489. private _updateMatrixForEffect;
  7490. private _updateMatrixForUniform;
  7491. private _updateVector3ForEffect;
  7492. private _updateVector3ForUniform;
  7493. private _updateVector4ForEffect;
  7494. private _updateVector4ForUniform;
  7495. private _updateColor3ForEffect;
  7496. private _updateColor3ForUniform;
  7497. private _updateColor4ForEffect;
  7498. private _updateColor4ForUniform;
  7499. /**
  7500. * Sets a sampler uniform on the effect.
  7501. * @param name Define the name of the sampler.
  7502. * @param texture Define the texture to set in the sampler
  7503. */
  7504. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7505. /**
  7506. * Directly updates the value of the uniform in the cache AND on the GPU.
  7507. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7508. * @param data Define the flattened data
  7509. */
  7510. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7511. /**
  7512. * Binds this uniform buffer to an effect.
  7513. * @param effect Define the effect to bind the buffer to
  7514. * @param name Name of the uniform block in the shader.
  7515. */
  7516. bindToEffect(effect: Effect, name: string): void;
  7517. /**
  7518. * Disposes the uniform buffer.
  7519. */
  7520. dispose(): void;
  7521. }
  7522. }
  7523. declare module BABYLON {
  7524. /**
  7525. * Enum that determines the text-wrapping mode to use.
  7526. */
  7527. export enum InspectableType {
  7528. /**
  7529. * Checkbox for booleans
  7530. */
  7531. Checkbox = 0,
  7532. /**
  7533. * Sliders for numbers
  7534. */
  7535. Slider = 1,
  7536. /**
  7537. * Vector3
  7538. */
  7539. Vector3 = 2,
  7540. /**
  7541. * Quaternions
  7542. */
  7543. Quaternion = 3,
  7544. /**
  7545. * Color3
  7546. */
  7547. Color3 = 4,
  7548. /**
  7549. * String
  7550. */
  7551. String = 5
  7552. }
  7553. /**
  7554. * Interface used to define custom inspectable properties.
  7555. * This interface is used by the inspector to display custom property grids
  7556. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7557. */
  7558. export interface IInspectable {
  7559. /**
  7560. * Gets the label to display
  7561. */
  7562. label: string;
  7563. /**
  7564. * Gets the name of the property to edit
  7565. */
  7566. propertyName: string;
  7567. /**
  7568. * Gets the type of the editor to use
  7569. */
  7570. type: InspectableType;
  7571. /**
  7572. * Gets the minimum value of the property when using in "slider" mode
  7573. */
  7574. min?: number;
  7575. /**
  7576. * Gets the maximum value of the property when using in "slider" mode
  7577. */
  7578. max?: number;
  7579. /**
  7580. * Gets the setp to use when using in "slider" mode
  7581. */
  7582. step?: number;
  7583. }
  7584. }
  7585. declare module BABYLON {
  7586. /**
  7587. * Class used to provide helper for timing
  7588. */
  7589. export class TimingTools {
  7590. /**
  7591. * Polyfill for setImmediate
  7592. * @param action defines the action to execute after the current execution block
  7593. */
  7594. static SetImmediate(action: () => void): void;
  7595. }
  7596. }
  7597. declare module BABYLON {
  7598. /**
  7599. * Class used to enable instatition of objects by class name
  7600. */
  7601. export class InstantiationTools {
  7602. /**
  7603. * Use this object to register external classes like custom textures or material
  7604. * to allow the laoders to instantiate them
  7605. */
  7606. static RegisteredExternalClasses: {
  7607. [key: string]: Object;
  7608. };
  7609. /**
  7610. * Tries to instantiate a new object from a given class name
  7611. * @param className defines the class name to instantiate
  7612. * @returns the new object or null if the system was not able to do the instantiation
  7613. */
  7614. static Instantiate(className: string): any;
  7615. }
  7616. }
  7617. declare module BABYLON {
  7618. /**
  7619. * Define options used to create a depth texture
  7620. */
  7621. export class DepthTextureCreationOptions {
  7622. /** Specifies whether or not a stencil should be allocated in the texture */
  7623. generateStencil?: boolean;
  7624. /** Specifies whether or not bilinear filtering is enable on the texture */
  7625. bilinearFiltering?: boolean;
  7626. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7627. comparisonFunction?: number;
  7628. /** Specifies if the created texture is a cube texture */
  7629. isCube?: boolean;
  7630. }
  7631. }
  7632. declare module BABYLON {
  7633. interface ThinEngine {
  7634. /**
  7635. * Creates a depth stencil cube texture.
  7636. * This is only available in WebGL 2.
  7637. * @param size The size of face edge in the cube texture.
  7638. * @param options The options defining the cube texture.
  7639. * @returns The cube texture
  7640. */
  7641. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7642. /**
  7643. * Creates a cube texture
  7644. * @param rootUrl defines the url where the files to load is located
  7645. * @param scene defines the current scene
  7646. * @param files defines the list of files to load (1 per face)
  7647. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7648. * @param onLoad defines an optional callback raised when the texture is loaded
  7649. * @param onError defines an optional callback raised if there is an issue to load the texture
  7650. * @param format defines the format of the data
  7651. * @param forcedExtension defines the extension to use to pick the right loader
  7652. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7653. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7654. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7655. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7656. * @returns the cube texture as an InternalTexture
  7657. */
  7658. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7659. /**
  7660. * Creates a cube texture
  7661. * @param rootUrl defines the url where the files to load is located
  7662. * @param scene defines the current scene
  7663. * @param files defines the list of files to load (1 per face)
  7664. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7665. * @param onLoad defines an optional callback raised when the texture is loaded
  7666. * @param onError defines an optional callback raised if there is an issue to load the texture
  7667. * @param format defines the format of the data
  7668. * @param forcedExtension defines the extension to use to pick the right loader
  7669. * @returns the cube texture as an InternalTexture
  7670. */
  7671. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7672. /**
  7673. * Creates a cube texture
  7674. * @param rootUrl defines the url where the files to load is located
  7675. * @param scene defines the current scene
  7676. * @param files defines the list of files to load (1 per face)
  7677. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7678. * @param onLoad defines an optional callback raised when the texture is loaded
  7679. * @param onError defines an optional callback raised if there is an issue to load the texture
  7680. * @param format defines the format of the data
  7681. * @param forcedExtension defines the extension to use to pick the right loader
  7682. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7683. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7684. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7685. * @returns the cube texture as an InternalTexture
  7686. */
  7687. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7688. /** @hidden */
  7689. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7690. /** @hidden */
  7691. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7692. /** @hidden */
  7693. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7694. /** @hidden */
  7695. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7696. /**
  7697. * @hidden
  7698. */
  7699. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Class for creating a cube texture
  7705. */
  7706. export class CubeTexture extends BaseTexture {
  7707. private _delayedOnLoad;
  7708. /**
  7709. * Observable triggered once the texture has been loaded.
  7710. */
  7711. onLoadObservable: Observable<CubeTexture>;
  7712. /**
  7713. * The url of the texture
  7714. */
  7715. url: string;
  7716. /**
  7717. * Gets or sets the center of the bounding box associated with the cube texture.
  7718. * It must define where the camera used to render the texture was set
  7719. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7720. */
  7721. boundingBoxPosition: Vector3;
  7722. private _boundingBoxSize;
  7723. /**
  7724. * Gets or sets the size of the bounding box associated with the cube texture
  7725. * When defined, the cubemap will switch to local mode
  7726. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7727. * @example https://www.babylonjs-playground.com/#RNASML
  7728. */
  7729. set boundingBoxSize(value: Vector3);
  7730. /**
  7731. * Returns the bounding box size
  7732. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7733. */
  7734. get boundingBoxSize(): Vector3;
  7735. protected _rotationY: number;
  7736. /**
  7737. * Sets texture matrix rotation angle around Y axis in radians.
  7738. */
  7739. set rotationY(value: number);
  7740. /**
  7741. * Gets texture matrix rotation angle around Y axis radians.
  7742. */
  7743. get rotationY(): number;
  7744. /**
  7745. * Are mip maps generated for this texture or not.
  7746. */
  7747. get noMipmap(): boolean;
  7748. private _noMipmap;
  7749. private _files;
  7750. protected _forcedExtension: Nullable<string>;
  7751. private _extensions;
  7752. private _textureMatrix;
  7753. private _format;
  7754. private _createPolynomials;
  7755. /**
  7756. * Creates a cube texture from an array of image urls
  7757. * @param files defines an array of image urls
  7758. * @param scene defines the hosting scene
  7759. * @param noMipmap specifies if mip maps are not used
  7760. * @returns a cube texture
  7761. */
  7762. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7763. /**
  7764. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7765. * @param url defines the url of the prefiltered texture
  7766. * @param scene defines the scene the texture is attached to
  7767. * @param forcedExtension defines the extension of the file if different from the url
  7768. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7769. * @return the prefiltered texture
  7770. */
  7771. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7772. /**
  7773. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7774. * as prefiltered data.
  7775. * @param rootUrl defines the url of the texture or the root name of the six images
  7776. * @param null defines the scene or engine the texture is attached to
  7777. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7778. * @param noMipmap defines if mipmaps should be created or not
  7779. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7780. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7781. * @param onError defines a callback triggered in case of error during load
  7782. * @param format defines the internal format to use for the texture once loaded
  7783. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7784. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7785. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7786. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7787. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7788. * @return the cube texture
  7789. */
  7790. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7791. /**
  7792. * Get the current class name of the texture useful for serialization or dynamic coding.
  7793. * @returns "CubeTexture"
  7794. */
  7795. getClassName(): string;
  7796. /**
  7797. * Update the url (and optional buffer) of this texture if url was null during construction.
  7798. * @param url the url of the texture
  7799. * @param forcedExtension defines the extension to use
  7800. * @param onLoad callback called when the texture is loaded (defaults to null)
  7801. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module BABYLON {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. get isDirty(): boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module BABYLON {
  7935. /**
  7936. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7937. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7938. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7939. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7940. */
  7941. export class ColorCurves {
  7942. private _dirty;
  7943. private _tempColor;
  7944. private _globalCurve;
  7945. private _highlightsCurve;
  7946. private _midtonesCurve;
  7947. private _shadowsCurve;
  7948. private _positiveCurve;
  7949. private _negativeCurve;
  7950. private _globalHue;
  7951. private _globalDensity;
  7952. private _globalSaturation;
  7953. private _globalExposure;
  7954. /**
  7955. * Gets the global Hue value.
  7956. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7957. */
  7958. get globalHue(): number;
  7959. /**
  7960. * Sets the global Hue value.
  7961. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7962. */
  7963. set globalHue(value: number);
  7964. /**
  7965. * Gets the global Density value.
  7966. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. get globalDensity(): number;
  7970. /**
  7971. * Sets the global Density value.
  7972. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7973. * Values less than zero provide a filter of opposite hue.
  7974. */
  7975. set globalDensity(value: number);
  7976. /**
  7977. * Gets the global Saturation value.
  7978. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7979. */
  7980. get globalSaturation(): number;
  7981. /**
  7982. * Sets the global Saturation value.
  7983. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7984. */
  7985. set globalSaturation(value: number);
  7986. /**
  7987. * Gets the global Exposure value.
  7988. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7989. */
  7990. get globalExposure(): number;
  7991. /**
  7992. * Sets the global Exposure value.
  7993. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7994. */
  7995. set globalExposure(value: number);
  7996. private _highlightsHue;
  7997. private _highlightsDensity;
  7998. private _highlightsSaturation;
  7999. private _highlightsExposure;
  8000. /**
  8001. * Gets the highlights Hue value.
  8002. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8003. */
  8004. get highlightsHue(): number;
  8005. /**
  8006. * Sets the highlights Hue value.
  8007. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8008. */
  8009. set highlightsHue(value: number);
  8010. /**
  8011. * Gets the highlights Density value.
  8012. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8013. * Values less than zero provide a filter of opposite hue.
  8014. */
  8015. get highlightsDensity(): number;
  8016. /**
  8017. * Sets the highlights Density value.
  8018. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8019. * Values less than zero provide a filter of opposite hue.
  8020. */
  8021. set highlightsDensity(value: number);
  8022. /**
  8023. * Gets the highlights Saturation value.
  8024. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8025. */
  8026. get highlightsSaturation(): number;
  8027. /**
  8028. * Sets the highlights Saturation value.
  8029. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8030. */
  8031. set highlightsSaturation(value: number);
  8032. /**
  8033. * Gets the highlights Exposure value.
  8034. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8035. */
  8036. get highlightsExposure(): number;
  8037. /**
  8038. * Sets the highlights Exposure value.
  8039. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8040. */
  8041. set highlightsExposure(value: number);
  8042. private _midtonesHue;
  8043. private _midtonesDensity;
  8044. private _midtonesSaturation;
  8045. private _midtonesExposure;
  8046. /**
  8047. * Gets the midtones Hue value.
  8048. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8049. */
  8050. get midtonesHue(): number;
  8051. /**
  8052. * Sets the midtones Hue value.
  8053. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8054. */
  8055. set midtonesHue(value: number);
  8056. /**
  8057. * Gets the midtones Density value.
  8058. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8059. * Values less than zero provide a filter of opposite hue.
  8060. */
  8061. get midtonesDensity(): number;
  8062. /**
  8063. * Sets the midtones Density value.
  8064. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8065. * Values less than zero provide a filter of opposite hue.
  8066. */
  8067. set midtonesDensity(value: number);
  8068. /**
  8069. * Gets the midtones Saturation value.
  8070. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8071. */
  8072. get midtonesSaturation(): number;
  8073. /**
  8074. * Sets the midtones Saturation value.
  8075. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8076. */
  8077. set midtonesSaturation(value: number);
  8078. /**
  8079. * Gets the midtones Exposure value.
  8080. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8081. */
  8082. get midtonesExposure(): number;
  8083. /**
  8084. * Sets the midtones Exposure value.
  8085. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8086. */
  8087. set midtonesExposure(value: number);
  8088. private _shadowsHue;
  8089. private _shadowsDensity;
  8090. private _shadowsSaturation;
  8091. private _shadowsExposure;
  8092. /**
  8093. * Gets the shadows Hue value.
  8094. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8095. */
  8096. get shadowsHue(): number;
  8097. /**
  8098. * Sets the shadows Hue value.
  8099. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8100. */
  8101. set shadowsHue(value: number);
  8102. /**
  8103. * Gets the shadows Density value.
  8104. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. get shadowsDensity(): number;
  8108. /**
  8109. * Sets the shadows Density value.
  8110. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8111. * Values less than zero provide a filter of opposite hue.
  8112. */
  8113. set shadowsDensity(value: number);
  8114. /**
  8115. * Gets the shadows Saturation value.
  8116. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8117. */
  8118. get shadowsSaturation(): number;
  8119. /**
  8120. * Sets the shadows Saturation value.
  8121. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8122. */
  8123. set shadowsSaturation(value: number);
  8124. /**
  8125. * Gets the shadows Exposure value.
  8126. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8127. */
  8128. get shadowsExposure(): number;
  8129. /**
  8130. * Sets the shadows Exposure value.
  8131. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8132. */
  8133. set shadowsExposure(value: number);
  8134. /**
  8135. * Returns the class name
  8136. * @returns The class name
  8137. */
  8138. getClassName(): string;
  8139. /**
  8140. * Binds the color curves to the shader.
  8141. * @param colorCurves The color curve to bind
  8142. * @param effect The effect to bind to
  8143. * @param positiveUniform The positive uniform shader parameter
  8144. * @param neutralUniform The neutral uniform shader parameter
  8145. * @param negativeUniform The negative uniform shader parameter
  8146. */
  8147. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8148. /**
  8149. * Prepare the list of uniforms associated with the ColorCurves effects.
  8150. * @param uniformsList The list of uniforms used in the effect
  8151. */
  8152. static PrepareUniforms(uniformsList: string[]): void;
  8153. /**
  8154. * Returns color grading data based on a hue, density, saturation and exposure value.
  8155. * @param filterHue The hue of the color filter.
  8156. * @param filterDensity The density of the color filter.
  8157. * @param saturation The saturation.
  8158. * @param exposure The exposure.
  8159. * @param result The result data container.
  8160. */
  8161. private getColorGradingDataToRef;
  8162. /**
  8163. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8164. * @param value The input slider value in range [-100,100].
  8165. * @returns Adjusted value.
  8166. */
  8167. private static applyColorGradingSliderNonlinear;
  8168. /**
  8169. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8170. * @param hue The hue (H) input.
  8171. * @param saturation The saturation (S) input.
  8172. * @param brightness The brightness (B) input.
  8173. * @result An RGBA color represented as Vector4.
  8174. */
  8175. private static fromHSBToRef;
  8176. /**
  8177. * Returns a value clamped between min and max
  8178. * @param value The value to clamp
  8179. * @param min The minimum of value
  8180. * @param max The maximum of value
  8181. * @returns The clamped value.
  8182. */
  8183. private static clamp;
  8184. /**
  8185. * Clones the current color curve instance.
  8186. * @return The cloned curves
  8187. */
  8188. clone(): ColorCurves;
  8189. /**
  8190. * Serializes the current color curve instance to a json representation.
  8191. * @return a JSON representation
  8192. */
  8193. serialize(): any;
  8194. /**
  8195. * Parses the color curve from a json representation.
  8196. * @param source the JSON source to parse
  8197. * @return The parsed curves
  8198. */
  8199. static Parse(source: any): ColorCurves;
  8200. }
  8201. }
  8202. declare module BABYLON {
  8203. /**
  8204. * Interface to follow in your material defines to integrate easily the
  8205. * Image proccessing functions.
  8206. * @hidden
  8207. */
  8208. export interface IImageProcessingConfigurationDefines {
  8209. IMAGEPROCESSING: boolean;
  8210. VIGNETTE: boolean;
  8211. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8212. VIGNETTEBLENDMODEOPAQUE: boolean;
  8213. TONEMAPPING: boolean;
  8214. TONEMAPPING_ACES: boolean;
  8215. CONTRAST: boolean;
  8216. EXPOSURE: boolean;
  8217. COLORCURVES: boolean;
  8218. COLORGRADING: boolean;
  8219. COLORGRADING3D: boolean;
  8220. SAMPLER3DGREENDEPTH: boolean;
  8221. SAMPLER3DBGRMAP: boolean;
  8222. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8223. }
  8224. /**
  8225. * @hidden
  8226. */
  8227. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8228. IMAGEPROCESSING: boolean;
  8229. VIGNETTE: boolean;
  8230. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8231. VIGNETTEBLENDMODEOPAQUE: boolean;
  8232. TONEMAPPING: boolean;
  8233. TONEMAPPING_ACES: boolean;
  8234. CONTRAST: boolean;
  8235. COLORCURVES: boolean;
  8236. COLORGRADING: boolean;
  8237. COLORGRADING3D: boolean;
  8238. SAMPLER3DGREENDEPTH: boolean;
  8239. SAMPLER3DBGRMAP: boolean;
  8240. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8241. EXPOSURE: boolean;
  8242. constructor();
  8243. }
  8244. /**
  8245. * This groups together the common properties used for image processing either in direct forward pass
  8246. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8247. * or not.
  8248. */
  8249. export class ImageProcessingConfiguration {
  8250. /**
  8251. * Default tone mapping applied in BabylonJS.
  8252. */
  8253. static readonly TONEMAPPING_STANDARD: number;
  8254. /**
  8255. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8256. * to other engines rendering to increase portability.
  8257. */
  8258. static readonly TONEMAPPING_ACES: number;
  8259. /**
  8260. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8261. */
  8262. colorCurves: Nullable<ColorCurves>;
  8263. private _colorCurvesEnabled;
  8264. /**
  8265. * Gets wether the color curves effect is enabled.
  8266. */
  8267. get colorCurvesEnabled(): boolean;
  8268. /**
  8269. * Sets wether the color curves effect is enabled.
  8270. */
  8271. set colorCurvesEnabled(value: boolean);
  8272. private _colorGradingTexture;
  8273. /**
  8274. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8275. */
  8276. get colorGradingTexture(): Nullable<BaseTexture>;
  8277. /**
  8278. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8279. */
  8280. set colorGradingTexture(value: Nullable<BaseTexture>);
  8281. private _colorGradingEnabled;
  8282. /**
  8283. * Gets wether the color grading effect is enabled.
  8284. */
  8285. get colorGradingEnabled(): boolean;
  8286. /**
  8287. * Sets wether the color grading effect is enabled.
  8288. */
  8289. set colorGradingEnabled(value: boolean);
  8290. private _colorGradingWithGreenDepth;
  8291. /**
  8292. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8293. */
  8294. get colorGradingWithGreenDepth(): boolean;
  8295. /**
  8296. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8297. */
  8298. set colorGradingWithGreenDepth(value: boolean);
  8299. private _colorGradingBGR;
  8300. /**
  8301. * Gets wether the color grading texture contains BGR values.
  8302. */
  8303. get colorGradingBGR(): boolean;
  8304. /**
  8305. * Sets wether the color grading texture contains BGR values.
  8306. */
  8307. set colorGradingBGR(value: boolean);
  8308. /** @hidden */
  8309. _exposure: number;
  8310. /**
  8311. * Gets the Exposure used in the effect.
  8312. */
  8313. get exposure(): number;
  8314. /**
  8315. * Sets the Exposure used in the effect.
  8316. */
  8317. set exposure(value: number);
  8318. private _toneMappingEnabled;
  8319. /**
  8320. * Gets wether the tone mapping effect is enabled.
  8321. */
  8322. get toneMappingEnabled(): boolean;
  8323. /**
  8324. * Sets wether the tone mapping effect is enabled.
  8325. */
  8326. set toneMappingEnabled(value: boolean);
  8327. private _toneMappingType;
  8328. /**
  8329. * Gets the type of tone mapping effect.
  8330. */
  8331. get toneMappingType(): number;
  8332. /**
  8333. * Sets the type of tone mapping effect used in BabylonJS.
  8334. */
  8335. set toneMappingType(value: number);
  8336. protected _contrast: number;
  8337. /**
  8338. * Gets the contrast used in the effect.
  8339. */
  8340. get contrast(): number;
  8341. /**
  8342. * Sets the contrast used in the effect.
  8343. */
  8344. set contrast(value: number);
  8345. /**
  8346. * Vignette stretch size.
  8347. */
  8348. vignetteStretch: number;
  8349. /**
  8350. * Vignette centre X Offset.
  8351. */
  8352. vignetteCentreX: number;
  8353. /**
  8354. * Vignette centre Y Offset.
  8355. */
  8356. vignetteCentreY: number;
  8357. /**
  8358. * Vignette weight or intensity of the vignette effect.
  8359. */
  8360. vignetteWeight: number;
  8361. /**
  8362. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8363. * if vignetteEnabled is set to true.
  8364. */
  8365. vignetteColor: Color4;
  8366. /**
  8367. * Camera field of view used by the Vignette effect.
  8368. */
  8369. vignetteCameraFov: number;
  8370. private _vignetteBlendMode;
  8371. /**
  8372. * Gets the vignette blend mode allowing different kind of effect.
  8373. */
  8374. get vignetteBlendMode(): number;
  8375. /**
  8376. * Sets the vignette blend mode allowing different kind of effect.
  8377. */
  8378. set vignetteBlendMode(value: number);
  8379. private _vignetteEnabled;
  8380. /**
  8381. * Gets wether the vignette effect is enabled.
  8382. */
  8383. get vignetteEnabled(): boolean;
  8384. /**
  8385. * Sets wether the vignette effect is enabled.
  8386. */
  8387. set vignetteEnabled(value: boolean);
  8388. private _applyByPostProcess;
  8389. /**
  8390. * Gets wether the image processing is applied through a post process or not.
  8391. */
  8392. get applyByPostProcess(): boolean;
  8393. /**
  8394. * Sets wether the image processing is applied through a post process or not.
  8395. */
  8396. set applyByPostProcess(value: boolean);
  8397. private _isEnabled;
  8398. /**
  8399. * Gets wether the image processing is enabled or not.
  8400. */
  8401. get isEnabled(): boolean;
  8402. /**
  8403. * Sets wether the image processing is enabled or not.
  8404. */
  8405. set isEnabled(value: boolean);
  8406. /**
  8407. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8408. */
  8409. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8410. /**
  8411. * Method called each time the image processing information changes requires to recompile the effect.
  8412. */
  8413. protected _updateParameters(): void;
  8414. /**
  8415. * Gets the current class name.
  8416. * @return "ImageProcessingConfiguration"
  8417. */
  8418. getClassName(): string;
  8419. /**
  8420. * Prepare the list of uniforms associated with the Image Processing effects.
  8421. * @param uniforms The list of uniforms used in the effect
  8422. * @param defines the list of defines currently in use
  8423. */
  8424. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8425. /**
  8426. * Prepare the list of samplers associated with the Image Processing effects.
  8427. * @param samplersList The list of uniforms used in the effect
  8428. * @param defines the list of defines currently in use
  8429. */
  8430. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8431. /**
  8432. * Prepare the list of defines associated to the shader.
  8433. * @param defines the list of defines to complete
  8434. * @param forPostProcess Define if we are currently in post process mode or not
  8435. */
  8436. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8437. /**
  8438. * Returns true if all the image processing information are ready.
  8439. * @returns True if ready, otherwise, false
  8440. */
  8441. isReady(): boolean;
  8442. /**
  8443. * Binds the image processing to the shader.
  8444. * @param effect The effect to bind to
  8445. * @param overrideAspectRatio Override the aspect ratio of the effect
  8446. */
  8447. bind(effect: Effect, overrideAspectRatio?: number): void;
  8448. /**
  8449. * Clones the current image processing instance.
  8450. * @return The cloned image processing
  8451. */
  8452. clone(): ImageProcessingConfiguration;
  8453. /**
  8454. * Serializes the current image processing instance to a json representation.
  8455. * @return a JSON representation
  8456. */
  8457. serialize(): any;
  8458. /**
  8459. * Parses the image processing from a json representation.
  8460. * @param source the JSON source to parse
  8461. * @return The parsed image processing
  8462. */
  8463. static Parse(source: any): ImageProcessingConfiguration;
  8464. private static _VIGNETTEMODE_MULTIPLY;
  8465. private static _VIGNETTEMODE_OPAQUE;
  8466. /**
  8467. * Used to apply the vignette as a mix with the pixel color.
  8468. */
  8469. static get VIGNETTEMODE_MULTIPLY(): number;
  8470. /**
  8471. * Used to apply the vignette as a replacement of the pixel color.
  8472. */
  8473. static get VIGNETTEMODE_OPAQUE(): number;
  8474. }
  8475. }
  8476. declare module BABYLON {
  8477. /** @hidden */
  8478. export var postprocessVertexShader: {
  8479. name: string;
  8480. shader: string;
  8481. };
  8482. }
  8483. declare module BABYLON {
  8484. interface ThinEngine {
  8485. /**
  8486. * Creates a new render target texture
  8487. * @param size defines the size of the texture
  8488. * @param options defines the options used to create the texture
  8489. * @returns a new render target texture stored in an InternalTexture
  8490. */
  8491. createRenderTargetTexture(size: number | {
  8492. width: number;
  8493. height: number;
  8494. layers?: number;
  8495. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8496. /**
  8497. * Creates a depth stencil texture.
  8498. * This is only available in WebGL 2 or with the depth texture extension available.
  8499. * @param size The size of face edge in the texture.
  8500. * @param options The options defining the texture.
  8501. * @returns The texture
  8502. */
  8503. createDepthStencilTexture(size: number | {
  8504. width: number;
  8505. height: number;
  8506. layers?: number;
  8507. }, options: DepthTextureCreationOptions): InternalTexture;
  8508. /** @hidden */
  8509. _createDepthStencilTexture(size: number | {
  8510. width: number;
  8511. height: number;
  8512. layers?: number;
  8513. }, options: DepthTextureCreationOptions): InternalTexture;
  8514. }
  8515. }
  8516. declare module BABYLON {
  8517. /**
  8518. * Defines the kind of connection point for node based material
  8519. */
  8520. export enum NodeMaterialBlockConnectionPointTypes {
  8521. /** Float */
  8522. Float = 1,
  8523. /** Int */
  8524. Int = 2,
  8525. /** Vector2 */
  8526. Vector2 = 4,
  8527. /** Vector3 */
  8528. Vector3 = 8,
  8529. /** Vector4 */
  8530. Vector4 = 16,
  8531. /** Color3 */
  8532. Color3 = 32,
  8533. /** Color4 */
  8534. Color4 = 64,
  8535. /** Matrix */
  8536. Matrix = 128,
  8537. /** Custom object */
  8538. Object = 256,
  8539. /** Detect type based on connection */
  8540. AutoDetect = 1024,
  8541. /** Output type that will be defined by input type */
  8542. BasedOnInput = 2048
  8543. }
  8544. }
  8545. declare module BABYLON {
  8546. /**
  8547. * Enum used to define the target of a block
  8548. */
  8549. export enum NodeMaterialBlockTargets {
  8550. /** Vertex shader */
  8551. Vertex = 1,
  8552. /** Fragment shader */
  8553. Fragment = 2,
  8554. /** Neutral */
  8555. Neutral = 4,
  8556. /** Vertex and Fragment */
  8557. VertexAndFragment = 3
  8558. }
  8559. }
  8560. declare module BABYLON {
  8561. /**
  8562. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8563. */
  8564. export enum NodeMaterialBlockConnectionPointMode {
  8565. /** Value is an uniform */
  8566. Uniform = 0,
  8567. /** Value is a mesh attribute */
  8568. Attribute = 1,
  8569. /** Value is a varying between vertex and fragment shaders */
  8570. Varying = 2,
  8571. /** Mode is undefined */
  8572. Undefined = 3
  8573. }
  8574. }
  8575. declare module BABYLON {
  8576. /**
  8577. * Enum used to define system values e.g. values automatically provided by the system
  8578. */
  8579. export enum NodeMaterialSystemValues {
  8580. /** World */
  8581. World = 1,
  8582. /** View */
  8583. View = 2,
  8584. /** Projection */
  8585. Projection = 3,
  8586. /** ViewProjection */
  8587. ViewProjection = 4,
  8588. /** WorldView */
  8589. WorldView = 5,
  8590. /** WorldViewProjection */
  8591. WorldViewProjection = 6,
  8592. /** CameraPosition */
  8593. CameraPosition = 7,
  8594. /** Fog Color */
  8595. FogColor = 8,
  8596. /** Delta time */
  8597. DeltaTime = 9
  8598. }
  8599. }
  8600. declare module BABYLON {
  8601. /** Defines supported spaces */
  8602. export enum Space {
  8603. /** Local (object) space */
  8604. LOCAL = 0,
  8605. /** World space */
  8606. WORLD = 1,
  8607. /** Bone space */
  8608. BONE = 2
  8609. }
  8610. /** Defines the 3 main axes */
  8611. export class Axis {
  8612. /** X axis */
  8613. static X: Vector3;
  8614. /** Y axis */
  8615. static Y: Vector3;
  8616. /** Z axis */
  8617. static Z: Vector3;
  8618. }
  8619. }
  8620. declare module BABYLON {
  8621. /**
  8622. * Represents a camera frustum
  8623. */
  8624. export class Frustum {
  8625. /**
  8626. * Gets the planes representing the frustum
  8627. * @param transform matrix to be applied to the returned planes
  8628. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8629. */
  8630. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8631. /**
  8632. * Gets the near frustum plane transformed by the transform matrix
  8633. * @param transform transformation matrix to be applied to the resulting frustum plane
  8634. * @param frustumPlane the resuling frustum plane
  8635. */
  8636. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8637. /**
  8638. * Gets the far frustum plane transformed by the transform matrix
  8639. * @param transform transformation matrix to be applied to the resulting frustum plane
  8640. * @param frustumPlane the resuling frustum plane
  8641. */
  8642. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8643. /**
  8644. * Gets the left frustum plane transformed by the transform matrix
  8645. * @param transform transformation matrix to be applied to the resulting frustum plane
  8646. * @param frustumPlane the resuling frustum plane
  8647. */
  8648. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8649. /**
  8650. * Gets the right frustum plane transformed by the transform matrix
  8651. * @param transform transformation matrix to be applied to the resulting frustum plane
  8652. * @param frustumPlane the resuling frustum plane
  8653. */
  8654. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8655. /**
  8656. * Gets the top frustum plane transformed by the transform matrix
  8657. * @param transform transformation matrix to be applied to the resulting frustum plane
  8658. * @param frustumPlane the resuling frustum plane
  8659. */
  8660. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8661. /**
  8662. * Gets the bottom frustum plane transformed by the transform matrix
  8663. * @param transform transformation matrix to be applied to the resulting frustum plane
  8664. * @param frustumPlane the resuling frustum plane
  8665. */
  8666. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8667. /**
  8668. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8669. * @param transform transformation matrix to be applied to the resulting frustum planes
  8670. * @param frustumPlanes the resuling frustum planes
  8671. */
  8672. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8673. }
  8674. }
  8675. declare module BABYLON {
  8676. /**
  8677. * Interface for the size containing width and height
  8678. */
  8679. export interface ISize {
  8680. /**
  8681. * Width
  8682. */
  8683. width: number;
  8684. /**
  8685. * Heighht
  8686. */
  8687. height: number;
  8688. }
  8689. /**
  8690. * Size containing widht and height
  8691. */
  8692. export class Size implements ISize {
  8693. /**
  8694. * Width
  8695. */
  8696. width: number;
  8697. /**
  8698. * Height
  8699. */
  8700. height: number;
  8701. /**
  8702. * Creates a Size object from the given width and height (floats).
  8703. * @param width width of the new size
  8704. * @param height height of the new size
  8705. */
  8706. constructor(width: number, height: number);
  8707. /**
  8708. * Returns a string with the Size width and height
  8709. * @returns a string with the Size width and height
  8710. */
  8711. toString(): string;
  8712. /**
  8713. * "Size"
  8714. * @returns the string "Size"
  8715. */
  8716. getClassName(): string;
  8717. /**
  8718. * Returns the Size hash code.
  8719. * @returns a hash code for a unique width and height
  8720. */
  8721. getHashCode(): number;
  8722. /**
  8723. * Updates the current size from the given one.
  8724. * @param src the given size
  8725. */
  8726. copyFrom(src: Size): void;
  8727. /**
  8728. * Updates in place the current Size from the given floats.
  8729. * @param width width of the new size
  8730. * @param height height of the new size
  8731. * @returns the updated Size.
  8732. */
  8733. copyFromFloats(width: number, height: number): Size;
  8734. /**
  8735. * Updates in place the current Size from the given floats.
  8736. * @param width width to set
  8737. * @param height height to set
  8738. * @returns the updated Size.
  8739. */
  8740. set(width: number, height: number): Size;
  8741. /**
  8742. * Multiplies the width and height by numbers
  8743. * @param w factor to multiple the width by
  8744. * @param h factor to multiple the height by
  8745. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8746. */
  8747. multiplyByFloats(w: number, h: number): Size;
  8748. /**
  8749. * Clones the size
  8750. * @returns a new Size copied from the given one.
  8751. */
  8752. clone(): Size;
  8753. /**
  8754. * True if the current Size and the given one width and height are strictly equal.
  8755. * @param other the other size to compare against
  8756. * @returns True if the current Size and the given one width and height are strictly equal.
  8757. */
  8758. equals(other: Size): boolean;
  8759. /**
  8760. * The surface of the Size : width * height (float).
  8761. */
  8762. get surface(): number;
  8763. /**
  8764. * Create a new size of zero
  8765. * @returns a new Size set to (0.0, 0.0)
  8766. */
  8767. static Zero(): Size;
  8768. /**
  8769. * Sums the width and height of two sizes
  8770. * @param otherSize size to add to this size
  8771. * @returns a new Size set as the addition result of the current Size and the given one.
  8772. */
  8773. add(otherSize: Size): Size;
  8774. /**
  8775. * Subtracts the width and height of two
  8776. * @param otherSize size to subtract to this size
  8777. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8778. */
  8779. subtract(otherSize: Size): Size;
  8780. /**
  8781. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8782. * @param start starting size to lerp between
  8783. * @param end end size to lerp between
  8784. * @param amount amount to lerp between the start and end values
  8785. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8786. */
  8787. static Lerp(start: Size, end: Size, amount: number): Size;
  8788. }
  8789. }
  8790. declare module BABYLON {
  8791. /**
  8792. * Contains position and normal vectors for a vertex
  8793. */
  8794. export class PositionNormalVertex {
  8795. /** the position of the vertex (defaut: 0,0,0) */
  8796. position: Vector3;
  8797. /** the normal of the vertex (defaut: 0,1,0) */
  8798. normal: Vector3;
  8799. /**
  8800. * Creates a PositionNormalVertex
  8801. * @param position the position of the vertex (defaut: 0,0,0)
  8802. * @param normal the normal of the vertex (defaut: 0,1,0)
  8803. */
  8804. constructor(
  8805. /** the position of the vertex (defaut: 0,0,0) */
  8806. position?: Vector3,
  8807. /** the normal of the vertex (defaut: 0,1,0) */
  8808. normal?: Vector3);
  8809. /**
  8810. * Clones the PositionNormalVertex
  8811. * @returns the cloned PositionNormalVertex
  8812. */
  8813. clone(): PositionNormalVertex;
  8814. }
  8815. /**
  8816. * Contains position, normal and uv vectors for a vertex
  8817. */
  8818. export class PositionNormalTextureVertex {
  8819. /** the position of the vertex (defaut: 0,0,0) */
  8820. position: Vector3;
  8821. /** the normal of the vertex (defaut: 0,1,0) */
  8822. normal: Vector3;
  8823. /** the uv of the vertex (default: 0,0) */
  8824. uv: Vector2;
  8825. /**
  8826. * Creates a PositionNormalTextureVertex
  8827. * @param position the position of the vertex (defaut: 0,0,0)
  8828. * @param normal the normal of the vertex (defaut: 0,1,0)
  8829. * @param uv the uv of the vertex (default: 0,0)
  8830. */
  8831. constructor(
  8832. /** the position of the vertex (defaut: 0,0,0) */
  8833. position?: Vector3,
  8834. /** the normal of the vertex (defaut: 0,1,0) */
  8835. normal?: Vector3,
  8836. /** the uv of the vertex (default: 0,0) */
  8837. uv?: Vector2);
  8838. /**
  8839. * Clones the PositionNormalTextureVertex
  8840. * @returns the cloned PositionNormalTextureVertex
  8841. */
  8842. clone(): PositionNormalTextureVertex;
  8843. }
  8844. }
  8845. declare module BABYLON {
  8846. /**
  8847. * Enum defining the type of animations supported by InputBlock
  8848. */
  8849. export enum AnimatedInputBlockTypes {
  8850. /** No animation */
  8851. None = 0,
  8852. /** Time based animation. Will only work for floats */
  8853. Time = 1
  8854. }
  8855. }
  8856. declare module BABYLON {
  8857. /**
  8858. * Interface describing all the common properties and methods a shadow light needs to implement.
  8859. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8860. * as well as binding the different shadow properties to the effects.
  8861. */
  8862. export interface IShadowLight extends Light {
  8863. /**
  8864. * The light id in the scene (used in scene.findLighById for instance)
  8865. */
  8866. id: string;
  8867. /**
  8868. * The position the shdow will be casted from.
  8869. */
  8870. position: Vector3;
  8871. /**
  8872. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8873. */
  8874. direction: Vector3;
  8875. /**
  8876. * The transformed position. Position of the light in world space taking parenting in account.
  8877. */
  8878. transformedPosition: Vector3;
  8879. /**
  8880. * The transformed direction. Direction of the light in world space taking parenting in account.
  8881. */
  8882. transformedDirection: Vector3;
  8883. /**
  8884. * The friendly name of the light in the scene.
  8885. */
  8886. name: string;
  8887. /**
  8888. * Defines the shadow projection clipping minimum z value.
  8889. */
  8890. shadowMinZ: number;
  8891. /**
  8892. * Defines the shadow projection clipping maximum z value.
  8893. */
  8894. shadowMaxZ: number;
  8895. /**
  8896. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8897. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8898. */
  8899. computeTransformedInformation(): boolean;
  8900. /**
  8901. * Gets the scene the light belongs to.
  8902. * @returns The scene
  8903. */
  8904. getScene(): Scene;
  8905. /**
  8906. * Callback defining a custom Projection Matrix Builder.
  8907. * This can be used to override the default projection matrix computation.
  8908. */
  8909. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8910. /**
  8911. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8912. * @param matrix The materix to updated with the projection information
  8913. * @param viewMatrix The transform matrix of the light
  8914. * @param renderList The list of mesh to render in the map
  8915. * @returns The current light
  8916. */
  8917. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8918. /**
  8919. * Gets the current depth scale used in ESM.
  8920. * @returns The scale
  8921. */
  8922. getDepthScale(): number;
  8923. /**
  8924. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8925. * @returns true if a cube texture needs to be use
  8926. */
  8927. needCube(): boolean;
  8928. /**
  8929. * Detects if the projection matrix requires to be recomputed this frame.
  8930. * @returns true if it requires to be recomputed otherwise, false.
  8931. */
  8932. needProjectionMatrixCompute(): boolean;
  8933. /**
  8934. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8935. */
  8936. forceProjectionMatrixCompute(): void;
  8937. /**
  8938. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8939. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8940. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8941. */
  8942. getShadowDirection(faceIndex?: number): Vector3;
  8943. /**
  8944. * Gets the minZ used for shadow according to both the scene and the light.
  8945. * @param activeCamera The camera we are returning the min for
  8946. * @returns the depth min z
  8947. */
  8948. getDepthMinZ(activeCamera: Camera): number;
  8949. /**
  8950. * Gets the maxZ used for shadow according to both the scene and the light.
  8951. * @param activeCamera The camera we are returning the max for
  8952. * @returns the depth max z
  8953. */
  8954. getDepthMaxZ(activeCamera: Camera): number;
  8955. }
  8956. /**
  8957. * Base implementation IShadowLight
  8958. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8959. */
  8960. export abstract class ShadowLight extends Light implements IShadowLight {
  8961. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8962. protected _position: Vector3;
  8963. protected _setPosition(value: Vector3): void;
  8964. /**
  8965. * Sets the position the shadow will be casted from. Also use as the light position for both
  8966. * point and spot lights.
  8967. */
  8968. get position(): Vector3;
  8969. /**
  8970. * Sets the position the shadow will be casted from. Also use as the light position for both
  8971. * point and spot lights.
  8972. */
  8973. set position(value: Vector3);
  8974. protected _direction: Vector3;
  8975. protected _setDirection(value: Vector3): void;
  8976. /**
  8977. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8978. * Also use as the light direction on spot and directional lights.
  8979. */
  8980. get direction(): Vector3;
  8981. /**
  8982. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8983. * Also use as the light direction on spot and directional lights.
  8984. */
  8985. set direction(value: Vector3);
  8986. protected _shadowMinZ: number;
  8987. /**
  8988. * Gets the shadow projection clipping minimum z value.
  8989. */
  8990. get shadowMinZ(): number;
  8991. /**
  8992. * Sets the shadow projection clipping minimum z value.
  8993. */
  8994. set shadowMinZ(value: number);
  8995. protected _shadowMaxZ: number;
  8996. /**
  8997. * Sets the shadow projection clipping maximum z value.
  8998. */
  8999. get shadowMaxZ(): number;
  9000. /**
  9001. * Gets the shadow projection clipping maximum z value.
  9002. */
  9003. set shadowMaxZ(value: number);
  9004. /**
  9005. * Callback defining a custom Projection Matrix Builder.
  9006. * This can be used to override the default projection matrix computation.
  9007. */
  9008. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9009. /**
  9010. * The transformed position. Position of the light in world space taking parenting in account.
  9011. */
  9012. transformedPosition: Vector3;
  9013. /**
  9014. * The transformed direction. Direction of the light in world space taking parenting in account.
  9015. */
  9016. transformedDirection: Vector3;
  9017. private _needProjectionMatrixCompute;
  9018. /**
  9019. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9020. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9021. */
  9022. computeTransformedInformation(): boolean;
  9023. /**
  9024. * Return the depth scale used for the shadow map.
  9025. * @returns the depth scale.
  9026. */
  9027. getDepthScale(): number;
  9028. /**
  9029. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9030. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9031. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9032. */
  9033. getShadowDirection(faceIndex?: number): Vector3;
  9034. /**
  9035. * Returns the ShadowLight absolute position in the World.
  9036. * @returns the position vector in world space
  9037. */
  9038. getAbsolutePosition(): Vector3;
  9039. /**
  9040. * Sets the ShadowLight direction toward the passed target.
  9041. * @param target The point to target in local space
  9042. * @returns the updated ShadowLight direction
  9043. */
  9044. setDirectionToTarget(target: Vector3): Vector3;
  9045. /**
  9046. * Returns the light rotation in euler definition.
  9047. * @returns the x y z rotation in local space.
  9048. */
  9049. getRotation(): Vector3;
  9050. /**
  9051. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9052. * @returns true if a cube texture needs to be use
  9053. */
  9054. needCube(): boolean;
  9055. /**
  9056. * Detects if the projection matrix requires to be recomputed this frame.
  9057. * @returns true if it requires to be recomputed otherwise, false.
  9058. */
  9059. needProjectionMatrixCompute(): boolean;
  9060. /**
  9061. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9062. */
  9063. forceProjectionMatrixCompute(): void;
  9064. /** @hidden */
  9065. _initCache(): void;
  9066. /** @hidden */
  9067. _isSynchronized(): boolean;
  9068. /**
  9069. * Computes the world matrix of the node
  9070. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9071. * @returns the world matrix
  9072. */
  9073. computeWorldMatrix(force?: boolean): Matrix;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. /**
  9087. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9088. * @param matrix The materix to updated with the projection information
  9089. * @param viewMatrix The transform matrix of the light
  9090. * @param renderList The list of mesh to render in the map
  9091. * @returns The current light
  9092. */
  9093. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9094. }
  9095. }
  9096. declare module BABYLON {
  9097. /** @hidden */
  9098. export var packingFunctions: {
  9099. name: string;
  9100. shader: string;
  9101. };
  9102. }
  9103. declare module BABYLON {
  9104. /** @hidden */
  9105. export var bayerDitherFunctions: {
  9106. name: string;
  9107. shader: string;
  9108. };
  9109. }
  9110. declare module BABYLON {
  9111. /** @hidden */
  9112. export var shadowMapFragmentDeclaration: {
  9113. name: string;
  9114. shader: string;
  9115. };
  9116. }
  9117. declare module BABYLON {
  9118. /** @hidden */
  9119. export var clipPlaneFragmentDeclaration: {
  9120. name: string;
  9121. shader: string;
  9122. };
  9123. }
  9124. declare module BABYLON {
  9125. /** @hidden */
  9126. export var clipPlaneFragment: {
  9127. name: string;
  9128. shader: string;
  9129. };
  9130. }
  9131. declare module BABYLON {
  9132. /** @hidden */
  9133. export var shadowMapFragment: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module BABYLON {
  9139. /** @hidden */
  9140. export var shadowMapPixelShader: {
  9141. name: string;
  9142. shader: string;
  9143. };
  9144. }
  9145. declare module BABYLON {
  9146. /** @hidden */
  9147. export var bonesDeclaration: {
  9148. name: string;
  9149. shader: string;
  9150. };
  9151. }
  9152. declare module BABYLON {
  9153. /** @hidden */
  9154. export var morphTargetsVertexGlobalDeclaration: {
  9155. name: string;
  9156. shader: string;
  9157. };
  9158. }
  9159. declare module BABYLON {
  9160. /** @hidden */
  9161. export var morphTargetsVertexDeclaration: {
  9162. name: string;
  9163. shader: string;
  9164. };
  9165. }
  9166. declare module BABYLON {
  9167. /** @hidden */
  9168. export var instancesDeclaration: {
  9169. name: string;
  9170. shader: string;
  9171. };
  9172. }
  9173. declare module BABYLON {
  9174. /** @hidden */
  9175. export var helperFunctions: {
  9176. name: string;
  9177. shader: string;
  9178. };
  9179. }
  9180. declare module BABYLON {
  9181. /** @hidden */
  9182. export var shadowMapVertexDeclaration: {
  9183. name: string;
  9184. shader: string;
  9185. };
  9186. }
  9187. declare module BABYLON {
  9188. /** @hidden */
  9189. export var clipPlaneVertexDeclaration: {
  9190. name: string;
  9191. shader: string;
  9192. };
  9193. }
  9194. declare module BABYLON {
  9195. /** @hidden */
  9196. export var morphTargetsVertex: {
  9197. name: string;
  9198. shader: string;
  9199. };
  9200. }
  9201. declare module BABYLON {
  9202. /** @hidden */
  9203. export var instancesVertex: {
  9204. name: string;
  9205. shader: string;
  9206. };
  9207. }
  9208. declare module BABYLON {
  9209. /** @hidden */
  9210. export var bonesVertex: {
  9211. name: string;
  9212. shader: string;
  9213. };
  9214. }
  9215. declare module BABYLON {
  9216. /** @hidden */
  9217. export var shadowMapVertexNormalBias: {
  9218. name: string;
  9219. shader: string;
  9220. };
  9221. }
  9222. declare module BABYLON {
  9223. /** @hidden */
  9224. export var shadowMapVertexMetric: {
  9225. name: string;
  9226. shader: string;
  9227. };
  9228. }
  9229. declare module BABYLON {
  9230. /** @hidden */
  9231. export var clipPlaneVertex: {
  9232. name: string;
  9233. shader: string;
  9234. };
  9235. }
  9236. declare module BABYLON {
  9237. /** @hidden */
  9238. export var shadowMapVertexShader: {
  9239. name: string;
  9240. shader: string;
  9241. };
  9242. }
  9243. declare module BABYLON {
  9244. /** @hidden */
  9245. export var depthBoxBlurPixelShader: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module BABYLON {
  9251. /** @hidden */
  9252. export var shadowMapFragmentSoftTransparentShadow: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module BABYLON {
  9258. /**
  9259. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9260. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9261. */
  9262. export class EffectFallbacks implements IEffectFallbacks {
  9263. private _defines;
  9264. private _currentRank;
  9265. private _maxRank;
  9266. private _mesh;
  9267. /**
  9268. * Removes the fallback from the bound mesh.
  9269. */
  9270. unBindMesh(): void;
  9271. /**
  9272. * Adds a fallback on the specified property.
  9273. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9274. * @param define The name of the define in the shader
  9275. */
  9276. addFallback(rank: number, define: string): void;
  9277. /**
  9278. * Sets the mesh to use CPU skinning when needing to fallback.
  9279. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9280. * @param mesh The mesh to use the fallbacks.
  9281. */
  9282. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9283. /**
  9284. * Checks to see if more fallbacks are still availible.
  9285. */
  9286. get hasMoreFallbacks(): boolean;
  9287. /**
  9288. * Removes the defines that should be removed when falling back.
  9289. * @param currentDefines defines the current define statements for the shader.
  9290. * @param effect defines the current effect we try to compile
  9291. * @returns The resulting defines with defines of the current rank removed.
  9292. */
  9293. reduce(currentDefines: string, effect: Effect): string;
  9294. }
  9295. }
  9296. declare module BABYLON {
  9297. /**
  9298. * Interface used to define Action
  9299. */
  9300. export interface IAction {
  9301. /**
  9302. * Trigger for the action
  9303. */
  9304. trigger: number;
  9305. /** Options of the trigger */
  9306. triggerOptions: any;
  9307. /**
  9308. * Gets the trigger parameters
  9309. * @returns the trigger parameters
  9310. */
  9311. getTriggerParameter(): any;
  9312. /**
  9313. * Internal only - executes current action event
  9314. * @hidden
  9315. */
  9316. _executeCurrent(evt?: ActionEvent): void;
  9317. /**
  9318. * Serialize placeholder for child classes
  9319. * @param parent of child
  9320. * @returns the serialized object
  9321. */
  9322. serialize(parent: any): any;
  9323. /**
  9324. * Internal only
  9325. * @hidden
  9326. */
  9327. _prepare(): void;
  9328. /**
  9329. * Internal only - manager for action
  9330. * @hidden
  9331. */
  9332. _actionManager: AbstractActionManager;
  9333. /**
  9334. * Adds action to chain of actions, may be a DoNothingAction
  9335. * @param action defines the next action to execute
  9336. * @returns The action passed in
  9337. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9338. */
  9339. then(action: IAction): IAction;
  9340. }
  9341. /**
  9342. * The action to be carried out following a trigger
  9343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9344. */
  9345. export class Action implements IAction {
  9346. /** the trigger, with or without parameters, for the action */
  9347. triggerOptions: any;
  9348. /**
  9349. * Trigger for the action
  9350. */
  9351. trigger: number;
  9352. /**
  9353. * Internal only - manager for action
  9354. * @hidden
  9355. */
  9356. _actionManager: ActionManager;
  9357. private _nextActiveAction;
  9358. private _child;
  9359. private _condition?;
  9360. private _triggerParameter;
  9361. /**
  9362. * An event triggered prior to action being executed.
  9363. */
  9364. onBeforeExecuteObservable: Observable<Action>;
  9365. /**
  9366. * Creates a new Action
  9367. * @param triggerOptions the trigger, with or without parameters, for the action
  9368. * @param condition an optional determinant of action
  9369. */
  9370. constructor(
  9371. /** the trigger, with or without parameters, for the action */
  9372. triggerOptions: any, condition?: Condition);
  9373. /**
  9374. * Internal only
  9375. * @hidden
  9376. */
  9377. _prepare(): void;
  9378. /**
  9379. * Gets the trigger parameters
  9380. * @returns the trigger parameters
  9381. */
  9382. getTriggerParameter(): any;
  9383. /**
  9384. * Internal only - executes current action event
  9385. * @hidden
  9386. */
  9387. _executeCurrent(evt?: ActionEvent): void;
  9388. /**
  9389. * Execute placeholder for child classes
  9390. * @param evt optional action event
  9391. */
  9392. execute(evt?: ActionEvent): void;
  9393. /**
  9394. * Skips to next active action
  9395. */
  9396. skipToNextActiveAction(): void;
  9397. /**
  9398. * Adds action to chain of actions, may be a DoNothingAction
  9399. * @param action defines the next action to execute
  9400. * @returns The action passed in
  9401. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9402. */
  9403. then(action: Action): Action;
  9404. /**
  9405. * Internal only
  9406. * @hidden
  9407. */
  9408. _getProperty(propertyPath: string): string;
  9409. /**
  9410. * Internal only
  9411. * @hidden
  9412. */
  9413. _getEffectiveTarget(target: any, propertyPath: string): any;
  9414. /**
  9415. * Serialize placeholder for child classes
  9416. * @param parent of child
  9417. * @returns the serialized object
  9418. */
  9419. serialize(parent: any): any;
  9420. /**
  9421. * Internal only called by serialize
  9422. * @hidden
  9423. */
  9424. protected _serialize(serializedAction: any, parent?: any): any;
  9425. /**
  9426. * Internal only
  9427. * @hidden
  9428. */
  9429. static _SerializeValueAsString: (value: any) => string;
  9430. /**
  9431. * Internal only
  9432. * @hidden
  9433. */
  9434. static _GetTargetProperty: (target: Node | Scene) => {
  9435. name: string;
  9436. targetType: string;
  9437. value: string;
  9438. };
  9439. }
  9440. }
  9441. declare module BABYLON {
  9442. /**
  9443. * A Condition applied to an Action
  9444. */
  9445. export class Condition {
  9446. /**
  9447. * Internal only - manager for action
  9448. * @hidden
  9449. */
  9450. _actionManager: ActionManager;
  9451. /**
  9452. * Internal only
  9453. * @hidden
  9454. */
  9455. _evaluationId: number;
  9456. /**
  9457. * Internal only
  9458. * @hidden
  9459. */
  9460. _currentResult: boolean;
  9461. /**
  9462. * Creates a new Condition
  9463. * @param actionManager the manager of the action the condition is applied to
  9464. */
  9465. constructor(actionManager: ActionManager);
  9466. /**
  9467. * Check if the current condition is valid
  9468. * @returns a boolean
  9469. */
  9470. isValid(): boolean;
  9471. /**
  9472. * Internal only
  9473. * @hidden
  9474. */
  9475. _getProperty(propertyPath: string): string;
  9476. /**
  9477. * Internal only
  9478. * @hidden
  9479. */
  9480. _getEffectiveTarget(target: any, propertyPath: string): any;
  9481. /**
  9482. * Serialize placeholder for child classes
  9483. * @returns the serialized object
  9484. */
  9485. serialize(): any;
  9486. /**
  9487. * Internal only
  9488. * @hidden
  9489. */
  9490. protected _serialize(serializedCondition: any): any;
  9491. }
  9492. /**
  9493. * Defines specific conditional operators as extensions of Condition
  9494. */
  9495. export class ValueCondition extends Condition {
  9496. /** path to specify the property of the target the conditional operator uses */
  9497. propertyPath: string;
  9498. /** the value compared by the conditional operator against the current value of the property */
  9499. value: any;
  9500. /** the conditional operator, default ValueCondition.IsEqual */
  9501. operator: number;
  9502. /**
  9503. * Internal only
  9504. * @hidden
  9505. */
  9506. private static _IsEqual;
  9507. /**
  9508. * Internal only
  9509. * @hidden
  9510. */
  9511. private static _IsDifferent;
  9512. /**
  9513. * Internal only
  9514. * @hidden
  9515. */
  9516. private static _IsGreater;
  9517. /**
  9518. * Internal only
  9519. * @hidden
  9520. */
  9521. private static _IsLesser;
  9522. /**
  9523. * returns the number for IsEqual
  9524. */
  9525. static get IsEqual(): number;
  9526. /**
  9527. * Returns the number for IsDifferent
  9528. */
  9529. static get IsDifferent(): number;
  9530. /**
  9531. * Returns the number for IsGreater
  9532. */
  9533. static get IsGreater(): number;
  9534. /**
  9535. * Returns the number for IsLesser
  9536. */
  9537. static get IsLesser(): number;
  9538. /**
  9539. * Internal only The action manager for the condition
  9540. * @hidden
  9541. */
  9542. _actionManager: ActionManager;
  9543. /**
  9544. * Internal only
  9545. * @hidden
  9546. */
  9547. private _target;
  9548. /**
  9549. * Internal only
  9550. * @hidden
  9551. */
  9552. private _effectiveTarget;
  9553. /**
  9554. * Internal only
  9555. * @hidden
  9556. */
  9557. private _property;
  9558. /**
  9559. * Creates a new ValueCondition
  9560. * @param actionManager manager for the action the condition applies to
  9561. * @param target for the action
  9562. * @param propertyPath path to specify the property of the target the conditional operator uses
  9563. * @param value the value compared by the conditional operator against the current value of the property
  9564. * @param operator the conditional operator, default ValueCondition.IsEqual
  9565. */
  9566. constructor(actionManager: ActionManager, target: any,
  9567. /** path to specify the property of the target the conditional operator uses */
  9568. propertyPath: string,
  9569. /** the value compared by the conditional operator against the current value of the property */
  9570. value: any,
  9571. /** the conditional operator, default ValueCondition.IsEqual */
  9572. operator?: number);
  9573. /**
  9574. * Compares the given value with the property value for the specified conditional operator
  9575. * @returns the result of the comparison
  9576. */
  9577. isValid(): boolean;
  9578. /**
  9579. * Serialize the ValueCondition into a JSON compatible object
  9580. * @returns serialization object
  9581. */
  9582. serialize(): any;
  9583. /**
  9584. * Gets the name of the conditional operator for the ValueCondition
  9585. * @param operator the conditional operator
  9586. * @returns the name
  9587. */
  9588. static GetOperatorName(operator: number): string;
  9589. }
  9590. /**
  9591. * Defines a predicate condition as an extension of Condition
  9592. */
  9593. export class PredicateCondition extends Condition {
  9594. /** defines the predicate function used to validate the condition */
  9595. predicate: () => boolean;
  9596. /**
  9597. * Internal only - manager for action
  9598. * @hidden
  9599. */
  9600. _actionManager: ActionManager;
  9601. /**
  9602. * Creates a new PredicateCondition
  9603. * @param actionManager manager for the action the condition applies to
  9604. * @param predicate defines the predicate function used to validate the condition
  9605. */
  9606. constructor(actionManager: ActionManager,
  9607. /** defines the predicate function used to validate the condition */
  9608. predicate: () => boolean);
  9609. /**
  9610. * @returns the validity of the predicate condition
  9611. */
  9612. isValid(): boolean;
  9613. }
  9614. /**
  9615. * Defines a state condition as an extension of Condition
  9616. */
  9617. export class StateCondition extends Condition {
  9618. /** Value to compare with target state */
  9619. value: string;
  9620. /**
  9621. * Internal only - manager for action
  9622. * @hidden
  9623. */
  9624. _actionManager: ActionManager;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. private _target;
  9630. /**
  9631. * Creates a new StateCondition
  9632. * @param actionManager manager for the action the condition applies to
  9633. * @param target of the condition
  9634. * @param value to compare with target state
  9635. */
  9636. constructor(actionManager: ActionManager, target: any,
  9637. /** Value to compare with target state */
  9638. value: string);
  9639. /**
  9640. * Gets a boolean indicating if the current condition is met
  9641. * @returns the validity of the state
  9642. */
  9643. isValid(): boolean;
  9644. /**
  9645. * Serialize the StateCondition into a JSON compatible object
  9646. * @returns serialization object
  9647. */
  9648. serialize(): any;
  9649. }
  9650. }
  9651. declare module BABYLON {
  9652. /**
  9653. * This defines an action responsible to toggle a boolean once triggered.
  9654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9655. */
  9656. export class SwitchBooleanAction extends Action {
  9657. /**
  9658. * The path to the boolean property in the target object
  9659. */
  9660. propertyPath: string;
  9661. private _target;
  9662. private _effectiveTarget;
  9663. private _property;
  9664. /**
  9665. * Instantiate the action
  9666. * @param triggerOptions defines the trigger options
  9667. * @param target defines the object containing the boolean
  9668. * @param propertyPath defines the path to the boolean property in the target object
  9669. * @param condition defines the trigger related conditions
  9670. */
  9671. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9672. /** @hidden */
  9673. _prepare(): void;
  9674. /**
  9675. * Execute the action toggle the boolean value.
  9676. */
  9677. execute(): void;
  9678. /**
  9679. * Serializes the actions and its related information.
  9680. * @param parent defines the object to serialize in
  9681. * @returns the serialized object
  9682. */
  9683. serialize(parent: any): any;
  9684. }
  9685. /**
  9686. * This defines an action responsible to set a the state field of the target
  9687. * to a desired value once triggered.
  9688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9689. */
  9690. export class SetStateAction extends Action {
  9691. /**
  9692. * The value to store in the state field.
  9693. */
  9694. value: string;
  9695. private _target;
  9696. /**
  9697. * Instantiate the action
  9698. * @param triggerOptions defines the trigger options
  9699. * @param target defines the object containing the state property
  9700. * @param value defines the value to store in the state field
  9701. * @param condition defines the trigger related conditions
  9702. */
  9703. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9704. /**
  9705. * Execute the action and store the value on the target state property.
  9706. */
  9707. execute(): void;
  9708. /**
  9709. * Serializes the actions and its related information.
  9710. * @param parent defines the object to serialize in
  9711. * @returns the serialized object
  9712. */
  9713. serialize(parent: any): any;
  9714. }
  9715. /**
  9716. * This defines an action responsible to set a property of the target
  9717. * to a desired value once triggered.
  9718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9719. */
  9720. export class SetValueAction extends Action {
  9721. /**
  9722. * The path of the property to set in the target.
  9723. */
  9724. propertyPath: string;
  9725. /**
  9726. * The value to set in the property
  9727. */
  9728. value: any;
  9729. private _target;
  9730. private _effectiveTarget;
  9731. private _property;
  9732. /**
  9733. * Instantiate the action
  9734. * @param triggerOptions defines the trigger options
  9735. * @param target defines the object containing the property
  9736. * @param propertyPath defines the path of the property to set in the target
  9737. * @param value defines the value to set in the property
  9738. * @param condition defines the trigger related conditions
  9739. */
  9740. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9741. /** @hidden */
  9742. _prepare(): void;
  9743. /**
  9744. * Execute the action and set the targetted property to the desired value.
  9745. */
  9746. execute(): void;
  9747. /**
  9748. * Serializes the actions and its related information.
  9749. * @param parent defines the object to serialize in
  9750. * @returns the serialized object
  9751. */
  9752. serialize(parent: any): any;
  9753. }
  9754. /**
  9755. * This defines an action responsible to increment the target value
  9756. * to a desired value once triggered.
  9757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9758. */
  9759. export class IncrementValueAction extends Action {
  9760. /**
  9761. * The path of the property to increment in the target.
  9762. */
  9763. propertyPath: string;
  9764. /**
  9765. * The value we should increment the property by.
  9766. */
  9767. value: any;
  9768. private _target;
  9769. private _effectiveTarget;
  9770. private _property;
  9771. /**
  9772. * Instantiate the action
  9773. * @param triggerOptions defines the trigger options
  9774. * @param target defines the object containing the property
  9775. * @param propertyPath defines the path of the property to increment in the target
  9776. * @param value defines the value value we should increment the property by
  9777. * @param condition defines the trigger related conditions
  9778. */
  9779. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9780. /** @hidden */
  9781. _prepare(): void;
  9782. /**
  9783. * Execute the action and increment the target of the value amount.
  9784. */
  9785. execute(): void;
  9786. /**
  9787. * Serializes the actions and its related information.
  9788. * @param parent defines the object to serialize in
  9789. * @returns the serialized object
  9790. */
  9791. serialize(parent: any): any;
  9792. }
  9793. /**
  9794. * This defines an action responsible to start an animation once triggered.
  9795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9796. */
  9797. export class PlayAnimationAction extends Action {
  9798. /**
  9799. * Where the animation should start (animation frame)
  9800. */
  9801. from: number;
  9802. /**
  9803. * Where the animation should stop (animation frame)
  9804. */
  9805. to: number;
  9806. /**
  9807. * Define if the animation should loop or stop after the first play.
  9808. */
  9809. loop?: boolean;
  9810. private _target;
  9811. /**
  9812. * Instantiate the action
  9813. * @param triggerOptions defines the trigger options
  9814. * @param target defines the target animation or animation name
  9815. * @param from defines from where the animation should start (animation frame)
  9816. * @param end defines where the animation should stop (animation frame)
  9817. * @param loop defines if the animation should loop or stop after the first play
  9818. * @param condition defines the trigger related conditions
  9819. */
  9820. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9821. /** @hidden */
  9822. _prepare(): void;
  9823. /**
  9824. * Execute the action and play the animation.
  9825. */
  9826. execute(): void;
  9827. /**
  9828. * Serializes the actions and its related information.
  9829. * @param parent defines the object to serialize in
  9830. * @returns the serialized object
  9831. */
  9832. serialize(parent: any): any;
  9833. }
  9834. /**
  9835. * This defines an action responsible to stop an animation once triggered.
  9836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9837. */
  9838. export class StopAnimationAction extends Action {
  9839. private _target;
  9840. /**
  9841. * Instantiate the action
  9842. * @param triggerOptions defines the trigger options
  9843. * @param target defines the target animation or animation name
  9844. * @param condition defines the trigger related conditions
  9845. */
  9846. constructor(triggerOptions: any, target: any, condition?: Condition);
  9847. /** @hidden */
  9848. _prepare(): void;
  9849. /**
  9850. * Execute the action and stop the animation.
  9851. */
  9852. execute(): void;
  9853. /**
  9854. * Serializes the actions and its related information.
  9855. * @param parent defines the object to serialize in
  9856. * @returns the serialized object
  9857. */
  9858. serialize(parent: any): any;
  9859. }
  9860. /**
  9861. * This defines an action responsible that does nothing once triggered.
  9862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9863. */
  9864. export class DoNothingAction extends Action {
  9865. /**
  9866. * Instantiate the action
  9867. * @param triggerOptions defines the trigger options
  9868. * @param condition defines the trigger related conditions
  9869. */
  9870. constructor(triggerOptions?: any, condition?: Condition);
  9871. /**
  9872. * Execute the action and do nothing.
  9873. */
  9874. execute(): void;
  9875. /**
  9876. * Serializes the actions and its related information.
  9877. * @param parent defines the object to serialize in
  9878. * @returns the serialized object
  9879. */
  9880. serialize(parent: any): any;
  9881. }
  9882. /**
  9883. * This defines an action responsible to trigger several actions once triggered.
  9884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9885. */
  9886. export class CombineAction extends Action {
  9887. /**
  9888. * The list of aggregated animations to run.
  9889. */
  9890. children: Action[];
  9891. /**
  9892. * Instantiate the action
  9893. * @param triggerOptions defines the trigger options
  9894. * @param children defines the list of aggregated animations to run
  9895. * @param condition defines the trigger related conditions
  9896. */
  9897. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9898. /** @hidden */
  9899. _prepare(): void;
  9900. /**
  9901. * Execute the action and executes all the aggregated actions.
  9902. */
  9903. execute(evt: ActionEvent): void;
  9904. /**
  9905. * Serializes the actions and its related information.
  9906. * @param parent defines the object to serialize in
  9907. * @returns the serialized object
  9908. */
  9909. serialize(parent: any): any;
  9910. }
  9911. /**
  9912. * This defines an action responsible to run code (external event) once triggered.
  9913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9914. */
  9915. export class ExecuteCodeAction extends Action {
  9916. /**
  9917. * The callback function to run.
  9918. */
  9919. func: (evt: ActionEvent) => void;
  9920. /**
  9921. * Instantiate the action
  9922. * @param triggerOptions defines the trigger options
  9923. * @param func defines the callback function to run
  9924. * @param condition defines the trigger related conditions
  9925. */
  9926. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9927. /**
  9928. * Execute the action and run the attached code.
  9929. */
  9930. execute(evt: ActionEvent): void;
  9931. }
  9932. /**
  9933. * This defines an action responsible to set the parent property of the target once triggered.
  9934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9935. */
  9936. export class SetParentAction extends Action {
  9937. private _parent;
  9938. private _target;
  9939. /**
  9940. * Instantiate the action
  9941. * @param triggerOptions defines the trigger options
  9942. * @param target defines the target containing the parent property
  9943. * @param parent defines from where the animation should start (animation frame)
  9944. * @param condition defines the trigger related conditions
  9945. */
  9946. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9947. /** @hidden */
  9948. _prepare(): void;
  9949. /**
  9950. * Execute the action and set the parent property.
  9951. */
  9952. execute(): void;
  9953. /**
  9954. * Serializes the actions and its related information.
  9955. * @param parent defines the object to serialize in
  9956. * @returns the serialized object
  9957. */
  9958. serialize(parent: any): any;
  9959. }
  9960. }
  9961. declare module BABYLON {
  9962. /**
  9963. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9964. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9966. */
  9967. export class ActionManager extends AbstractActionManager {
  9968. /**
  9969. * Nothing
  9970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9971. */
  9972. static readonly NothingTrigger: number;
  9973. /**
  9974. * On pick
  9975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9976. */
  9977. static readonly OnPickTrigger: number;
  9978. /**
  9979. * On left pick
  9980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9981. */
  9982. static readonly OnLeftPickTrigger: number;
  9983. /**
  9984. * On right pick
  9985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9986. */
  9987. static readonly OnRightPickTrigger: number;
  9988. /**
  9989. * On center pick
  9990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9991. */
  9992. static readonly OnCenterPickTrigger: number;
  9993. /**
  9994. * On pick down
  9995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9996. */
  9997. static readonly OnPickDownTrigger: number;
  9998. /**
  9999. * On double pick
  10000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10001. */
  10002. static readonly OnDoublePickTrigger: number;
  10003. /**
  10004. * On pick up
  10005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10006. */
  10007. static readonly OnPickUpTrigger: number;
  10008. /**
  10009. * On pick out.
  10010. * This trigger will only be raised if you also declared a OnPickDown
  10011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10012. */
  10013. static readonly OnPickOutTrigger: number;
  10014. /**
  10015. * On long press
  10016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10017. */
  10018. static readonly OnLongPressTrigger: number;
  10019. /**
  10020. * On pointer over
  10021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10022. */
  10023. static readonly OnPointerOverTrigger: number;
  10024. /**
  10025. * On pointer out
  10026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10027. */
  10028. static readonly OnPointerOutTrigger: number;
  10029. /**
  10030. * On every frame
  10031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10032. */
  10033. static readonly OnEveryFrameTrigger: number;
  10034. /**
  10035. * On intersection enter
  10036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10037. */
  10038. static readonly OnIntersectionEnterTrigger: number;
  10039. /**
  10040. * On intersection exit
  10041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10042. */
  10043. static readonly OnIntersectionExitTrigger: number;
  10044. /**
  10045. * On key down
  10046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10047. */
  10048. static readonly OnKeyDownTrigger: number;
  10049. /**
  10050. * On key up
  10051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10052. */
  10053. static readonly OnKeyUpTrigger: number;
  10054. private _scene;
  10055. /**
  10056. * Creates a new action manager
  10057. * @param scene defines the hosting scene
  10058. */
  10059. constructor(scene: Scene);
  10060. /**
  10061. * Releases all associated resources
  10062. */
  10063. dispose(): void;
  10064. /**
  10065. * Gets hosting scene
  10066. * @returns the hosting scene
  10067. */
  10068. getScene(): Scene;
  10069. /**
  10070. * Does this action manager handles actions of any of the given triggers
  10071. * @param triggers defines the triggers to be tested
  10072. * @return a boolean indicating whether one (or more) of the triggers is handled
  10073. */
  10074. hasSpecificTriggers(triggers: number[]): boolean;
  10075. /**
  10076. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10077. * speed.
  10078. * @param triggerA defines the trigger to be tested
  10079. * @param triggerB defines the trigger to be tested
  10080. * @return a boolean indicating whether one (or more) of the triggers is handled
  10081. */
  10082. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10083. /**
  10084. * Does this action manager handles actions of a given trigger
  10085. * @param trigger defines the trigger to be tested
  10086. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10087. * @return whether the trigger is handled
  10088. */
  10089. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10090. /**
  10091. * Does this action manager has pointer triggers
  10092. */
  10093. get hasPointerTriggers(): boolean;
  10094. /**
  10095. * Does this action manager has pick triggers
  10096. */
  10097. get hasPickTriggers(): boolean;
  10098. /**
  10099. * Registers an action to this action manager
  10100. * @param action defines the action to be registered
  10101. * @return the action amended (prepared) after registration
  10102. */
  10103. registerAction(action: IAction): Nullable<IAction>;
  10104. /**
  10105. * Unregisters an action to this action manager
  10106. * @param action defines the action to be unregistered
  10107. * @return a boolean indicating whether the action has been unregistered
  10108. */
  10109. unregisterAction(action: IAction): Boolean;
  10110. /**
  10111. * Process a specific trigger
  10112. * @param trigger defines the trigger to process
  10113. * @param evt defines the event details to be processed
  10114. */
  10115. processTrigger(trigger: number, evt?: IActionEvent): void;
  10116. /** @hidden */
  10117. _getEffectiveTarget(target: any, propertyPath: string): any;
  10118. /** @hidden */
  10119. _getProperty(propertyPath: string): string;
  10120. /**
  10121. * Serialize this manager to a JSON object
  10122. * @param name defines the property name to store this manager
  10123. * @returns a JSON representation of this manager
  10124. */
  10125. serialize(name: string): any;
  10126. /**
  10127. * Creates a new ActionManager from a JSON data
  10128. * @param parsedActions defines the JSON data to read from
  10129. * @param object defines the hosting mesh
  10130. * @param scene defines the hosting scene
  10131. */
  10132. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10133. /**
  10134. * Get a trigger name by index
  10135. * @param trigger defines the trigger index
  10136. * @returns a trigger name
  10137. */
  10138. static GetTriggerName(trigger: number): string;
  10139. }
  10140. }
  10141. declare module BABYLON {
  10142. /**
  10143. * Class used to represent a sprite
  10144. * @see http://doc.babylonjs.com/babylon101/sprites
  10145. */
  10146. export class Sprite implements IAnimatable {
  10147. /** defines the name */
  10148. name: string;
  10149. /** Gets or sets the current world position */
  10150. position: Vector3;
  10151. /** Gets or sets the main color */
  10152. color: Color4;
  10153. /** Gets or sets the width */
  10154. width: number;
  10155. /** Gets or sets the height */
  10156. height: number;
  10157. /** Gets or sets rotation angle */
  10158. angle: number;
  10159. /** Gets or sets the cell index in the sprite sheet */
  10160. cellIndex: number;
  10161. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10162. cellRef: string;
  10163. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10164. invertU: boolean;
  10165. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10166. invertV: boolean;
  10167. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10168. disposeWhenFinishedAnimating: boolean;
  10169. /** Gets the list of attached animations */
  10170. animations: Nullable<Array<Animation>>;
  10171. /** Gets or sets a boolean indicating if the sprite can be picked */
  10172. isPickable: boolean;
  10173. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10174. useAlphaForPicking: boolean;
  10175. /** @hidden */
  10176. _xOffset: number;
  10177. /** @hidden */
  10178. _yOffset: number;
  10179. /** @hidden */
  10180. _xSize: number;
  10181. /** @hidden */
  10182. _ySize: number;
  10183. /**
  10184. * Gets or sets the associated action manager
  10185. */
  10186. actionManager: Nullable<ActionManager>;
  10187. /**
  10188. * An event triggered when the control has been disposed
  10189. */
  10190. onDisposeObservable: Observable<Sprite>;
  10191. private _animationStarted;
  10192. private _loopAnimation;
  10193. private _fromIndex;
  10194. private _toIndex;
  10195. private _delay;
  10196. private _direction;
  10197. private _manager;
  10198. private _time;
  10199. private _onAnimationEnd;
  10200. /**
  10201. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10202. */
  10203. isVisible: boolean;
  10204. /**
  10205. * Gets or sets the sprite size
  10206. */
  10207. get size(): number;
  10208. set size(value: number);
  10209. /**
  10210. * Returns a boolean indicating if the animation is started
  10211. */
  10212. get animationStarted(): boolean;
  10213. /**
  10214. * Gets or sets the unique id of the sprite
  10215. */
  10216. uniqueId: number;
  10217. /**
  10218. * Gets the manager of this sprite
  10219. */
  10220. get manager(): ISpriteManager;
  10221. /**
  10222. * Creates a new Sprite
  10223. * @param name defines the name
  10224. * @param manager defines the manager
  10225. */
  10226. constructor(
  10227. /** defines the name */
  10228. name: string, manager: ISpriteManager);
  10229. /**
  10230. * Returns the string "Sprite"
  10231. * @returns "Sprite"
  10232. */
  10233. getClassName(): string;
  10234. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10235. get fromIndex(): number;
  10236. set fromIndex(value: number);
  10237. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10238. get toIndex(): number;
  10239. set toIndex(value: number);
  10240. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10241. get loopAnimation(): boolean;
  10242. set loopAnimation(value: boolean);
  10243. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10244. get delay(): number;
  10245. set delay(value: number);
  10246. /**
  10247. * Starts an animation
  10248. * @param from defines the initial key
  10249. * @param to defines the end key
  10250. * @param loop defines if the animation must loop
  10251. * @param delay defines the start delay (in ms)
  10252. * @param onAnimationEnd defines a callback to call when animation ends
  10253. */
  10254. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10255. /** Stops current animation (if any) */
  10256. stopAnimation(): void;
  10257. /** @hidden */
  10258. _animate(deltaTime: number): void;
  10259. /** Release associated resources */
  10260. dispose(): void;
  10261. /**
  10262. * Serializes the sprite to a JSON object
  10263. * @returns the JSON object
  10264. */
  10265. serialize(): any;
  10266. /**
  10267. * Parses a JSON object to create a new sprite
  10268. * @param parsedSprite The JSON object to parse
  10269. * @param manager defines the hosting manager
  10270. * @returns the new sprite
  10271. */
  10272. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10273. }
  10274. }
  10275. declare module BABYLON {
  10276. /**
  10277. * Information about the result of picking within a scene
  10278. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10279. */
  10280. export class PickingInfo {
  10281. /** @hidden */
  10282. _pickingUnavailable: boolean;
  10283. /**
  10284. * If the pick collided with an object
  10285. */
  10286. hit: boolean;
  10287. /**
  10288. * Distance away where the pick collided
  10289. */
  10290. distance: number;
  10291. /**
  10292. * The location of pick collision
  10293. */
  10294. pickedPoint: Nullable<Vector3>;
  10295. /**
  10296. * The mesh corresponding the the pick collision
  10297. */
  10298. pickedMesh: Nullable<AbstractMesh>;
  10299. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10300. bu: number;
  10301. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10302. bv: number;
  10303. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10304. faceId: number;
  10305. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10306. subMeshFaceId: number;
  10307. /** Id of the the submesh that was picked */
  10308. subMeshId: number;
  10309. /** If a sprite was picked, this will be the sprite the pick collided with */
  10310. pickedSprite: Nullable<Sprite>;
  10311. /**
  10312. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10313. */
  10314. originMesh: Nullable<AbstractMesh>;
  10315. /**
  10316. * The ray that was used to perform the picking.
  10317. */
  10318. ray: Nullable<Ray>;
  10319. /**
  10320. * Gets the normal correspodning to the face the pick collided with
  10321. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10322. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10323. * @returns The normal correspodning to the face the pick collided with
  10324. */
  10325. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10326. /**
  10327. * Gets the texture coordinates of where the pick occured
  10328. * @returns the vector containing the coordnates of the texture
  10329. */
  10330. getTextureCoordinates(): Nullable<Vector2>;
  10331. }
  10332. }
  10333. declare module BABYLON {
  10334. /**
  10335. * Class representing a ray with position and direction
  10336. */
  10337. export class Ray {
  10338. /** origin point */
  10339. origin: Vector3;
  10340. /** direction */
  10341. direction: Vector3;
  10342. /** length of the ray */
  10343. length: number;
  10344. private static readonly TmpVector3;
  10345. private _tmpRay;
  10346. /**
  10347. * Creates a new ray
  10348. * @param origin origin point
  10349. * @param direction direction
  10350. * @param length length of the ray
  10351. */
  10352. constructor(
  10353. /** origin point */
  10354. origin: Vector3,
  10355. /** direction */
  10356. direction: Vector3,
  10357. /** length of the ray */
  10358. length?: number);
  10359. /**
  10360. * Checks if the ray intersects a box
  10361. * This does not account for the ray lenght by design to improve perfs.
  10362. * @param minimum bound of the box
  10363. * @param maximum bound of the box
  10364. * @param intersectionTreshold extra extend to be added to the box in all direction
  10365. * @returns if the box was hit
  10366. */
  10367. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10368. /**
  10369. * Checks if the ray intersects a box
  10370. * This does not account for the ray lenght by design to improve perfs.
  10371. * @param box the bounding box to check
  10372. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10373. * @returns if the box was hit
  10374. */
  10375. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10376. /**
  10377. * If the ray hits a sphere
  10378. * @param sphere the bounding sphere to check
  10379. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10380. * @returns true if it hits the sphere
  10381. */
  10382. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10383. /**
  10384. * If the ray hits a triange
  10385. * @param vertex0 triangle vertex
  10386. * @param vertex1 triangle vertex
  10387. * @param vertex2 triangle vertex
  10388. * @returns intersection information if hit
  10389. */
  10390. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10391. /**
  10392. * Checks if ray intersects a plane
  10393. * @param plane the plane to check
  10394. * @returns the distance away it was hit
  10395. */
  10396. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10397. /**
  10398. * Calculate the intercept of a ray on a given axis
  10399. * @param axis to check 'x' | 'y' | 'z'
  10400. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10401. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10402. */
  10403. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10404. /**
  10405. * Checks if ray intersects a mesh
  10406. * @param mesh the mesh to check
  10407. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10408. * @returns picking info of the intersecton
  10409. */
  10410. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10411. /**
  10412. * Checks if ray intersects a mesh
  10413. * @param meshes the meshes to check
  10414. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10415. * @param results array to store result in
  10416. * @returns Array of picking infos
  10417. */
  10418. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10419. private _comparePickingInfo;
  10420. private static smallnum;
  10421. private static rayl;
  10422. /**
  10423. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10424. * @param sega the first point of the segment to test the intersection against
  10425. * @param segb the second point of the segment to test the intersection against
  10426. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10427. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10428. */
  10429. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10430. /**
  10431. * Update the ray from viewport position
  10432. * @param x position
  10433. * @param y y position
  10434. * @param viewportWidth viewport width
  10435. * @param viewportHeight viewport height
  10436. * @param world world matrix
  10437. * @param view view matrix
  10438. * @param projection projection matrix
  10439. * @returns this ray updated
  10440. */
  10441. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10442. /**
  10443. * Creates a ray with origin and direction of 0,0,0
  10444. * @returns the new ray
  10445. */
  10446. static Zero(): Ray;
  10447. /**
  10448. * Creates a new ray from screen space and viewport
  10449. * @param x position
  10450. * @param y y position
  10451. * @param viewportWidth viewport width
  10452. * @param viewportHeight viewport height
  10453. * @param world world matrix
  10454. * @param view view matrix
  10455. * @param projection projection matrix
  10456. * @returns new ray
  10457. */
  10458. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10459. /**
  10460. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10461. * transformed to the given world matrix.
  10462. * @param origin The origin point
  10463. * @param end The end point
  10464. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10465. * @returns the new ray
  10466. */
  10467. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10468. /**
  10469. * Transforms a ray by a matrix
  10470. * @param ray ray to transform
  10471. * @param matrix matrix to apply
  10472. * @returns the resulting new ray
  10473. */
  10474. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10475. /**
  10476. * Transforms a ray by a matrix
  10477. * @param ray ray to transform
  10478. * @param matrix matrix to apply
  10479. * @param result ray to store result in
  10480. */
  10481. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10482. /**
  10483. * Unproject a ray from screen space to object space
  10484. * @param sourceX defines the screen space x coordinate to use
  10485. * @param sourceY defines the screen space y coordinate to use
  10486. * @param viewportWidth defines the current width of the viewport
  10487. * @param viewportHeight defines the current height of the viewport
  10488. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10489. * @param view defines the view matrix to use
  10490. * @param projection defines the projection matrix to use
  10491. */
  10492. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10493. }
  10494. /**
  10495. * Type used to define predicate used to select faces when a mesh intersection is detected
  10496. */
  10497. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10498. interface Scene {
  10499. /** @hidden */
  10500. _tempPickingRay: Nullable<Ray>;
  10501. /** @hidden */
  10502. _cachedRayForTransform: Ray;
  10503. /** @hidden */
  10504. _pickWithRayInverseMatrix: Matrix;
  10505. /** @hidden */
  10506. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10507. /** @hidden */
  10508. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10509. }
  10510. }
  10511. declare module BABYLON {
  10512. /**
  10513. * Groups all the scene component constants in one place to ease maintenance.
  10514. * @hidden
  10515. */
  10516. export class SceneComponentConstants {
  10517. static readonly NAME_EFFECTLAYER: string;
  10518. static readonly NAME_LAYER: string;
  10519. static readonly NAME_LENSFLARESYSTEM: string;
  10520. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10521. static readonly NAME_PARTICLESYSTEM: string;
  10522. static readonly NAME_GAMEPAD: string;
  10523. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10524. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10525. static readonly NAME_DEPTHRENDERER: string;
  10526. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10527. static readonly NAME_SPRITE: string;
  10528. static readonly NAME_OUTLINERENDERER: string;
  10529. static readonly NAME_PROCEDURALTEXTURE: string;
  10530. static readonly NAME_SHADOWGENERATOR: string;
  10531. static readonly NAME_OCTREE: string;
  10532. static readonly NAME_PHYSICSENGINE: string;
  10533. static readonly NAME_AUDIO: string;
  10534. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10535. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10536. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10538. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10539. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10540. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10541. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10542. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10543. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10544. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10545. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10546. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10547. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10548. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10549. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10550. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10551. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10552. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10553. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10554. static readonly STEP_AFTERRENDER_AUDIO: number;
  10555. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10558. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10559. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10560. static readonly STEP_POINTERMOVE_SPRITE: number;
  10561. static readonly STEP_POINTERDOWN_SPRITE: number;
  10562. static readonly STEP_POINTERUP_SPRITE: number;
  10563. }
  10564. /**
  10565. * This represents a scene component.
  10566. *
  10567. * This is used to decouple the dependency the scene is having on the different workloads like
  10568. * layers, post processes...
  10569. */
  10570. export interface ISceneComponent {
  10571. /**
  10572. * The name of the component. Each component must have a unique name.
  10573. */
  10574. name: string;
  10575. /**
  10576. * The scene the component belongs to.
  10577. */
  10578. scene: Scene;
  10579. /**
  10580. * Register the component to one instance of a scene.
  10581. */
  10582. register(): void;
  10583. /**
  10584. * Rebuilds the elements related to this component in case of
  10585. * context lost for instance.
  10586. */
  10587. rebuild(): void;
  10588. /**
  10589. * Disposes the component and the associated ressources.
  10590. */
  10591. dispose(): void;
  10592. }
  10593. /**
  10594. * This represents a SERIALIZABLE scene component.
  10595. *
  10596. * This extends Scene Component to add Serialization methods on top.
  10597. */
  10598. export interface ISceneSerializableComponent extends ISceneComponent {
  10599. /**
  10600. * Adds all the elements from the container to the scene
  10601. * @param container the container holding the elements
  10602. */
  10603. addFromContainer(container: AbstractScene): void;
  10604. /**
  10605. * Removes all the elements in the container from the scene
  10606. * @param container contains the elements to remove
  10607. * @param dispose if the removed element should be disposed (default: false)
  10608. */
  10609. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10610. /**
  10611. * Serializes the component data to the specified json object
  10612. * @param serializationObject The object to serialize to
  10613. */
  10614. serialize(serializationObject: any): void;
  10615. }
  10616. /**
  10617. * Strong typing of a Mesh related stage step action
  10618. */
  10619. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10620. /**
  10621. * Strong typing of a Evaluate Sub Mesh related stage step action
  10622. */
  10623. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10624. /**
  10625. * Strong typing of a Active Mesh related stage step action
  10626. */
  10627. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10628. /**
  10629. * Strong typing of a Camera related stage step action
  10630. */
  10631. export type CameraStageAction = (camera: Camera) => void;
  10632. /**
  10633. * Strong typing of a Camera Frame buffer related stage step action
  10634. */
  10635. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10636. /**
  10637. * Strong typing of a Render Target related stage step action
  10638. */
  10639. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10640. /**
  10641. * Strong typing of a RenderingGroup related stage step action
  10642. */
  10643. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10644. /**
  10645. * Strong typing of a Mesh Render related stage step action
  10646. */
  10647. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10648. /**
  10649. * Strong typing of a simple stage step action
  10650. */
  10651. export type SimpleStageAction = () => void;
  10652. /**
  10653. * Strong typing of a render target action.
  10654. */
  10655. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10656. /**
  10657. * Strong typing of a pointer move action.
  10658. */
  10659. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10660. /**
  10661. * Strong typing of a pointer up/down action.
  10662. */
  10663. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10664. /**
  10665. * Representation of a stage in the scene (Basically a list of ordered steps)
  10666. * @hidden
  10667. */
  10668. export class Stage<T extends Function> extends Array<{
  10669. index: number;
  10670. component: ISceneComponent;
  10671. action: T;
  10672. }> {
  10673. /**
  10674. * Hide ctor from the rest of the world.
  10675. * @param items The items to add.
  10676. */
  10677. private constructor();
  10678. /**
  10679. * Creates a new Stage.
  10680. * @returns A new instance of a Stage
  10681. */
  10682. static Create<T extends Function>(): Stage<T>;
  10683. /**
  10684. * Registers a step in an ordered way in the targeted stage.
  10685. * @param index Defines the position to register the step in
  10686. * @param component Defines the component attached to the step
  10687. * @param action Defines the action to launch during the step
  10688. */
  10689. registerStep(index: number, component: ISceneComponent, action: T): void;
  10690. /**
  10691. * Clears all the steps from the stage.
  10692. */
  10693. clear(): void;
  10694. }
  10695. }
  10696. declare module BABYLON {
  10697. interface Scene {
  10698. /** @hidden */
  10699. _pointerOverSprite: Nullable<Sprite>;
  10700. /** @hidden */
  10701. _pickedDownSprite: Nullable<Sprite>;
  10702. /** @hidden */
  10703. _tempSpritePickingRay: Nullable<Ray>;
  10704. /**
  10705. * All of the sprite managers added to this scene
  10706. * @see http://doc.babylonjs.com/babylon101/sprites
  10707. */
  10708. spriteManagers: Array<ISpriteManager>;
  10709. /**
  10710. * An event triggered when sprites rendering is about to start
  10711. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10712. */
  10713. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10714. /**
  10715. * An event triggered when sprites rendering is done
  10716. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10717. */
  10718. onAfterSpritesRenderingObservable: Observable<Scene>;
  10719. /** @hidden */
  10720. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10721. /** Launch a ray to try to pick a sprite in the scene
  10722. * @param x position on screen
  10723. * @param y position on screen
  10724. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10725. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10726. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10727. * @returns a PickingInfo
  10728. */
  10729. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10730. /** Use the given ray to pick a sprite in the scene
  10731. * @param ray The ray (in world space) to use to pick meshes
  10732. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10733. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10734. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10735. * @returns a PickingInfo
  10736. */
  10737. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10738. /** @hidden */
  10739. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10740. /** Launch a ray to try to pick sprites in the scene
  10741. * @param x position on screen
  10742. * @param y position on screen
  10743. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10744. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10745. * @returns a PickingInfo array
  10746. */
  10747. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10748. /** Use the given ray to pick sprites in the scene
  10749. * @param ray The ray (in world space) to use to pick meshes
  10750. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10751. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10752. * @returns a PickingInfo array
  10753. */
  10754. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10755. /**
  10756. * Force the sprite under the pointer
  10757. * @param sprite defines the sprite to use
  10758. */
  10759. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10760. /**
  10761. * Gets the sprite under the pointer
  10762. * @returns a Sprite or null if no sprite is under the pointer
  10763. */
  10764. getPointerOverSprite(): Nullable<Sprite>;
  10765. }
  10766. /**
  10767. * Defines the sprite scene component responsible to manage sprites
  10768. * in a given scene.
  10769. */
  10770. export class SpriteSceneComponent implements ISceneComponent {
  10771. /**
  10772. * The component name helpfull to identify the component in the list of scene components.
  10773. */
  10774. readonly name: string;
  10775. /**
  10776. * The scene the component belongs to.
  10777. */
  10778. scene: Scene;
  10779. /** @hidden */
  10780. private _spritePredicate;
  10781. /**
  10782. * Creates a new instance of the component for the given scene
  10783. * @param scene Defines the scene to register the component in
  10784. */
  10785. constructor(scene: Scene);
  10786. /**
  10787. * Registers the component in a given scene
  10788. */
  10789. register(): void;
  10790. /**
  10791. * Rebuilds the elements related to this component in case of
  10792. * context lost for instance.
  10793. */
  10794. rebuild(): void;
  10795. /**
  10796. * Disposes the component and the associated ressources.
  10797. */
  10798. dispose(): void;
  10799. private _pickSpriteButKeepRay;
  10800. private _pointerMove;
  10801. private _pointerDown;
  10802. private _pointerUp;
  10803. }
  10804. }
  10805. declare module BABYLON {
  10806. /** @hidden */
  10807. export var fogFragmentDeclaration: {
  10808. name: string;
  10809. shader: string;
  10810. };
  10811. }
  10812. declare module BABYLON {
  10813. /** @hidden */
  10814. export var fogFragment: {
  10815. name: string;
  10816. shader: string;
  10817. };
  10818. }
  10819. declare module BABYLON {
  10820. /** @hidden */
  10821. export var spritesPixelShader: {
  10822. name: string;
  10823. shader: string;
  10824. };
  10825. }
  10826. declare module BABYLON {
  10827. /** @hidden */
  10828. export var fogVertexDeclaration: {
  10829. name: string;
  10830. shader: string;
  10831. };
  10832. }
  10833. declare module BABYLON {
  10834. /** @hidden */
  10835. export var spritesVertexShader: {
  10836. name: string;
  10837. shader: string;
  10838. };
  10839. }
  10840. declare module BABYLON {
  10841. /**
  10842. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10843. */
  10844. export interface ISpriteManager extends IDisposable {
  10845. /**
  10846. * Gets manager's name
  10847. */
  10848. name: string;
  10849. /**
  10850. * Restricts the camera to viewing objects with the same layerMask.
  10851. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10852. */
  10853. layerMask: number;
  10854. /**
  10855. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10856. */
  10857. isPickable: boolean;
  10858. /**
  10859. * Gets the hosting scene
  10860. */
  10861. scene: Scene;
  10862. /**
  10863. * Specifies the rendering group id for this mesh (0 by default)
  10864. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10865. */
  10866. renderingGroupId: number;
  10867. /**
  10868. * Defines the list of sprites managed by the manager.
  10869. */
  10870. sprites: Array<Sprite>;
  10871. /**
  10872. * Gets or sets the spritesheet texture
  10873. */
  10874. texture: Texture;
  10875. /** Defines the default width of a cell in the spritesheet */
  10876. cellWidth: number;
  10877. /** Defines the default height of a cell in the spritesheet */
  10878. cellHeight: number;
  10879. /**
  10880. * Tests the intersection of a sprite with a specific ray.
  10881. * @param ray The ray we are sending to test the collision
  10882. * @param camera The camera space we are sending rays in
  10883. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10884. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10885. * @returns picking info or null.
  10886. */
  10887. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10888. /**
  10889. * Intersects the sprites with a ray
  10890. * @param ray defines the ray to intersect with
  10891. * @param camera defines the current active camera
  10892. * @param predicate defines a predicate used to select candidate sprites
  10893. * @returns null if no hit or a PickingInfo array
  10894. */
  10895. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10896. /**
  10897. * Renders the list of sprites on screen.
  10898. */
  10899. render(): void;
  10900. }
  10901. /**
  10902. * Class used to manage multiple sprites on the same spritesheet
  10903. * @see http://doc.babylonjs.com/babylon101/sprites
  10904. */
  10905. export class SpriteManager implements ISpriteManager {
  10906. /** defines the manager's name */
  10907. name: string;
  10908. /** Define the Url to load snippets */
  10909. static SnippetUrl: string;
  10910. /** Snippet ID if the manager was created from the snippet server */
  10911. snippetId: string;
  10912. /** Gets the list of sprites */
  10913. sprites: Sprite[];
  10914. /** Gets or sets the rendering group id (0 by default) */
  10915. renderingGroupId: number;
  10916. /** Gets or sets camera layer mask */
  10917. layerMask: number;
  10918. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10919. fogEnabled: boolean;
  10920. /** Gets or sets a boolean indicating if the sprites are pickable */
  10921. isPickable: boolean;
  10922. /** Defines the default width of a cell in the spritesheet */
  10923. cellWidth: number;
  10924. /** Defines the default height of a cell in the spritesheet */
  10925. cellHeight: number;
  10926. /** Associative array from JSON sprite data file */
  10927. private _cellData;
  10928. /** Array of sprite names from JSON sprite data file */
  10929. private _spriteMap;
  10930. /** True when packed cell data from JSON file is ready*/
  10931. private _packedAndReady;
  10932. private _textureContent;
  10933. /**
  10934. * An event triggered when the manager is disposed.
  10935. */
  10936. onDisposeObservable: Observable<SpriteManager>;
  10937. private _onDisposeObserver;
  10938. /**
  10939. * Callback called when the manager is disposed
  10940. */
  10941. set onDispose(callback: () => void);
  10942. private _capacity;
  10943. private _fromPacked;
  10944. private _spriteTexture;
  10945. private _epsilon;
  10946. private _scene;
  10947. private _vertexData;
  10948. private _buffer;
  10949. private _vertexBuffers;
  10950. private _indexBuffer;
  10951. private _effectBase;
  10952. private _effectFog;
  10953. /**
  10954. * Gets or sets the unique id of the sprite
  10955. */
  10956. uniqueId: number;
  10957. /**
  10958. * Gets the array of sprites
  10959. */
  10960. get children(): Sprite[];
  10961. /**
  10962. * Gets the hosting scene
  10963. */
  10964. get scene(): Scene;
  10965. /**
  10966. * Gets the capacity of the manager
  10967. */
  10968. get capacity(): number;
  10969. /**
  10970. * Gets or sets the spritesheet texture
  10971. */
  10972. get texture(): Texture;
  10973. set texture(value: Texture);
  10974. private _blendMode;
  10975. /**
  10976. * Blend mode use to render the particle, it can be any of
  10977. * the static Constants.ALPHA_x properties provided in this class.
  10978. * Default value is Constants.ALPHA_COMBINE
  10979. */
  10980. get blendMode(): number;
  10981. set blendMode(blendMode: number);
  10982. /** Disables writing to the depth buffer when rendering the sprites.
  10983. * It can be handy to disable depth writing when using textures without alpha channel
  10984. * and setting some specific blend modes.
  10985. */
  10986. disableDepthWrite: boolean;
  10987. /**
  10988. * Creates a new sprite manager
  10989. * @param name defines the manager's name
  10990. * @param imgUrl defines the sprite sheet url
  10991. * @param capacity defines the maximum allowed number of sprites
  10992. * @param cellSize defines the size of a sprite cell
  10993. * @param scene defines the hosting scene
  10994. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10995. * @param samplingMode defines the smapling mode to use with spritesheet
  10996. * @param fromPacked set to false; do not alter
  10997. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10998. */
  10999. constructor(
  11000. /** defines the manager's name */
  11001. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11002. /**
  11003. * Returns the string "SpriteManager"
  11004. * @returns "SpriteManager"
  11005. */
  11006. getClassName(): string;
  11007. private _makePacked;
  11008. private _appendSpriteVertex;
  11009. private _checkTextureAlpha;
  11010. /**
  11011. * Intersects the sprites with a ray
  11012. * @param ray defines the ray to intersect with
  11013. * @param camera defines the current active camera
  11014. * @param predicate defines a predicate used to select candidate sprites
  11015. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11016. * @returns null if no hit or a PickingInfo
  11017. */
  11018. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11019. /**
  11020. * Intersects the sprites with a ray
  11021. * @param ray defines the ray to intersect with
  11022. * @param camera defines the current active camera
  11023. * @param predicate defines a predicate used to select candidate sprites
  11024. * @returns null if no hit or a PickingInfo array
  11025. */
  11026. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11027. /**
  11028. * Render all child sprites
  11029. */
  11030. render(): void;
  11031. /**
  11032. * Release associated resources
  11033. */
  11034. dispose(): void;
  11035. /**
  11036. * Serializes the sprite manager to a JSON object
  11037. * @param serializeTexture defines if the texture must be serialized as well
  11038. * @returns the JSON object
  11039. */
  11040. serialize(serializeTexture?: boolean): any;
  11041. /**
  11042. * Parses a JSON object to create a new sprite manager.
  11043. * @param parsedManager The JSON object to parse
  11044. * @param scene The scene to create the sprite managerin
  11045. * @param rootUrl The root url to use to load external dependencies like texture
  11046. * @returns the new sprite manager
  11047. */
  11048. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11049. /**
  11050. * Creates a sprite manager from a snippet saved in a remote file
  11051. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11052. * @param url defines the url to load from
  11053. * @param scene defines the hosting scene
  11054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11055. * @returns a promise that will resolve to the new sprite manager
  11056. */
  11057. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11058. /**
  11059. * Creates a sprite manager from a snippet saved by the sprite editor
  11060. * @param snippetId defines the snippet to load
  11061. * @param scene defines the hosting scene
  11062. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11063. * @returns a promise that will resolve to the new sprite manager
  11064. */
  11065. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11066. }
  11067. }
  11068. declare module BABYLON {
  11069. /** Interface used by value gradients (color, factor, ...) */
  11070. export interface IValueGradient {
  11071. /**
  11072. * Gets or sets the gradient value (between 0 and 1)
  11073. */
  11074. gradient: number;
  11075. }
  11076. /** Class used to store color4 gradient */
  11077. export class ColorGradient implements IValueGradient {
  11078. /**
  11079. * Gets or sets the gradient value (between 0 and 1)
  11080. */
  11081. gradient: number;
  11082. /**
  11083. * Gets or sets first associated color
  11084. */
  11085. color1: Color4;
  11086. /**
  11087. * Gets or sets second associated color
  11088. */
  11089. color2?: Color4 | undefined;
  11090. /**
  11091. * Creates a new color4 gradient
  11092. * @param gradient gets or sets the gradient value (between 0 and 1)
  11093. * @param color1 gets or sets first associated color
  11094. * @param color2 gets or sets first second color
  11095. */
  11096. constructor(
  11097. /**
  11098. * Gets or sets the gradient value (between 0 and 1)
  11099. */
  11100. gradient: number,
  11101. /**
  11102. * Gets or sets first associated color
  11103. */
  11104. color1: Color4,
  11105. /**
  11106. * Gets or sets second associated color
  11107. */
  11108. color2?: Color4 | undefined);
  11109. /**
  11110. * Will get a color picked randomly between color1 and color2.
  11111. * If color2 is undefined then color1 will be used
  11112. * @param result defines the target Color4 to store the result in
  11113. */
  11114. getColorToRef(result: Color4): void;
  11115. }
  11116. /** Class used to store color 3 gradient */
  11117. export class Color3Gradient implements IValueGradient {
  11118. /**
  11119. * Gets or sets the gradient value (between 0 and 1)
  11120. */
  11121. gradient: number;
  11122. /**
  11123. * Gets or sets the associated color
  11124. */
  11125. color: Color3;
  11126. /**
  11127. * Creates a new color3 gradient
  11128. * @param gradient gets or sets the gradient value (between 0 and 1)
  11129. * @param color gets or sets associated color
  11130. */
  11131. constructor(
  11132. /**
  11133. * Gets or sets the gradient value (between 0 and 1)
  11134. */
  11135. gradient: number,
  11136. /**
  11137. * Gets or sets the associated color
  11138. */
  11139. color: Color3);
  11140. }
  11141. /** Class used to store factor gradient */
  11142. export class FactorGradient implements IValueGradient {
  11143. /**
  11144. * Gets or sets the gradient value (between 0 and 1)
  11145. */
  11146. gradient: number;
  11147. /**
  11148. * Gets or sets first associated factor
  11149. */
  11150. factor1: number;
  11151. /**
  11152. * Gets or sets second associated factor
  11153. */
  11154. factor2?: number | undefined;
  11155. /**
  11156. * Creates a new factor gradient
  11157. * @param gradient gets or sets the gradient value (between 0 and 1)
  11158. * @param factor1 gets or sets first associated factor
  11159. * @param factor2 gets or sets second associated factor
  11160. */
  11161. constructor(
  11162. /**
  11163. * Gets or sets the gradient value (between 0 and 1)
  11164. */
  11165. gradient: number,
  11166. /**
  11167. * Gets or sets first associated factor
  11168. */
  11169. factor1: number,
  11170. /**
  11171. * Gets or sets second associated factor
  11172. */
  11173. factor2?: number | undefined);
  11174. /**
  11175. * Will get a number picked randomly between factor1 and factor2.
  11176. * If factor2 is undefined then factor1 will be used
  11177. * @returns the picked number
  11178. */
  11179. getFactor(): number;
  11180. }
  11181. /**
  11182. * Helper used to simplify some generic gradient tasks
  11183. */
  11184. export class GradientHelper {
  11185. /**
  11186. * Gets the current gradient from an array of IValueGradient
  11187. * @param ratio defines the current ratio to get
  11188. * @param gradients defines the array of IValueGradient
  11189. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11190. */
  11191. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11192. }
  11193. }
  11194. declare module BABYLON {
  11195. interface ThinEngine {
  11196. /**
  11197. * Creates a raw texture
  11198. * @param data defines the data to store in the texture
  11199. * @param width defines the width of the texture
  11200. * @param height defines the height of the texture
  11201. * @param format defines the format of the data
  11202. * @param generateMipMaps defines if the engine should generate the mip levels
  11203. * @param invertY defines if data must be stored with Y axis inverted
  11204. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11205. * @param compression defines the compression used (null by default)
  11206. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11207. * @returns the raw texture inside an InternalTexture
  11208. */
  11209. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11210. /**
  11211. * Update a raw texture
  11212. * @param texture defines the texture to update
  11213. * @param data defines the data to store in the texture
  11214. * @param format defines the format of the data
  11215. * @param invertY defines if data must be stored with Y axis inverted
  11216. */
  11217. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11218. /**
  11219. * Update a raw texture
  11220. * @param texture defines the texture to update
  11221. * @param data defines the data to store in the texture
  11222. * @param format defines the format of the data
  11223. * @param invertY defines if data must be stored with Y axis inverted
  11224. * @param compression defines the compression used (null by default)
  11225. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11226. */
  11227. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11228. /**
  11229. * Creates a new raw cube texture
  11230. * @param data defines the array of data to use to create each face
  11231. * @param size defines the size of the textures
  11232. * @param format defines the format of the data
  11233. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11234. * @param generateMipMaps defines if the engine should generate the mip levels
  11235. * @param invertY defines if data must be stored with Y axis inverted
  11236. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11237. * @param compression defines the compression used (null by default)
  11238. * @returns the cube texture as an InternalTexture
  11239. */
  11240. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11241. /**
  11242. * Update a raw cube texture
  11243. * @param texture defines the texture to udpdate
  11244. * @param data defines the data to store
  11245. * @param format defines the data format
  11246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11247. * @param invertY defines if data must be stored with Y axis inverted
  11248. */
  11249. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11250. /**
  11251. * Update a raw cube texture
  11252. * @param texture defines the texture to udpdate
  11253. * @param data defines the data to store
  11254. * @param format defines the data format
  11255. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11256. * @param invertY defines if data must be stored with Y axis inverted
  11257. * @param compression defines the compression used (null by default)
  11258. */
  11259. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11260. /**
  11261. * Update a raw cube texture
  11262. * @param texture defines the texture to udpdate
  11263. * @param data defines the data to store
  11264. * @param format defines the data format
  11265. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11266. * @param invertY defines if data must be stored with Y axis inverted
  11267. * @param compression defines the compression used (null by default)
  11268. * @param level defines which level of the texture to update
  11269. */
  11270. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11271. /**
  11272. * Creates a new raw cube texture from a specified url
  11273. * @param url defines the url where the data is located
  11274. * @param scene defines the current scene
  11275. * @param size defines the size of the textures
  11276. * @param format defines the format of the data
  11277. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11278. * @param noMipmap defines if the engine should avoid generating the mip levels
  11279. * @param callback defines a callback used to extract texture data from loaded data
  11280. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11281. * @param onLoad defines a callback called when texture is loaded
  11282. * @param onError defines a callback called if there is an error
  11283. * @returns the cube texture as an InternalTexture
  11284. */
  11285. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11286. /**
  11287. * Creates a new raw cube texture from a specified url
  11288. * @param url defines the url where the data is located
  11289. * @param scene defines the current scene
  11290. * @param size defines the size of the textures
  11291. * @param format defines the format of the data
  11292. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11293. * @param noMipmap defines if the engine should avoid generating the mip levels
  11294. * @param callback defines a callback used to extract texture data from loaded data
  11295. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11296. * @param onLoad defines a callback called when texture is loaded
  11297. * @param onError defines a callback called if there is an error
  11298. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11299. * @param invertY defines if data must be stored with Y axis inverted
  11300. * @returns the cube texture as an InternalTexture
  11301. */
  11302. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11303. /**
  11304. * Creates a new raw 3D texture
  11305. * @param data defines the data used to create the texture
  11306. * @param width defines the width of the texture
  11307. * @param height defines the height of the texture
  11308. * @param depth defines the depth of the texture
  11309. * @param format defines the format of the texture
  11310. * @param generateMipMaps defines if the engine must generate mip levels
  11311. * @param invertY defines if data must be stored with Y axis inverted
  11312. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11313. * @param compression defines the compressed used (can be null)
  11314. * @param textureType defines the compressed used (can be null)
  11315. * @returns a new raw 3D texture (stored in an InternalTexture)
  11316. */
  11317. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11318. /**
  11319. * Update a raw 3D texture
  11320. * @param texture defines the texture to update
  11321. * @param data defines the data to store
  11322. * @param format defines the data format
  11323. * @param invertY defines if data must be stored with Y axis inverted
  11324. */
  11325. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11326. /**
  11327. * Update a raw 3D texture
  11328. * @param texture defines the texture to update
  11329. * @param data defines the data to store
  11330. * @param format defines the data format
  11331. * @param invertY defines if data must be stored with Y axis inverted
  11332. * @param compression defines the used compression (can be null)
  11333. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11334. */
  11335. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11336. /**
  11337. * Creates a new raw 2D array texture
  11338. * @param data defines the data used to create the texture
  11339. * @param width defines the width of the texture
  11340. * @param height defines the height of the texture
  11341. * @param depth defines the number of layers of the texture
  11342. * @param format defines the format of the texture
  11343. * @param generateMipMaps defines if the engine must generate mip levels
  11344. * @param invertY defines if data must be stored with Y axis inverted
  11345. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11346. * @param compression defines the compressed used (can be null)
  11347. * @param textureType defines the compressed used (can be null)
  11348. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11349. */
  11350. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11351. /**
  11352. * Update a raw 2D array texture
  11353. * @param texture defines the texture to update
  11354. * @param data defines the data to store
  11355. * @param format defines the data format
  11356. * @param invertY defines if data must be stored with Y axis inverted
  11357. */
  11358. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11359. /**
  11360. * Update a raw 2D array texture
  11361. * @param texture defines the texture to update
  11362. * @param data defines the data to store
  11363. * @param format defines the data format
  11364. * @param invertY defines if data must be stored with Y axis inverted
  11365. * @param compression defines the used compression (can be null)
  11366. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11367. */
  11368. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11369. }
  11370. }
  11371. declare module BABYLON {
  11372. /**
  11373. * Raw texture can help creating a texture directly from an array of data.
  11374. * This can be super useful if you either get the data from an uncompressed source or
  11375. * if you wish to create your texture pixel by pixel.
  11376. */
  11377. export class RawTexture extends Texture {
  11378. /**
  11379. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11380. */
  11381. format: number;
  11382. /**
  11383. * Instantiates a new RawTexture.
  11384. * Raw texture can help creating a texture directly from an array of data.
  11385. * This can be super useful if you either get the data from an uncompressed source or
  11386. * if you wish to create your texture pixel by pixel.
  11387. * @param data define the array of data to use to create the texture
  11388. * @param width define the width of the texture
  11389. * @param height define the height of the texture
  11390. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11391. * @param scene define the scene the texture belongs to
  11392. * @param generateMipMaps define whether mip maps should be generated or not
  11393. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11394. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11395. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11396. */
  11397. constructor(data: ArrayBufferView, width: number, height: number,
  11398. /**
  11399. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11400. */
  11401. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11402. /**
  11403. * Updates the texture underlying data.
  11404. * @param data Define the new data of the texture
  11405. */
  11406. update(data: ArrayBufferView): void;
  11407. /**
  11408. * Creates a luminance texture from some data.
  11409. * @param data Define the texture data
  11410. * @param width Define the width of the texture
  11411. * @param height Define the height of the texture
  11412. * @param scene Define the scene the texture belongs to
  11413. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11414. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11415. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11416. * @returns the luminance texture
  11417. */
  11418. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11419. /**
  11420. * Creates a luminance alpha texture from some data.
  11421. * @param data Define the texture data
  11422. * @param width Define the width of the texture
  11423. * @param height Define the height of the texture
  11424. * @param scene Define the scene the texture belongs to
  11425. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11426. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11427. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11428. * @returns the luminance alpha texture
  11429. */
  11430. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11431. /**
  11432. * Creates an alpha texture from some data.
  11433. * @param data Define the texture data
  11434. * @param width Define the width of the texture
  11435. * @param height Define the height of the texture
  11436. * @param scene Define the scene the texture belongs to
  11437. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11438. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11439. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11440. * @returns the alpha texture
  11441. */
  11442. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11443. /**
  11444. * Creates a RGB texture from some data.
  11445. * @param data Define the texture data
  11446. * @param width Define the width of the texture
  11447. * @param height Define the height of the texture
  11448. * @param scene Define the scene the texture belongs to
  11449. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11450. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11451. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11452. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11453. * @returns the RGB alpha texture
  11454. */
  11455. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11456. /**
  11457. * Creates a RGBA texture from some data.
  11458. * @param data Define the texture data
  11459. * @param width Define the width of the texture
  11460. * @param height Define the height of the texture
  11461. * @param scene Define the scene the texture belongs to
  11462. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11463. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11464. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11465. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11466. * @returns the RGBA texture
  11467. */
  11468. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11469. /**
  11470. * Creates a R texture from some data.
  11471. * @param data Define the texture data
  11472. * @param width Define the width of the texture
  11473. * @param height Define the height of the texture
  11474. * @param scene Define the scene the texture belongs to
  11475. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11476. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11477. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11478. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11479. * @returns the R texture
  11480. */
  11481. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11482. }
  11483. }
  11484. declare module BABYLON {
  11485. interface AbstractScene {
  11486. /**
  11487. * The list of procedural textures added to the scene
  11488. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11489. */
  11490. proceduralTextures: Array<ProceduralTexture>;
  11491. }
  11492. /**
  11493. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11494. * in a given scene.
  11495. */
  11496. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11497. /**
  11498. * The component name helpfull to identify the component in the list of scene components.
  11499. */
  11500. readonly name: string;
  11501. /**
  11502. * The scene the component belongs to.
  11503. */
  11504. scene: Scene;
  11505. /**
  11506. * Creates a new instance of the component for the given scene
  11507. * @param scene Defines the scene to register the component in
  11508. */
  11509. constructor(scene: Scene);
  11510. /**
  11511. * Registers the component in a given scene
  11512. */
  11513. register(): void;
  11514. /**
  11515. * Rebuilds the elements related to this component in case of
  11516. * context lost for instance.
  11517. */
  11518. rebuild(): void;
  11519. /**
  11520. * Disposes the component and the associated ressources.
  11521. */
  11522. dispose(): void;
  11523. private _beforeClear;
  11524. }
  11525. }
  11526. declare module BABYLON {
  11527. interface ThinEngine {
  11528. /**
  11529. * Creates a new render target cube texture
  11530. * @param size defines the size of the texture
  11531. * @param options defines the options used to create the texture
  11532. * @returns a new render target cube texture stored in an InternalTexture
  11533. */
  11534. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11535. }
  11536. }
  11537. declare module BABYLON {
  11538. /** @hidden */
  11539. export var proceduralVertexShader: {
  11540. name: string;
  11541. shader: string;
  11542. };
  11543. }
  11544. declare module BABYLON {
  11545. /**
  11546. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11547. * This is the base class of any Procedural texture and contains most of the shareable code.
  11548. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11549. */
  11550. export class ProceduralTexture extends Texture {
  11551. isCube: boolean;
  11552. /**
  11553. * Define if the texture is enabled or not (disabled texture will not render)
  11554. */
  11555. isEnabled: boolean;
  11556. /**
  11557. * Define if the texture must be cleared before rendering (default is true)
  11558. */
  11559. autoClear: boolean;
  11560. /**
  11561. * Callback called when the texture is generated
  11562. */
  11563. onGenerated: () => void;
  11564. /**
  11565. * Event raised when the texture is generated
  11566. */
  11567. onGeneratedObservable: Observable<ProceduralTexture>;
  11568. /** @hidden */
  11569. _generateMipMaps: boolean;
  11570. /** @hidden **/
  11571. _effect: Effect;
  11572. /** @hidden */
  11573. _textures: {
  11574. [key: string]: Texture;
  11575. };
  11576. /** @hidden */
  11577. protected _fallbackTexture: Nullable<Texture>;
  11578. private _size;
  11579. private _currentRefreshId;
  11580. private _frameId;
  11581. private _refreshRate;
  11582. private _vertexBuffers;
  11583. private _indexBuffer;
  11584. private _uniforms;
  11585. private _samplers;
  11586. private _fragment;
  11587. private _floats;
  11588. private _ints;
  11589. private _floatsArrays;
  11590. private _colors3;
  11591. private _colors4;
  11592. private _vectors2;
  11593. private _vectors3;
  11594. private _matrices;
  11595. private _fallbackTextureUsed;
  11596. private _fullEngine;
  11597. private _cachedDefines;
  11598. private _contentUpdateId;
  11599. private _contentData;
  11600. /**
  11601. * Instantiates a new procedural texture.
  11602. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11603. * This is the base class of any Procedural texture and contains most of the shareable code.
  11604. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11605. * @param name Define the name of the texture
  11606. * @param size Define the size of the texture to create
  11607. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11608. * @param scene Define the scene the texture belongs to
  11609. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11610. * @param generateMipMaps Define if the texture should creates mip maps or not
  11611. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11612. */
  11613. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11614. /**
  11615. * The effect that is created when initializing the post process.
  11616. * @returns The created effect corresponding the the postprocess.
  11617. */
  11618. getEffect(): Effect;
  11619. /**
  11620. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11621. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11622. */
  11623. getContent(): Nullable<ArrayBufferView>;
  11624. private _createIndexBuffer;
  11625. /** @hidden */
  11626. _rebuild(): void;
  11627. /**
  11628. * Resets the texture in order to recreate its associated resources.
  11629. * This can be called in case of context loss
  11630. */
  11631. reset(): void;
  11632. protected _getDefines(): string;
  11633. /**
  11634. * Is the texture ready to be used ? (rendered at least once)
  11635. * @returns true if ready, otherwise, false.
  11636. */
  11637. isReady(): boolean;
  11638. /**
  11639. * Resets the refresh counter of the texture and start bak from scratch.
  11640. * Could be useful to regenerate the texture if it is setup to render only once.
  11641. */
  11642. resetRefreshCounter(): void;
  11643. /**
  11644. * Set the fragment shader to use in order to render the texture.
  11645. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11646. */
  11647. setFragment(fragment: any): void;
  11648. /**
  11649. * Define the refresh rate of the texture or the rendering frequency.
  11650. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11651. */
  11652. get refreshRate(): number;
  11653. set refreshRate(value: number);
  11654. /** @hidden */
  11655. _shouldRender(): boolean;
  11656. /**
  11657. * Get the size the texture is rendering at.
  11658. * @returns the size (texture is always squared)
  11659. */
  11660. getRenderSize(): number;
  11661. /**
  11662. * Resize the texture to new value.
  11663. * @param size Define the new size the texture should have
  11664. * @param generateMipMaps Define whether the new texture should create mip maps
  11665. */
  11666. resize(size: number, generateMipMaps: boolean): void;
  11667. private _checkUniform;
  11668. /**
  11669. * Set a texture in the shader program used to render.
  11670. * @param name Define the name of the uniform samplers as defined in the shader
  11671. * @param texture Define the texture to bind to this sampler
  11672. * @return the texture itself allowing "fluent" like uniform updates
  11673. */
  11674. setTexture(name: string, texture: Texture): ProceduralTexture;
  11675. /**
  11676. * Set a float in the shader.
  11677. * @param name Define the name of the uniform as defined in the shader
  11678. * @param value Define the value to give to the uniform
  11679. * @return the texture itself allowing "fluent" like uniform updates
  11680. */
  11681. setFloat(name: string, value: number): ProceduralTexture;
  11682. /**
  11683. * Set a int in the shader.
  11684. * @param name Define the name of the uniform as defined in the shader
  11685. * @param value Define the value to give to the uniform
  11686. * @return the texture itself allowing "fluent" like uniform updates
  11687. */
  11688. setInt(name: string, value: number): ProceduralTexture;
  11689. /**
  11690. * Set an array of floats in the shader.
  11691. * @param name Define the name of the uniform as defined in the shader
  11692. * @param value Define the value to give to the uniform
  11693. * @return the texture itself allowing "fluent" like uniform updates
  11694. */
  11695. setFloats(name: string, value: number[]): ProceduralTexture;
  11696. /**
  11697. * Set a vec3 in the shader from a Color3.
  11698. * @param name Define the name of the uniform as defined in the shader
  11699. * @param value Define the value to give to the uniform
  11700. * @return the texture itself allowing "fluent" like uniform updates
  11701. */
  11702. setColor3(name: string, value: Color3): ProceduralTexture;
  11703. /**
  11704. * Set a vec4 in the shader from a Color4.
  11705. * @param name Define the name of the uniform as defined in the shader
  11706. * @param value Define the value to give to the uniform
  11707. * @return the texture itself allowing "fluent" like uniform updates
  11708. */
  11709. setColor4(name: string, value: Color4): ProceduralTexture;
  11710. /**
  11711. * Set a vec2 in the shader from a Vector2.
  11712. * @param name Define the name of the uniform as defined in the shader
  11713. * @param value Define the value to give to the uniform
  11714. * @return the texture itself allowing "fluent" like uniform updates
  11715. */
  11716. setVector2(name: string, value: Vector2): ProceduralTexture;
  11717. /**
  11718. * Set a vec3 in the shader from a Vector3.
  11719. * @param name Define the name of the uniform as defined in the shader
  11720. * @param value Define the value to give to the uniform
  11721. * @return the texture itself allowing "fluent" like uniform updates
  11722. */
  11723. setVector3(name: string, value: Vector3): ProceduralTexture;
  11724. /**
  11725. * Set a mat4 in the shader from a MAtrix.
  11726. * @param name Define the name of the uniform as defined in the shader
  11727. * @param value Define the value to give to the uniform
  11728. * @return the texture itself allowing "fluent" like uniform updates
  11729. */
  11730. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11731. /**
  11732. * Render the texture to its associated render target.
  11733. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11734. */
  11735. render(useCameraPostProcess?: boolean): void;
  11736. /**
  11737. * Clone the texture.
  11738. * @returns the cloned texture
  11739. */
  11740. clone(): ProceduralTexture;
  11741. /**
  11742. * Dispose the texture and release its asoociated resources.
  11743. */
  11744. dispose(): void;
  11745. }
  11746. }
  11747. declare module BABYLON {
  11748. /**
  11749. * This represents the base class for particle system in Babylon.
  11750. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11751. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11752. * @example https://doc.babylonjs.com/babylon101/particles
  11753. */
  11754. export class BaseParticleSystem {
  11755. /**
  11756. * Source color is added to the destination color without alpha affecting the result
  11757. */
  11758. static BLENDMODE_ONEONE: number;
  11759. /**
  11760. * Blend current color and particle color using particle’s alpha
  11761. */
  11762. static BLENDMODE_STANDARD: number;
  11763. /**
  11764. * Add current color and particle color multiplied by particle’s alpha
  11765. */
  11766. static BLENDMODE_ADD: number;
  11767. /**
  11768. * Multiply current color with particle color
  11769. */
  11770. static BLENDMODE_MULTIPLY: number;
  11771. /**
  11772. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11773. */
  11774. static BLENDMODE_MULTIPLYADD: number;
  11775. /**
  11776. * List of animations used by the particle system.
  11777. */
  11778. animations: Animation[];
  11779. /**
  11780. * Gets or sets the unique id of the particle system
  11781. */
  11782. uniqueId: number;
  11783. /**
  11784. * The id of the Particle system.
  11785. */
  11786. id: string;
  11787. /**
  11788. * The friendly name of the Particle system.
  11789. */
  11790. name: string;
  11791. /**
  11792. * Snippet ID if the particle system was created from the snippet server
  11793. */
  11794. snippetId: string;
  11795. /**
  11796. * The rendering group used by the Particle system to chose when to render.
  11797. */
  11798. renderingGroupId: number;
  11799. /**
  11800. * The emitter represents the Mesh or position we are attaching the particle system to.
  11801. */
  11802. emitter: Nullable<AbstractMesh | Vector3>;
  11803. /**
  11804. * The maximum number of particles to emit per frame
  11805. */
  11806. emitRate: number;
  11807. /**
  11808. * If you want to launch only a few particles at once, that can be done, as well.
  11809. */
  11810. manualEmitCount: number;
  11811. /**
  11812. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11813. */
  11814. updateSpeed: number;
  11815. /**
  11816. * The amount of time the particle system is running (depends of the overall update speed).
  11817. */
  11818. targetStopDuration: number;
  11819. /**
  11820. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11821. */
  11822. disposeOnStop: boolean;
  11823. /**
  11824. * Minimum power of emitting particles.
  11825. */
  11826. minEmitPower: number;
  11827. /**
  11828. * Maximum power of emitting particles.
  11829. */
  11830. maxEmitPower: number;
  11831. /**
  11832. * Minimum life time of emitting particles.
  11833. */
  11834. minLifeTime: number;
  11835. /**
  11836. * Maximum life time of emitting particles.
  11837. */
  11838. maxLifeTime: number;
  11839. /**
  11840. * Minimum Size of emitting particles.
  11841. */
  11842. minSize: number;
  11843. /**
  11844. * Maximum Size of emitting particles.
  11845. */
  11846. maxSize: number;
  11847. /**
  11848. * Minimum scale of emitting particles on X axis.
  11849. */
  11850. minScaleX: number;
  11851. /**
  11852. * Maximum scale of emitting particles on X axis.
  11853. */
  11854. maxScaleX: number;
  11855. /**
  11856. * Minimum scale of emitting particles on Y axis.
  11857. */
  11858. minScaleY: number;
  11859. /**
  11860. * Maximum scale of emitting particles on Y axis.
  11861. */
  11862. maxScaleY: number;
  11863. /**
  11864. * Gets or sets the minimal initial rotation in radians.
  11865. */
  11866. minInitialRotation: number;
  11867. /**
  11868. * Gets or sets the maximal initial rotation in radians.
  11869. */
  11870. maxInitialRotation: number;
  11871. /**
  11872. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11873. */
  11874. minAngularSpeed: number;
  11875. /**
  11876. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11877. */
  11878. maxAngularSpeed: number;
  11879. /**
  11880. * The texture used to render each particle. (this can be a spritesheet)
  11881. */
  11882. particleTexture: Nullable<Texture>;
  11883. /**
  11884. * The layer mask we are rendering the particles through.
  11885. */
  11886. layerMask: number;
  11887. /**
  11888. * This can help using your own shader to render the particle system.
  11889. * The according effect will be created
  11890. */
  11891. customShader: any;
  11892. /**
  11893. * By default particle system starts as soon as they are created. This prevents the
  11894. * automatic start to happen and let you decide when to start emitting particles.
  11895. */
  11896. preventAutoStart: boolean;
  11897. private _noiseTexture;
  11898. /**
  11899. * Gets or sets a texture used to add random noise to particle positions
  11900. */
  11901. get noiseTexture(): Nullable<ProceduralTexture>;
  11902. set noiseTexture(value: Nullable<ProceduralTexture>);
  11903. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11904. noiseStrength: Vector3;
  11905. /**
  11906. * Callback triggered when the particle animation is ending.
  11907. */
  11908. onAnimationEnd: Nullable<() => void>;
  11909. /**
  11910. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11911. */
  11912. blendMode: number;
  11913. /**
  11914. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11915. * to override the particles.
  11916. */
  11917. forceDepthWrite: boolean;
  11918. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11919. preWarmCycles: number;
  11920. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11921. preWarmStepOffset: number;
  11922. /**
  11923. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11924. */
  11925. spriteCellChangeSpeed: number;
  11926. /**
  11927. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11928. */
  11929. startSpriteCellID: number;
  11930. /**
  11931. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11932. */
  11933. endSpriteCellID: number;
  11934. /**
  11935. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11936. */
  11937. spriteCellWidth: number;
  11938. /**
  11939. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11940. */
  11941. spriteCellHeight: number;
  11942. /**
  11943. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11944. */
  11945. spriteRandomStartCell: boolean;
  11946. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11947. translationPivot: Vector2;
  11948. /** @hidden */
  11949. protected _isAnimationSheetEnabled: boolean;
  11950. /**
  11951. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11952. */
  11953. beginAnimationOnStart: boolean;
  11954. /**
  11955. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11956. */
  11957. beginAnimationFrom: number;
  11958. /**
  11959. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11960. */
  11961. beginAnimationTo: number;
  11962. /**
  11963. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11964. */
  11965. beginAnimationLoop: boolean;
  11966. /**
  11967. * Gets or sets a world offset applied to all particles
  11968. */
  11969. worldOffset: Vector3;
  11970. /**
  11971. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11972. */
  11973. get isAnimationSheetEnabled(): boolean;
  11974. set isAnimationSheetEnabled(value: boolean);
  11975. /**
  11976. * Get hosting scene
  11977. * @returns the scene
  11978. */
  11979. getScene(): Scene;
  11980. /**
  11981. * You can use gravity if you want to give an orientation to your particles.
  11982. */
  11983. gravity: Vector3;
  11984. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11985. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11986. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11987. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11988. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11989. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11990. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11991. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11992. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11993. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11994. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11995. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11996. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11997. /**
  11998. * Defines the delay in milliseconds before starting the system (0 by default)
  11999. */
  12000. startDelay: number;
  12001. /**
  12002. * Gets the current list of drag gradients.
  12003. * You must use addDragGradient and removeDragGradient to udpate this list
  12004. * @returns the list of drag gradients
  12005. */
  12006. getDragGradients(): Nullable<Array<FactorGradient>>;
  12007. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12008. limitVelocityDamping: number;
  12009. /**
  12010. * Gets the current list of limit velocity gradients.
  12011. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12012. * @returns the list of limit velocity gradients
  12013. */
  12014. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12015. /**
  12016. * Gets the current list of color gradients.
  12017. * You must use addColorGradient and removeColorGradient to udpate this list
  12018. * @returns the list of color gradients
  12019. */
  12020. getColorGradients(): Nullable<Array<ColorGradient>>;
  12021. /**
  12022. * Gets the current list of size gradients.
  12023. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12024. * @returns the list of size gradients
  12025. */
  12026. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12027. /**
  12028. * Gets the current list of color remap gradients.
  12029. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12030. * @returns the list of color remap gradients
  12031. */
  12032. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12033. /**
  12034. * Gets the current list of alpha remap gradients.
  12035. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12036. * @returns the list of alpha remap gradients
  12037. */
  12038. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12039. /**
  12040. * Gets the current list of life time gradients.
  12041. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12042. * @returns the list of life time gradients
  12043. */
  12044. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12045. /**
  12046. * Gets the current list of angular speed gradients.
  12047. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12048. * @returns the list of angular speed gradients
  12049. */
  12050. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12051. /**
  12052. * Gets the current list of velocity gradients.
  12053. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12054. * @returns the list of velocity gradients
  12055. */
  12056. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12057. /**
  12058. * Gets the current list of start size gradients.
  12059. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12060. * @returns the list of start size gradients
  12061. */
  12062. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12063. /**
  12064. * Gets the current list of emit rate gradients.
  12065. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12066. * @returns the list of emit rate gradients
  12067. */
  12068. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12069. /**
  12070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12071. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12072. */
  12073. get direction1(): Vector3;
  12074. set direction1(value: Vector3);
  12075. /**
  12076. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12077. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12078. */
  12079. get direction2(): Vector3;
  12080. set direction2(value: Vector3);
  12081. /**
  12082. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12083. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12084. */
  12085. get minEmitBox(): Vector3;
  12086. set minEmitBox(value: Vector3);
  12087. /**
  12088. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12089. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12090. */
  12091. get maxEmitBox(): Vector3;
  12092. set maxEmitBox(value: Vector3);
  12093. /**
  12094. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12095. */
  12096. color1: Color4;
  12097. /**
  12098. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12099. */
  12100. color2: Color4;
  12101. /**
  12102. * Color the particle will have at the end of its lifetime
  12103. */
  12104. colorDead: Color4;
  12105. /**
  12106. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12107. */
  12108. textureMask: Color4;
  12109. /**
  12110. * The particle emitter type defines the emitter used by the particle system.
  12111. * It can be for example box, sphere, or cone...
  12112. */
  12113. particleEmitterType: IParticleEmitterType;
  12114. /** @hidden */
  12115. _isSubEmitter: boolean;
  12116. /**
  12117. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12118. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12119. */
  12120. billboardMode: number;
  12121. protected _isBillboardBased: boolean;
  12122. /**
  12123. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12124. */
  12125. get isBillboardBased(): boolean;
  12126. set isBillboardBased(value: boolean);
  12127. /**
  12128. * The scene the particle system belongs to.
  12129. */
  12130. protected _scene: Scene;
  12131. /**
  12132. * Local cache of defines for image processing.
  12133. */
  12134. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12135. /**
  12136. * Default configuration related to image processing available in the standard Material.
  12137. */
  12138. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12139. /**
  12140. * Gets the image processing configuration used either in this material.
  12141. */
  12142. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12143. /**
  12144. * Sets the Default image processing configuration used either in the this material.
  12145. *
  12146. * If sets to null, the scene one is in use.
  12147. */
  12148. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12149. /**
  12150. * Attaches a new image processing configuration to the Standard Material.
  12151. * @param configuration
  12152. */
  12153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12154. /** @hidden */
  12155. protected _reset(): void;
  12156. /** @hidden */
  12157. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12158. /**
  12159. * Instantiates a particle system.
  12160. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12161. * @param name The name of the particle system
  12162. */
  12163. constructor(name: string);
  12164. /**
  12165. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12166. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12167. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12168. * @returns the emitter
  12169. */
  12170. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12171. /**
  12172. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12173. * @param radius The radius of the hemisphere to emit from
  12174. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12175. * @returns the emitter
  12176. */
  12177. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12178. /**
  12179. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12180. * @param radius The radius of the sphere to emit from
  12181. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12182. * @returns the emitter
  12183. */
  12184. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12185. /**
  12186. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12187. * @param radius The radius of the sphere to emit from
  12188. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12189. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12190. * @returns the emitter
  12191. */
  12192. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12193. /**
  12194. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12195. * @param radius The radius of the emission cylinder
  12196. * @param height The height of the emission cylinder
  12197. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12198. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12199. * @returns the emitter
  12200. */
  12201. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12202. /**
  12203. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12204. * @param radius The radius of the cylinder to emit from
  12205. * @param height The height of the emission cylinder
  12206. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12209. * @returns the emitter
  12210. */
  12211. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12212. /**
  12213. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12214. * @param radius The radius of the cone to emit from
  12215. * @param angle The base angle of the cone
  12216. * @returns the emitter
  12217. */
  12218. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12219. /**
  12220. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12221. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12222. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12223. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12224. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12225. * @returns the emitter
  12226. */
  12227. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12228. }
  12229. }
  12230. declare module BABYLON {
  12231. /**
  12232. * Type of sub emitter
  12233. */
  12234. export enum SubEmitterType {
  12235. /**
  12236. * Attached to the particle over it's lifetime
  12237. */
  12238. ATTACHED = 0,
  12239. /**
  12240. * Created when the particle dies
  12241. */
  12242. END = 1
  12243. }
  12244. /**
  12245. * Sub emitter class used to emit particles from an existing particle
  12246. */
  12247. export class SubEmitter {
  12248. /**
  12249. * the particle system to be used by the sub emitter
  12250. */
  12251. particleSystem: ParticleSystem;
  12252. /**
  12253. * Type of the submitter (Default: END)
  12254. */
  12255. type: SubEmitterType;
  12256. /**
  12257. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12258. * Note: This only is supported when using an emitter of type Mesh
  12259. */
  12260. inheritDirection: boolean;
  12261. /**
  12262. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12263. */
  12264. inheritedVelocityAmount: number;
  12265. /**
  12266. * Creates a sub emitter
  12267. * @param particleSystem the particle system to be used by the sub emitter
  12268. */
  12269. constructor(
  12270. /**
  12271. * the particle system to be used by the sub emitter
  12272. */
  12273. particleSystem: ParticleSystem);
  12274. /**
  12275. * Clones the sub emitter
  12276. * @returns the cloned sub emitter
  12277. */
  12278. clone(): SubEmitter;
  12279. /**
  12280. * Serialize current object to a JSON object
  12281. * @returns the serialized object
  12282. */
  12283. serialize(): any;
  12284. /** @hidden */
  12285. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12286. /**
  12287. * Creates a new SubEmitter from a serialized JSON version
  12288. * @param serializationObject defines the JSON object to read from
  12289. * @param scene defines the hosting scene
  12290. * @param rootUrl defines the rootUrl for data loading
  12291. * @returns a new SubEmitter
  12292. */
  12293. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12294. /** Release associated resources */
  12295. dispose(): void;
  12296. }
  12297. }
  12298. declare module BABYLON {
  12299. /** @hidden */
  12300. export var imageProcessingDeclaration: {
  12301. name: string;
  12302. shader: string;
  12303. };
  12304. }
  12305. declare module BABYLON {
  12306. /** @hidden */
  12307. export var imageProcessingFunctions: {
  12308. name: string;
  12309. shader: string;
  12310. };
  12311. }
  12312. declare module BABYLON {
  12313. /** @hidden */
  12314. export var particlesPixelShader: {
  12315. name: string;
  12316. shader: string;
  12317. };
  12318. }
  12319. declare module BABYLON {
  12320. /** @hidden */
  12321. export var particlesVertexShader: {
  12322. name: string;
  12323. shader: string;
  12324. };
  12325. }
  12326. declare module BABYLON {
  12327. /**
  12328. * This represents a particle system in Babylon.
  12329. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12330. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12331. * @example https://doc.babylonjs.com/babylon101/particles
  12332. */
  12333. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12334. /**
  12335. * Billboard mode will only apply to Y axis
  12336. */
  12337. static readonly BILLBOARDMODE_Y: number;
  12338. /**
  12339. * Billboard mode will apply to all axes
  12340. */
  12341. static readonly BILLBOARDMODE_ALL: number;
  12342. /**
  12343. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12344. */
  12345. static readonly BILLBOARDMODE_STRETCHED: number;
  12346. /**
  12347. * This function can be defined to provide custom update for active particles.
  12348. * This function will be called instead of regular update (age, position, color, etc.).
  12349. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12350. */
  12351. updateFunction: (particles: Particle[]) => void;
  12352. private _emitterWorldMatrix;
  12353. /**
  12354. * This function can be defined to specify initial direction for every new particle.
  12355. * It by default use the emitterType defined function
  12356. */
  12357. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12358. /**
  12359. * This function can be defined to specify initial position for every new particle.
  12360. * It by default use the emitterType defined function
  12361. */
  12362. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12363. /**
  12364. * @hidden
  12365. */
  12366. _inheritedVelocityOffset: Vector3;
  12367. /**
  12368. * An event triggered when the system is disposed
  12369. */
  12370. onDisposeObservable: Observable<IParticleSystem>;
  12371. private _onDisposeObserver;
  12372. /**
  12373. * Sets a callback that will be triggered when the system is disposed
  12374. */
  12375. set onDispose(callback: () => void);
  12376. private _particles;
  12377. private _epsilon;
  12378. private _capacity;
  12379. private _stockParticles;
  12380. private _newPartsExcess;
  12381. private _vertexData;
  12382. private _vertexBuffer;
  12383. private _vertexBuffers;
  12384. private _spriteBuffer;
  12385. private _indexBuffer;
  12386. private _effect;
  12387. private _customEffect;
  12388. private _cachedDefines;
  12389. private _scaledColorStep;
  12390. private _colorDiff;
  12391. private _scaledDirection;
  12392. private _scaledGravity;
  12393. private _currentRenderId;
  12394. private _alive;
  12395. private _useInstancing;
  12396. private _started;
  12397. private _stopped;
  12398. private _actualFrame;
  12399. private _scaledUpdateSpeed;
  12400. private _vertexBufferSize;
  12401. /** @hidden */
  12402. _currentEmitRateGradient: Nullable<FactorGradient>;
  12403. /** @hidden */
  12404. _currentEmitRate1: number;
  12405. /** @hidden */
  12406. _currentEmitRate2: number;
  12407. /** @hidden */
  12408. _currentStartSizeGradient: Nullable<FactorGradient>;
  12409. /** @hidden */
  12410. _currentStartSize1: number;
  12411. /** @hidden */
  12412. _currentStartSize2: number;
  12413. private readonly _rawTextureWidth;
  12414. private _rampGradientsTexture;
  12415. private _useRampGradients;
  12416. /** Gets or sets a boolean indicating that ramp gradients must be used
  12417. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12418. */
  12419. get useRampGradients(): boolean;
  12420. set useRampGradients(value: boolean);
  12421. /**
  12422. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12423. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12424. */
  12425. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12426. private _subEmitters;
  12427. /**
  12428. * @hidden
  12429. * If the particle systems emitter should be disposed when the particle system is disposed
  12430. */
  12431. _disposeEmitterOnDispose: boolean;
  12432. /**
  12433. * The current active Sub-systems, this property is used by the root particle system only.
  12434. */
  12435. activeSubSystems: Array<ParticleSystem>;
  12436. /**
  12437. * Specifies if the particles are updated in emitter local space or world space
  12438. */
  12439. isLocal: boolean;
  12440. private _rootParticleSystem;
  12441. /**
  12442. * Gets the current list of active particles
  12443. */
  12444. get particles(): Particle[];
  12445. /**
  12446. * Gets the number of particles active at the same time.
  12447. * @returns The number of active particles.
  12448. */
  12449. getActiveCount(): number;
  12450. /**
  12451. * Returns the string "ParticleSystem"
  12452. * @returns a string containing the class name
  12453. */
  12454. getClassName(): string;
  12455. /**
  12456. * Gets a boolean indicating that the system is stopping
  12457. * @returns true if the system is currently stopping
  12458. */
  12459. isStopping(): boolean;
  12460. /**
  12461. * Gets the custom effect used to render the particles
  12462. * @param blendMode Blend mode for which the effect should be retrieved
  12463. * @returns The effect
  12464. */
  12465. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12466. /**
  12467. * Sets the custom effect used to render the particles
  12468. * @param effect The effect to set
  12469. * @param blendMode Blend mode for which the effect should be set
  12470. */
  12471. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12472. /** @hidden */
  12473. private _onBeforeDrawParticlesObservable;
  12474. /**
  12475. * Observable that will be called just before the particles are drawn
  12476. */
  12477. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12478. /**
  12479. * Gets the name of the particle vertex shader
  12480. */
  12481. get vertexShaderName(): string;
  12482. /**
  12483. * Instantiates a particle system.
  12484. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12485. * @param name The name of the particle system
  12486. * @param capacity The max number of particles alive at the same time
  12487. * @param scene The scene the particle system belongs to
  12488. * @param customEffect a custom effect used to change the way particles are rendered by default
  12489. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12490. * @param epsilon Offset used to render the particles
  12491. */
  12492. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12493. private _addFactorGradient;
  12494. private _removeFactorGradient;
  12495. /**
  12496. * Adds a new life time gradient
  12497. * @param gradient defines the gradient to use (between 0 and 1)
  12498. * @param factor defines the life time factor to affect to the specified gradient
  12499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12500. * @returns the current particle system
  12501. */
  12502. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12503. /**
  12504. * Remove a specific life time gradient
  12505. * @param gradient defines the gradient to remove
  12506. * @returns the current particle system
  12507. */
  12508. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12509. /**
  12510. * Adds a new size gradient
  12511. * @param gradient defines the gradient to use (between 0 and 1)
  12512. * @param factor defines the size factor to affect to the specified gradient
  12513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12514. * @returns the current particle system
  12515. */
  12516. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12517. /**
  12518. * Remove a specific size gradient
  12519. * @param gradient defines the gradient to remove
  12520. * @returns the current particle system
  12521. */
  12522. removeSizeGradient(gradient: number): IParticleSystem;
  12523. /**
  12524. * Adds a new color remap gradient
  12525. * @param gradient defines the gradient to use (between 0 and 1)
  12526. * @param min defines the color remap minimal range
  12527. * @param max defines the color remap maximal range
  12528. * @returns the current particle system
  12529. */
  12530. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12531. /**
  12532. * Remove a specific color remap gradient
  12533. * @param gradient defines the gradient to remove
  12534. * @returns the current particle system
  12535. */
  12536. removeColorRemapGradient(gradient: number): IParticleSystem;
  12537. /**
  12538. * Adds a new alpha remap gradient
  12539. * @param gradient defines the gradient to use (between 0 and 1)
  12540. * @param min defines the alpha remap minimal range
  12541. * @param max defines the alpha remap maximal range
  12542. * @returns the current particle system
  12543. */
  12544. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12545. /**
  12546. * Remove a specific alpha remap gradient
  12547. * @param gradient defines the gradient to remove
  12548. * @returns the current particle system
  12549. */
  12550. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12551. /**
  12552. * Adds a new angular speed gradient
  12553. * @param gradient defines the gradient to use (between 0 and 1)
  12554. * @param factor defines the angular speed to affect to the specified gradient
  12555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12556. * @returns the current particle system
  12557. */
  12558. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12559. /**
  12560. * Remove a specific angular speed gradient
  12561. * @param gradient defines the gradient to remove
  12562. * @returns the current particle system
  12563. */
  12564. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12565. /**
  12566. * Adds a new velocity gradient
  12567. * @param gradient defines the gradient to use (between 0 and 1)
  12568. * @param factor defines the velocity to affect to the specified gradient
  12569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12570. * @returns the current particle system
  12571. */
  12572. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12573. /**
  12574. * Remove a specific velocity gradient
  12575. * @param gradient defines the gradient to remove
  12576. * @returns the current particle system
  12577. */
  12578. removeVelocityGradient(gradient: number): IParticleSystem;
  12579. /**
  12580. * Adds a new limit velocity gradient
  12581. * @param gradient defines the gradient to use (between 0 and 1)
  12582. * @param factor defines the limit velocity value to affect to the specified gradient
  12583. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12584. * @returns the current particle system
  12585. */
  12586. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12587. /**
  12588. * Remove a specific limit velocity gradient
  12589. * @param gradient defines the gradient to remove
  12590. * @returns the current particle system
  12591. */
  12592. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12593. /**
  12594. * Adds a new drag gradient
  12595. * @param gradient defines the gradient to use (between 0 and 1)
  12596. * @param factor defines the drag value to affect to the specified gradient
  12597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12598. * @returns the current particle system
  12599. */
  12600. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12601. /**
  12602. * Remove a specific drag gradient
  12603. * @param gradient defines the gradient to remove
  12604. * @returns the current particle system
  12605. */
  12606. removeDragGradient(gradient: number): IParticleSystem;
  12607. /**
  12608. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12609. * @param gradient defines the gradient to use (between 0 and 1)
  12610. * @param factor defines the emit rate value to affect to the specified gradient
  12611. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12612. * @returns the current particle system
  12613. */
  12614. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12615. /**
  12616. * Remove a specific emit rate gradient
  12617. * @param gradient defines the gradient to remove
  12618. * @returns the current particle system
  12619. */
  12620. removeEmitRateGradient(gradient: number): IParticleSystem;
  12621. /**
  12622. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12623. * @param gradient defines the gradient to use (between 0 and 1)
  12624. * @param factor defines the start size value to affect to the specified gradient
  12625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12626. * @returns the current particle system
  12627. */
  12628. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12629. /**
  12630. * Remove a specific start size gradient
  12631. * @param gradient defines the gradient to remove
  12632. * @returns the current particle system
  12633. */
  12634. removeStartSizeGradient(gradient: number): IParticleSystem;
  12635. private _createRampGradientTexture;
  12636. /**
  12637. * Gets the current list of ramp gradients.
  12638. * You must use addRampGradient and removeRampGradient to udpate this list
  12639. * @returns the list of ramp gradients
  12640. */
  12641. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12642. /** Force the system to rebuild all gradients that need to be resync */
  12643. forceRefreshGradients(): void;
  12644. private _syncRampGradientTexture;
  12645. /**
  12646. * Adds a new ramp gradient used to remap particle colors
  12647. * @param gradient defines the gradient to use (between 0 and 1)
  12648. * @param color defines the color to affect to the specified gradient
  12649. * @returns the current particle system
  12650. */
  12651. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12652. /**
  12653. * Remove a specific ramp gradient
  12654. * @param gradient defines the gradient to remove
  12655. * @returns the current particle system
  12656. */
  12657. removeRampGradient(gradient: number): ParticleSystem;
  12658. /**
  12659. * Adds a new color gradient
  12660. * @param gradient defines the gradient to use (between 0 and 1)
  12661. * @param color1 defines the color to affect to the specified gradient
  12662. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12663. * @returns this particle system
  12664. */
  12665. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12666. /**
  12667. * Remove a specific color gradient
  12668. * @param gradient defines the gradient to remove
  12669. * @returns this particle system
  12670. */
  12671. removeColorGradient(gradient: number): IParticleSystem;
  12672. private _fetchR;
  12673. protected _reset(): void;
  12674. private _resetEffect;
  12675. private _createVertexBuffers;
  12676. private _createIndexBuffer;
  12677. /**
  12678. * Gets the maximum number of particles active at the same time.
  12679. * @returns The max number of active particles.
  12680. */
  12681. getCapacity(): number;
  12682. /**
  12683. * Gets whether there are still active particles in the system.
  12684. * @returns True if it is alive, otherwise false.
  12685. */
  12686. isAlive(): boolean;
  12687. /**
  12688. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12689. * @returns True if it has been started, otherwise false.
  12690. */
  12691. isStarted(): boolean;
  12692. private _prepareSubEmitterInternalArray;
  12693. /**
  12694. * Starts the particle system and begins to emit
  12695. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12696. */
  12697. start(delay?: number): void;
  12698. /**
  12699. * Stops the particle system.
  12700. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  12701. */
  12702. stop(stopSubEmitters?: boolean): void;
  12703. /**
  12704. * Remove all active particles
  12705. */
  12706. reset(): void;
  12707. /**
  12708. * @hidden (for internal use only)
  12709. */
  12710. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12711. /**
  12712. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12713. * Its lifetime will start back at 0.
  12714. */
  12715. recycleParticle: (particle: Particle) => void;
  12716. private _stopSubEmitters;
  12717. private _createParticle;
  12718. private _removeFromRoot;
  12719. private _emitFromParticle;
  12720. private _update;
  12721. /** @hidden */
  12722. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12723. /** @hidden */
  12724. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12725. /**
  12726. * Fill the defines array according to the current settings of the particle system
  12727. * @param defines Array to be updated
  12728. * @param blendMode blend mode to take into account when updating the array
  12729. */
  12730. fillDefines(defines: Array<string>, blendMode: number): void;
  12731. /**
  12732. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12733. * @param uniforms Uniforms array to fill
  12734. * @param attributes Attributes array to fill
  12735. * @param samplers Samplers array to fill
  12736. */
  12737. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12738. /** @hidden */
  12739. private _getEffect;
  12740. /**
  12741. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12742. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12743. */
  12744. animate(preWarmOnly?: boolean): void;
  12745. private _appendParticleVertices;
  12746. /**
  12747. * Rebuilds the particle system.
  12748. */
  12749. rebuild(): void;
  12750. /**
  12751. * Is this system ready to be used/rendered
  12752. * @return true if the system is ready
  12753. */
  12754. isReady(): boolean;
  12755. private _render;
  12756. /**
  12757. * Renders the particle system in its current state.
  12758. * @returns the current number of particles
  12759. */
  12760. render(): number;
  12761. /**
  12762. * Disposes the particle system and free the associated resources
  12763. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12764. */
  12765. dispose(disposeTexture?: boolean): void;
  12766. /**
  12767. * Clones the particle system.
  12768. * @param name The name of the cloned object
  12769. * @param newEmitter The new emitter to use
  12770. * @returns the cloned particle system
  12771. */
  12772. clone(name: string, newEmitter: any): ParticleSystem;
  12773. /**
  12774. * Serializes the particle system to a JSON object
  12775. * @param serializeTexture defines if the texture must be serialized as well
  12776. * @returns the JSON object
  12777. */
  12778. serialize(serializeTexture?: boolean): any;
  12779. /** @hidden */
  12780. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12781. /** @hidden */
  12782. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12783. /**
  12784. * Parses a JSON object to create a particle system.
  12785. * @param parsedParticleSystem The JSON object to parse
  12786. * @param scene The scene to create the particle system in
  12787. * @param rootUrl The root url to use to load external dependencies like texture
  12788. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12789. * @returns the Parsed particle system
  12790. */
  12791. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12792. }
  12793. }
  12794. declare module BABYLON {
  12795. /**
  12796. * A particle represents one of the element emitted by a particle system.
  12797. * This is mainly define by its coordinates, direction, velocity and age.
  12798. */
  12799. export class Particle {
  12800. /**
  12801. * The particle system the particle belongs to.
  12802. */
  12803. particleSystem: ParticleSystem;
  12804. private static _Count;
  12805. /**
  12806. * Unique ID of the particle
  12807. */
  12808. id: number;
  12809. /**
  12810. * The world position of the particle in the scene.
  12811. */
  12812. position: Vector3;
  12813. /**
  12814. * The world direction of the particle in the scene.
  12815. */
  12816. direction: Vector3;
  12817. /**
  12818. * The color of the particle.
  12819. */
  12820. color: Color4;
  12821. /**
  12822. * The color change of the particle per step.
  12823. */
  12824. colorStep: Color4;
  12825. /**
  12826. * Defines how long will the life of the particle be.
  12827. */
  12828. lifeTime: number;
  12829. /**
  12830. * The current age of the particle.
  12831. */
  12832. age: number;
  12833. /**
  12834. * The current size of the particle.
  12835. */
  12836. size: number;
  12837. /**
  12838. * The current scale of the particle.
  12839. */
  12840. scale: Vector2;
  12841. /**
  12842. * The current angle of the particle.
  12843. */
  12844. angle: number;
  12845. /**
  12846. * Defines how fast is the angle changing.
  12847. */
  12848. angularSpeed: number;
  12849. /**
  12850. * Defines the cell index used by the particle to be rendered from a sprite.
  12851. */
  12852. cellIndex: number;
  12853. /**
  12854. * The information required to support color remapping
  12855. */
  12856. remapData: Vector4;
  12857. /** @hidden */
  12858. _randomCellOffset?: number;
  12859. /** @hidden */
  12860. _initialDirection: Nullable<Vector3>;
  12861. /** @hidden */
  12862. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12863. /** @hidden */
  12864. _initialStartSpriteCellID: number;
  12865. /** @hidden */
  12866. _initialEndSpriteCellID: number;
  12867. /** @hidden */
  12868. _currentColorGradient: Nullable<ColorGradient>;
  12869. /** @hidden */
  12870. _currentColor1: Color4;
  12871. /** @hidden */
  12872. _currentColor2: Color4;
  12873. /** @hidden */
  12874. _currentSizeGradient: Nullable<FactorGradient>;
  12875. /** @hidden */
  12876. _currentSize1: number;
  12877. /** @hidden */
  12878. _currentSize2: number;
  12879. /** @hidden */
  12880. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12881. /** @hidden */
  12882. _currentAngularSpeed1: number;
  12883. /** @hidden */
  12884. _currentAngularSpeed2: number;
  12885. /** @hidden */
  12886. _currentVelocityGradient: Nullable<FactorGradient>;
  12887. /** @hidden */
  12888. _currentVelocity1: number;
  12889. /** @hidden */
  12890. _currentVelocity2: number;
  12891. /** @hidden */
  12892. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12893. /** @hidden */
  12894. _currentLimitVelocity1: number;
  12895. /** @hidden */
  12896. _currentLimitVelocity2: number;
  12897. /** @hidden */
  12898. _currentDragGradient: Nullable<FactorGradient>;
  12899. /** @hidden */
  12900. _currentDrag1: number;
  12901. /** @hidden */
  12902. _currentDrag2: number;
  12903. /** @hidden */
  12904. _randomNoiseCoordinates1: Vector3;
  12905. /** @hidden */
  12906. _randomNoiseCoordinates2: Vector3;
  12907. /** @hidden */
  12908. _localPosition?: Vector3;
  12909. /**
  12910. * Creates a new instance Particle
  12911. * @param particleSystem the particle system the particle belongs to
  12912. */
  12913. constructor(
  12914. /**
  12915. * The particle system the particle belongs to.
  12916. */
  12917. particleSystem: ParticleSystem);
  12918. private updateCellInfoFromSystem;
  12919. /**
  12920. * Defines how the sprite cell index is updated for the particle
  12921. */
  12922. updateCellIndex(): void;
  12923. /** @hidden */
  12924. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12925. /** @hidden */
  12926. _inheritParticleInfoToSubEmitters(): void;
  12927. /** @hidden */
  12928. _reset(): void;
  12929. /**
  12930. * Copy the properties of particle to another one.
  12931. * @param other the particle to copy the information to.
  12932. */
  12933. copyTo(other: Particle): void;
  12934. }
  12935. }
  12936. declare module BABYLON {
  12937. /**
  12938. * Particle emitter represents a volume emitting particles.
  12939. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12940. */
  12941. export interface IParticleEmitterType {
  12942. /**
  12943. * Called by the particle System when the direction is computed for the created particle.
  12944. * @param worldMatrix is the world matrix of the particle system
  12945. * @param directionToUpdate is the direction vector to update with the result
  12946. * @param particle is the particle we are computed the direction for
  12947. * @param isLocal defines if the direction should be set in local space
  12948. */
  12949. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12950. /**
  12951. * Called by the particle System when the position is computed for the created particle.
  12952. * @param worldMatrix is the world matrix of the particle system
  12953. * @param positionToUpdate is the position vector to update with the result
  12954. * @param particle is the particle we are computed the position for
  12955. * @param isLocal defines if the position should be set in local space
  12956. */
  12957. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12958. /**
  12959. * Clones the current emitter and returns a copy of it
  12960. * @returns the new emitter
  12961. */
  12962. clone(): IParticleEmitterType;
  12963. /**
  12964. * Called by the GPUParticleSystem to setup the update shader
  12965. * @param effect defines the update shader
  12966. */
  12967. applyToShader(effect: Effect): void;
  12968. /**
  12969. * Returns a string to use to update the GPU particles update shader
  12970. * @returns the effect defines string
  12971. */
  12972. getEffectDefines(): string;
  12973. /**
  12974. * Returns a string representing the class name
  12975. * @returns a string containing the class name
  12976. */
  12977. getClassName(): string;
  12978. /**
  12979. * Serializes the particle system to a JSON object.
  12980. * @returns the JSON object
  12981. */
  12982. serialize(): any;
  12983. /**
  12984. * Parse properties from a JSON object
  12985. * @param serializationObject defines the JSON object
  12986. * @param scene defines the hosting scene
  12987. */
  12988. parse(serializationObject: any, scene: Scene): void;
  12989. }
  12990. }
  12991. declare module BABYLON {
  12992. /**
  12993. * Particle emitter emitting particles from the inside of a box.
  12994. * It emits the particles randomly between 2 given directions.
  12995. */
  12996. export class BoxParticleEmitter implements IParticleEmitterType {
  12997. /**
  12998. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12999. */
  13000. direction1: Vector3;
  13001. /**
  13002. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13003. */
  13004. direction2: Vector3;
  13005. /**
  13006. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13007. */
  13008. minEmitBox: Vector3;
  13009. /**
  13010. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13011. */
  13012. maxEmitBox: Vector3;
  13013. /**
  13014. * Creates a new instance BoxParticleEmitter
  13015. */
  13016. constructor();
  13017. /**
  13018. * Called by the particle System when the direction is computed for the created particle.
  13019. * @param worldMatrix is the world matrix of the particle system
  13020. * @param directionToUpdate is the direction vector to update with the result
  13021. * @param particle is the particle we are computed the direction for
  13022. * @param isLocal defines if the direction should be set in local space
  13023. */
  13024. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13025. /**
  13026. * Called by the particle System when the position is computed for the created particle.
  13027. * @param worldMatrix is the world matrix of the particle system
  13028. * @param positionToUpdate is the position vector to update with the result
  13029. * @param particle is the particle we are computed the position for
  13030. * @param isLocal defines if the position should be set in local space
  13031. */
  13032. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13033. /**
  13034. * Clones the current emitter and returns a copy of it
  13035. * @returns the new emitter
  13036. */
  13037. clone(): BoxParticleEmitter;
  13038. /**
  13039. * Called by the GPUParticleSystem to setup the update shader
  13040. * @param effect defines the update shader
  13041. */
  13042. applyToShader(effect: Effect): void;
  13043. /**
  13044. * Returns a string to use to update the GPU particles update shader
  13045. * @returns a string containng the defines string
  13046. */
  13047. getEffectDefines(): string;
  13048. /**
  13049. * Returns the string "BoxParticleEmitter"
  13050. * @returns a string containing the class name
  13051. */
  13052. getClassName(): string;
  13053. /**
  13054. * Serializes the particle system to a JSON object.
  13055. * @returns the JSON object
  13056. */
  13057. serialize(): any;
  13058. /**
  13059. * Parse properties from a JSON object
  13060. * @param serializationObject defines the JSON object
  13061. */
  13062. parse(serializationObject: any): void;
  13063. }
  13064. }
  13065. declare module BABYLON {
  13066. /**
  13067. * Particle emitter emitting particles from the inside of a cone.
  13068. * It emits the particles alongside the cone volume from the base to the particle.
  13069. * The emission direction might be randomized.
  13070. */
  13071. export class ConeParticleEmitter implements IParticleEmitterType {
  13072. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13073. directionRandomizer: number;
  13074. private _radius;
  13075. private _angle;
  13076. private _height;
  13077. /**
  13078. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13079. */
  13080. radiusRange: number;
  13081. /**
  13082. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13083. */
  13084. heightRange: number;
  13085. /**
  13086. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13087. */
  13088. emitFromSpawnPointOnly: boolean;
  13089. /**
  13090. * Gets or sets the radius of the emission cone
  13091. */
  13092. get radius(): number;
  13093. set radius(value: number);
  13094. /**
  13095. * Gets or sets the angle of the emission cone
  13096. */
  13097. get angle(): number;
  13098. set angle(value: number);
  13099. private _buildHeight;
  13100. /**
  13101. * Creates a new instance ConeParticleEmitter
  13102. * @param radius the radius of the emission cone (1 by default)
  13103. * @param angle the cone base angle (PI by default)
  13104. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13105. */
  13106. constructor(radius?: number, angle?: number,
  13107. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13108. directionRandomizer?: number);
  13109. /**
  13110. * Called by the particle System when the direction is computed for the created particle.
  13111. * @param worldMatrix is the world matrix of the particle system
  13112. * @param directionToUpdate is the direction vector to update with the result
  13113. * @param particle is the particle we are computed the direction for
  13114. * @param isLocal defines if the direction should be set in local space
  13115. */
  13116. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13117. /**
  13118. * Called by the particle System when the position is computed for the created particle.
  13119. * @param worldMatrix is the world matrix of the particle system
  13120. * @param positionToUpdate is the position vector to update with the result
  13121. * @param particle is the particle we are computed the position for
  13122. * @param isLocal defines if the position should be set in local space
  13123. */
  13124. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13125. /**
  13126. * Clones the current emitter and returns a copy of it
  13127. * @returns the new emitter
  13128. */
  13129. clone(): ConeParticleEmitter;
  13130. /**
  13131. * Called by the GPUParticleSystem to setup the update shader
  13132. * @param effect defines the update shader
  13133. */
  13134. applyToShader(effect: Effect): void;
  13135. /**
  13136. * Returns a string to use to update the GPU particles update shader
  13137. * @returns a string containng the defines string
  13138. */
  13139. getEffectDefines(): string;
  13140. /**
  13141. * Returns the string "ConeParticleEmitter"
  13142. * @returns a string containing the class name
  13143. */
  13144. getClassName(): string;
  13145. /**
  13146. * Serializes the particle system to a JSON object.
  13147. * @returns the JSON object
  13148. */
  13149. serialize(): any;
  13150. /**
  13151. * Parse properties from a JSON object
  13152. * @param serializationObject defines the JSON object
  13153. */
  13154. parse(serializationObject: any): void;
  13155. }
  13156. }
  13157. declare module BABYLON {
  13158. /**
  13159. * Particle emitter emitting particles from the inside of a cylinder.
  13160. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13161. */
  13162. export class CylinderParticleEmitter implements IParticleEmitterType {
  13163. /**
  13164. * The radius of the emission cylinder.
  13165. */
  13166. radius: number;
  13167. /**
  13168. * The height of the emission cylinder.
  13169. */
  13170. height: number;
  13171. /**
  13172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13173. */
  13174. radiusRange: number;
  13175. /**
  13176. * How much to randomize the particle direction [0-1].
  13177. */
  13178. directionRandomizer: number;
  13179. /**
  13180. * Creates a new instance CylinderParticleEmitter
  13181. * @param radius the radius of the emission cylinder (1 by default)
  13182. * @param height the height of the emission cylinder (1 by default)
  13183. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13184. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13185. */
  13186. constructor(
  13187. /**
  13188. * The radius of the emission cylinder.
  13189. */
  13190. radius?: number,
  13191. /**
  13192. * The height of the emission cylinder.
  13193. */
  13194. height?: number,
  13195. /**
  13196. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13197. */
  13198. radiusRange?: number,
  13199. /**
  13200. * How much to randomize the particle direction [0-1].
  13201. */
  13202. directionRandomizer?: number);
  13203. /**
  13204. * Called by the particle System when the direction is computed for the created particle.
  13205. * @param worldMatrix is the world matrix of the particle system
  13206. * @param directionToUpdate is the direction vector to update with the result
  13207. * @param particle is the particle we are computed the direction for
  13208. * @param isLocal defines if the direction should be set in local space
  13209. */
  13210. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13211. /**
  13212. * Called by the particle System when the position is computed for the created particle.
  13213. * @param worldMatrix is the world matrix of the particle system
  13214. * @param positionToUpdate is the position vector to update with the result
  13215. * @param particle is the particle we are computed the position for
  13216. * @param isLocal defines if the position should be set in local space
  13217. */
  13218. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13219. /**
  13220. * Clones the current emitter and returns a copy of it
  13221. * @returns the new emitter
  13222. */
  13223. clone(): CylinderParticleEmitter;
  13224. /**
  13225. * Called by the GPUParticleSystem to setup the update shader
  13226. * @param effect defines the update shader
  13227. */
  13228. applyToShader(effect: Effect): void;
  13229. /**
  13230. * Returns a string to use to update the GPU particles update shader
  13231. * @returns a string containng the defines string
  13232. */
  13233. getEffectDefines(): string;
  13234. /**
  13235. * Returns the string "CylinderParticleEmitter"
  13236. * @returns a string containing the class name
  13237. */
  13238. getClassName(): string;
  13239. /**
  13240. * Serializes the particle system to a JSON object.
  13241. * @returns the JSON object
  13242. */
  13243. serialize(): any;
  13244. /**
  13245. * Parse properties from a JSON object
  13246. * @param serializationObject defines the JSON object
  13247. */
  13248. parse(serializationObject: any): void;
  13249. }
  13250. /**
  13251. * Particle emitter emitting particles from the inside of a cylinder.
  13252. * It emits the particles randomly between two vectors.
  13253. */
  13254. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13255. /**
  13256. * The min limit of the emission direction.
  13257. */
  13258. direction1: Vector3;
  13259. /**
  13260. * The max limit of the emission direction.
  13261. */
  13262. direction2: Vector3;
  13263. /**
  13264. * Creates a new instance CylinderDirectedParticleEmitter
  13265. * @param radius the radius of the emission cylinder (1 by default)
  13266. * @param height the height of the emission cylinder (1 by default)
  13267. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13268. * @param direction1 the min limit of the emission direction (up vector by default)
  13269. * @param direction2 the max limit of the emission direction (up vector by default)
  13270. */
  13271. constructor(radius?: number, height?: number, radiusRange?: number,
  13272. /**
  13273. * The min limit of the emission direction.
  13274. */
  13275. direction1?: Vector3,
  13276. /**
  13277. * The max limit of the emission direction.
  13278. */
  13279. direction2?: Vector3);
  13280. /**
  13281. * Called by the particle System when the direction is computed for the created particle.
  13282. * @param worldMatrix is the world matrix of the particle system
  13283. * @param directionToUpdate is the direction vector to update with the result
  13284. * @param particle is the particle we are computed the direction for
  13285. */
  13286. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13287. /**
  13288. * Clones the current emitter and returns a copy of it
  13289. * @returns the new emitter
  13290. */
  13291. clone(): CylinderDirectedParticleEmitter;
  13292. /**
  13293. * Called by the GPUParticleSystem to setup the update shader
  13294. * @param effect defines the update shader
  13295. */
  13296. applyToShader(effect: Effect): void;
  13297. /**
  13298. * Returns a string to use to update the GPU particles update shader
  13299. * @returns a string containng the defines string
  13300. */
  13301. getEffectDefines(): string;
  13302. /**
  13303. * Returns the string "CylinderDirectedParticleEmitter"
  13304. * @returns a string containing the class name
  13305. */
  13306. getClassName(): string;
  13307. /**
  13308. * Serializes the particle system to a JSON object.
  13309. * @returns the JSON object
  13310. */
  13311. serialize(): any;
  13312. /**
  13313. * Parse properties from a JSON object
  13314. * @param serializationObject defines the JSON object
  13315. */
  13316. parse(serializationObject: any): void;
  13317. }
  13318. }
  13319. declare module BABYLON {
  13320. /**
  13321. * Particle emitter emitting particles from the inside of a hemisphere.
  13322. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13323. */
  13324. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13325. /**
  13326. * The radius of the emission hemisphere.
  13327. */
  13328. radius: number;
  13329. /**
  13330. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13331. */
  13332. radiusRange: number;
  13333. /**
  13334. * How much to randomize the particle direction [0-1].
  13335. */
  13336. directionRandomizer: number;
  13337. /**
  13338. * Creates a new instance HemisphericParticleEmitter
  13339. * @param radius the radius of the emission hemisphere (1 by default)
  13340. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13341. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13342. */
  13343. constructor(
  13344. /**
  13345. * The radius of the emission hemisphere.
  13346. */
  13347. radius?: number,
  13348. /**
  13349. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13350. */
  13351. radiusRange?: number,
  13352. /**
  13353. * How much to randomize the particle direction [0-1].
  13354. */
  13355. directionRandomizer?: number);
  13356. /**
  13357. * Called by the particle System when the direction is computed for the created particle.
  13358. * @param worldMatrix is the world matrix of the particle system
  13359. * @param directionToUpdate is the direction vector to update with the result
  13360. * @param particle is the particle we are computed the direction for
  13361. * @param isLocal defines if the direction should be set in local space
  13362. */
  13363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13364. /**
  13365. * Called by the particle System when the position is computed for the created particle.
  13366. * @param worldMatrix is the world matrix of the particle system
  13367. * @param positionToUpdate is the position vector to update with the result
  13368. * @param particle is the particle we are computed the position for
  13369. * @param isLocal defines if the position should be set in local space
  13370. */
  13371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13372. /**
  13373. * Clones the current emitter and returns a copy of it
  13374. * @returns the new emitter
  13375. */
  13376. clone(): HemisphericParticleEmitter;
  13377. /**
  13378. * Called by the GPUParticleSystem to setup the update shader
  13379. * @param effect defines the update shader
  13380. */
  13381. applyToShader(effect: Effect): void;
  13382. /**
  13383. * Returns a string to use to update the GPU particles update shader
  13384. * @returns a string containng the defines string
  13385. */
  13386. getEffectDefines(): string;
  13387. /**
  13388. * Returns the string "HemisphericParticleEmitter"
  13389. * @returns a string containing the class name
  13390. */
  13391. getClassName(): string;
  13392. /**
  13393. * Serializes the particle system to a JSON object.
  13394. * @returns the JSON object
  13395. */
  13396. serialize(): any;
  13397. /**
  13398. * Parse properties from a JSON object
  13399. * @param serializationObject defines the JSON object
  13400. */
  13401. parse(serializationObject: any): void;
  13402. }
  13403. }
  13404. declare module BABYLON {
  13405. /**
  13406. * Particle emitter emitting particles from a point.
  13407. * It emits the particles randomly between 2 given directions.
  13408. */
  13409. export class PointParticleEmitter implements IParticleEmitterType {
  13410. /**
  13411. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13412. */
  13413. direction1: Vector3;
  13414. /**
  13415. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13416. */
  13417. direction2: Vector3;
  13418. /**
  13419. * Creates a new instance PointParticleEmitter
  13420. */
  13421. constructor();
  13422. /**
  13423. * Called by the particle System when the direction is computed for the created particle.
  13424. * @param worldMatrix is the world matrix of the particle system
  13425. * @param directionToUpdate is the direction vector to update with the result
  13426. * @param particle is the particle we are computed the direction for
  13427. * @param isLocal defines if the direction should be set in local space
  13428. */
  13429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13430. /**
  13431. * Called by the particle System when the position is computed for the created particle.
  13432. * @param worldMatrix is the world matrix of the particle system
  13433. * @param positionToUpdate is the position vector to update with the result
  13434. * @param particle is the particle we are computed the position for
  13435. * @param isLocal defines if the position should be set in local space
  13436. */
  13437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13438. /**
  13439. * Clones the current emitter and returns a copy of it
  13440. * @returns the new emitter
  13441. */
  13442. clone(): PointParticleEmitter;
  13443. /**
  13444. * Called by the GPUParticleSystem to setup the update shader
  13445. * @param effect defines the update shader
  13446. */
  13447. applyToShader(effect: Effect): void;
  13448. /**
  13449. * Returns a string to use to update the GPU particles update shader
  13450. * @returns a string containng the defines string
  13451. */
  13452. getEffectDefines(): string;
  13453. /**
  13454. * Returns the string "PointParticleEmitter"
  13455. * @returns a string containing the class name
  13456. */
  13457. getClassName(): string;
  13458. /**
  13459. * Serializes the particle system to a JSON object.
  13460. * @returns the JSON object
  13461. */
  13462. serialize(): any;
  13463. /**
  13464. * Parse properties from a JSON object
  13465. * @param serializationObject defines the JSON object
  13466. */
  13467. parse(serializationObject: any): void;
  13468. }
  13469. }
  13470. declare module BABYLON {
  13471. /**
  13472. * Particle emitter emitting particles from the inside of a sphere.
  13473. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13474. */
  13475. export class SphereParticleEmitter implements IParticleEmitterType {
  13476. /**
  13477. * The radius of the emission sphere.
  13478. */
  13479. radius: number;
  13480. /**
  13481. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13482. */
  13483. radiusRange: number;
  13484. /**
  13485. * How much to randomize the particle direction [0-1].
  13486. */
  13487. directionRandomizer: number;
  13488. /**
  13489. * Creates a new instance SphereParticleEmitter
  13490. * @param radius the radius of the emission sphere (1 by default)
  13491. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13492. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13493. */
  13494. constructor(
  13495. /**
  13496. * The radius of the emission sphere.
  13497. */
  13498. radius?: number,
  13499. /**
  13500. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13501. */
  13502. radiusRange?: number,
  13503. /**
  13504. * How much to randomize the particle direction [0-1].
  13505. */
  13506. directionRandomizer?: number);
  13507. /**
  13508. * Called by the particle System when the direction is computed for the created particle.
  13509. * @param worldMatrix is the world matrix of the particle system
  13510. * @param directionToUpdate is the direction vector to update with the result
  13511. * @param particle is the particle we are computed the direction for
  13512. * @param isLocal defines if the direction should be set in local space
  13513. */
  13514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13515. /**
  13516. * Called by the particle System when the position is computed for the created particle.
  13517. * @param worldMatrix is the world matrix of the particle system
  13518. * @param positionToUpdate is the position vector to update with the result
  13519. * @param particle is the particle we are computed the position for
  13520. * @param isLocal defines if the position should be set in local space
  13521. */
  13522. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13523. /**
  13524. * Clones the current emitter and returns a copy of it
  13525. * @returns the new emitter
  13526. */
  13527. clone(): SphereParticleEmitter;
  13528. /**
  13529. * Called by the GPUParticleSystem to setup the update shader
  13530. * @param effect defines the update shader
  13531. */
  13532. applyToShader(effect: Effect): void;
  13533. /**
  13534. * Returns a string to use to update the GPU particles update shader
  13535. * @returns a string containng the defines string
  13536. */
  13537. getEffectDefines(): string;
  13538. /**
  13539. * Returns the string "SphereParticleEmitter"
  13540. * @returns a string containing the class name
  13541. */
  13542. getClassName(): string;
  13543. /**
  13544. * Serializes the particle system to a JSON object.
  13545. * @returns the JSON object
  13546. */
  13547. serialize(): any;
  13548. /**
  13549. * Parse properties from a JSON object
  13550. * @param serializationObject defines the JSON object
  13551. */
  13552. parse(serializationObject: any): void;
  13553. }
  13554. /**
  13555. * Particle emitter emitting particles from the inside of a sphere.
  13556. * It emits the particles randomly between two vectors.
  13557. */
  13558. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13559. /**
  13560. * The min limit of the emission direction.
  13561. */
  13562. direction1: Vector3;
  13563. /**
  13564. * The max limit of the emission direction.
  13565. */
  13566. direction2: Vector3;
  13567. /**
  13568. * Creates a new instance SphereDirectedParticleEmitter
  13569. * @param radius the radius of the emission sphere (1 by default)
  13570. * @param direction1 the min limit of the emission direction (up vector by default)
  13571. * @param direction2 the max limit of the emission direction (up vector by default)
  13572. */
  13573. constructor(radius?: number,
  13574. /**
  13575. * The min limit of the emission direction.
  13576. */
  13577. direction1?: Vector3,
  13578. /**
  13579. * The max limit of the emission direction.
  13580. */
  13581. direction2?: Vector3);
  13582. /**
  13583. * Called by the particle System when the direction is computed for the created particle.
  13584. * @param worldMatrix is the world matrix of the particle system
  13585. * @param directionToUpdate is the direction vector to update with the result
  13586. * @param particle is the particle we are computed the direction for
  13587. */
  13588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13589. /**
  13590. * Clones the current emitter and returns a copy of it
  13591. * @returns the new emitter
  13592. */
  13593. clone(): SphereDirectedParticleEmitter;
  13594. /**
  13595. * Called by the GPUParticleSystem to setup the update shader
  13596. * @param effect defines the update shader
  13597. */
  13598. applyToShader(effect: Effect): void;
  13599. /**
  13600. * Returns a string to use to update the GPU particles update shader
  13601. * @returns a string containng the defines string
  13602. */
  13603. getEffectDefines(): string;
  13604. /**
  13605. * Returns the string "SphereDirectedParticleEmitter"
  13606. * @returns a string containing the class name
  13607. */
  13608. getClassName(): string;
  13609. /**
  13610. * Serializes the particle system to a JSON object.
  13611. * @returns the JSON object
  13612. */
  13613. serialize(): any;
  13614. /**
  13615. * Parse properties from a JSON object
  13616. * @param serializationObject defines the JSON object
  13617. */
  13618. parse(serializationObject: any): void;
  13619. }
  13620. }
  13621. declare module BABYLON {
  13622. /**
  13623. * Particle emitter emitting particles from a custom list of positions.
  13624. */
  13625. export class CustomParticleEmitter implements IParticleEmitterType {
  13626. /**
  13627. * Gets or sets the position generator that will create the inital position of each particle.
  13628. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13629. */
  13630. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13631. /**
  13632. * Gets or sets the destination generator that will create the final destination of each particle.
  13633. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13634. */
  13635. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13636. /**
  13637. * Creates a new instance CustomParticleEmitter
  13638. */
  13639. constructor();
  13640. /**
  13641. * Called by the particle System when the direction is computed for the created particle.
  13642. * @param worldMatrix is the world matrix of the particle system
  13643. * @param directionToUpdate is the direction vector to update with the result
  13644. * @param particle is the particle we are computed the direction for
  13645. * @param isLocal defines if the direction should be set in local space
  13646. */
  13647. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13648. /**
  13649. * Called by the particle System when the position is computed for the created particle.
  13650. * @param worldMatrix is the world matrix of the particle system
  13651. * @param positionToUpdate is the position vector to update with the result
  13652. * @param particle is the particle we are computed the position for
  13653. * @param isLocal defines if the position should be set in local space
  13654. */
  13655. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13656. /**
  13657. * Clones the current emitter and returns a copy of it
  13658. * @returns the new emitter
  13659. */
  13660. clone(): CustomParticleEmitter;
  13661. /**
  13662. * Called by the GPUParticleSystem to setup the update shader
  13663. * @param effect defines the update shader
  13664. */
  13665. applyToShader(effect: Effect): void;
  13666. /**
  13667. * Returns a string to use to update the GPU particles update shader
  13668. * @returns a string containng the defines string
  13669. */
  13670. getEffectDefines(): string;
  13671. /**
  13672. * Returns the string "PointParticleEmitter"
  13673. * @returns a string containing the class name
  13674. */
  13675. getClassName(): string;
  13676. /**
  13677. * Serializes the particle system to a JSON object.
  13678. * @returns the JSON object
  13679. */
  13680. serialize(): any;
  13681. /**
  13682. * Parse properties from a JSON object
  13683. * @param serializationObject defines the JSON object
  13684. */
  13685. parse(serializationObject: any): void;
  13686. }
  13687. }
  13688. declare module BABYLON {
  13689. /**
  13690. * Particle emitter emitting particles from the inside of a box.
  13691. * It emits the particles randomly between 2 given directions.
  13692. */
  13693. export class MeshParticleEmitter implements IParticleEmitterType {
  13694. private _indices;
  13695. private _positions;
  13696. private _normals;
  13697. private _storedNormal;
  13698. private _mesh;
  13699. /**
  13700. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13701. */
  13702. direction1: Vector3;
  13703. /**
  13704. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13705. */
  13706. direction2: Vector3;
  13707. /**
  13708. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13709. */
  13710. useMeshNormalsForDirection: boolean;
  13711. /** Defines the mesh to use as source */
  13712. get mesh(): Nullable<AbstractMesh>;
  13713. set mesh(value: Nullable<AbstractMesh>);
  13714. /**
  13715. * Creates a new instance MeshParticleEmitter
  13716. * @param mesh defines the mesh to use as source
  13717. */
  13718. constructor(mesh?: Nullable<AbstractMesh>);
  13719. /**
  13720. * Called by the particle System when the direction is computed for the created particle.
  13721. * @param worldMatrix is the world matrix of the particle system
  13722. * @param directionToUpdate is the direction vector to update with the result
  13723. * @param particle is the particle we are computed the direction for
  13724. * @param isLocal defines if the direction should be set in local space
  13725. */
  13726. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13727. /**
  13728. * Called by the particle System when the position is computed for the created particle.
  13729. * @param worldMatrix is the world matrix of the particle system
  13730. * @param positionToUpdate is the position vector to update with the result
  13731. * @param particle is the particle we are computed the position for
  13732. * @param isLocal defines if the position should be set in local space
  13733. */
  13734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13735. /**
  13736. * Clones the current emitter and returns a copy of it
  13737. * @returns the new emitter
  13738. */
  13739. clone(): MeshParticleEmitter;
  13740. /**
  13741. * Called by the GPUParticleSystem to setup the update shader
  13742. * @param effect defines the update shader
  13743. */
  13744. applyToShader(effect: Effect): void;
  13745. /**
  13746. * Returns a string to use to update the GPU particles update shader
  13747. * @returns a string containng the defines string
  13748. */
  13749. getEffectDefines(): string;
  13750. /**
  13751. * Returns the string "BoxParticleEmitter"
  13752. * @returns a string containing the class name
  13753. */
  13754. getClassName(): string;
  13755. /**
  13756. * Serializes the particle system to a JSON object.
  13757. * @returns the JSON object
  13758. */
  13759. serialize(): any;
  13760. /**
  13761. * Parse properties from a JSON object
  13762. * @param serializationObject defines the JSON object
  13763. * @param scene defines the hosting scene
  13764. */
  13765. parse(serializationObject: any, scene: Scene): void;
  13766. }
  13767. }
  13768. declare module BABYLON {
  13769. /**
  13770. * Interface representing a particle system in Babylon.js.
  13771. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13772. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13773. */
  13774. export interface IParticleSystem {
  13775. /**
  13776. * List of animations used by the particle system.
  13777. */
  13778. animations: Animation[];
  13779. /**
  13780. * The id of the Particle system.
  13781. */
  13782. id: string;
  13783. /**
  13784. * The name of the Particle system.
  13785. */
  13786. name: string;
  13787. /**
  13788. * The emitter represents the Mesh or position we are attaching the particle system to.
  13789. */
  13790. emitter: Nullable<AbstractMesh | Vector3>;
  13791. /**
  13792. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13793. */
  13794. isBillboardBased: boolean;
  13795. /**
  13796. * The rendering group used by the Particle system to chose when to render.
  13797. */
  13798. renderingGroupId: number;
  13799. /**
  13800. * The layer mask we are rendering the particles through.
  13801. */
  13802. layerMask: number;
  13803. /**
  13804. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13805. */
  13806. updateSpeed: number;
  13807. /**
  13808. * The amount of time the particle system is running (depends of the overall update speed).
  13809. */
  13810. targetStopDuration: number;
  13811. /**
  13812. * The texture used to render each particle. (this can be a spritesheet)
  13813. */
  13814. particleTexture: Nullable<Texture>;
  13815. /**
  13816. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13817. */
  13818. blendMode: number;
  13819. /**
  13820. * Minimum life time of emitting particles.
  13821. */
  13822. minLifeTime: number;
  13823. /**
  13824. * Maximum life time of emitting particles.
  13825. */
  13826. maxLifeTime: number;
  13827. /**
  13828. * Minimum Size of emitting particles.
  13829. */
  13830. minSize: number;
  13831. /**
  13832. * Maximum Size of emitting particles.
  13833. */
  13834. maxSize: number;
  13835. /**
  13836. * Minimum scale of emitting particles on X axis.
  13837. */
  13838. minScaleX: number;
  13839. /**
  13840. * Maximum scale of emitting particles on X axis.
  13841. */
  13842. maxScaleX: number;
  13843. /**
  13844. * Minimum scale of emitting particles on Y axis.
  13845. */
  13846. minScaleY: number;
  13847. /**
  13848. * Maximum scale of emitting particles on Y axis.
  13849. */
  13850. maxScaleY: number;
  13851. /**
  13852. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13853. */
  13854. color1: Color4;
  13855. /**
  13856. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13857. */
  13858. color2: Color4;
  13859. /**
  13860. * Color the particle will have at the end of its lifetime.
  13861. */
  13862. colorDead: Color4;
  13863. /**
  13864. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13865. */
  13866. emitRate: number;
  13867. /**
  13868. * You can use gravity if you want to give an orientation to your particles.
  13869. */
  13870. gravity: Vector3;
  13871. /**
  13872. * Minimum power of emitting particles.
  13873. */
  13874. minEmitPower: number;
  13875. /**
  13876. * Maximum power of emitting particles.
  13877. */
  13878. maxEmitPower: number;
  13879. /**
  13880. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13881. */
  13882. minAngularSpeed: number;
  13883. /**
  13884. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13885. */
  13886. maxAngularSpeed: number;
  13887. /**
  13888. * Gets or sets the minimal initial rotation in radians.
  13889. */
  13890. minInitialRotation: number;
  13891. /**
  13892. * Gets or sets the maximal initial rotation in radians.
  13893. */
  13894. maxInitialRotation: number;
  13895. /**
  13896. * The particle emitter type defines the emitter used by the particle system.
  13897. * It can be for example box, sphere, or cone...
  13898. */
  13899. particleEmitterType: Nullable<IParticleEmitterType>;
  13900. /**
  13901. * Defines the delay in milliseconds before starting the system (0 by default)
  13902. */
  13903. startDelay: number;
  13904. /**
  13905. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  13906. */
  13907. preWarmCycles: number;
  13908. /**
  13909. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13910. */
  13911. preWarmStepOffset: number;
  13912. /**
  13913. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  13914. */
  13915. spriteCellChangeSpeed: number;
  13916. /**
  13917. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13918. */
  13919. startSpriteCellID: number;
  13920. /**
  13921. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13922. */
  13923. endSpriteCellID: number;
  13924. /**
  13925. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13926. */
  13927. spriteCellWidth: number;
  13928. /**
  13929. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13930. */
  13931. spriteCellHeight: number;
  13932. /**
  13933. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13934. */
  13935. spriteRandomStartCell: boolean;
  13936. /**
  13937. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13938. */
  13939. isAnimationSheetEnabled: boolean;
  13940. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13941. translationPivot: Vector2;
  13942. /**
  13943. * Gets or sets a texture used to add random noise to particle positions
  13944. */
  13945. noiseTexture: Nullable<BaseTexture>;
  13946. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13947. noiseStrength: Vector3;
  13948. /**
  13949. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13950. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13951. */
  13952. billboardMode: number;
  13953. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13954. limitVelocityDamping: number;
  13955. /**
  13956. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13957. */
  13958. beginAnimationOnStart: boolean;
  13959. /**
  13960. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13961. */
  13962. beginAnimationFrom: number;
  13963. /**
  13964. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13965. */
  13966. beginAnimationTo: number;
  13967. /**
  13968. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13969. */
  13970. beginAnimationLoop: boolean;
  13971. /**
  13972. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13973. */
  13974. disposeOnStop: boolean;
  13975. /**
  13976. * Specifies if the particles are updated in emitter local space or world space
  13977. */
  13978. isLocal: boolean;
  13979. /** Snippet ID if the particle system was created from the snippet server */
  13980. snippetId: string;
  13981. /**
  13982. * Gets the maximum number of particles active at the same time.
  13983. * @returns The max number of active particles.
  13984. */
  13985. getCapacity(): number;
  13986. /**
  13987. * Gets the number of particles active at the same time.
  13988. * @returns The number of active particles.
  13989. */
  13990. getActiveCount(): number;
  13991. /**
  13992. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13993. * @returns True if it has been started, otherwise false.
  13994. */
  13995. isStarted(): boolean;
  13996. /**
  13997. * Animates the particle system for this frame.
  13998. */
  13999. animate(): void;
  14000. /**
  14001. * Renders the particle system in its current state.
  14002. * @returns the current number of particles
  14003. */
  14004. render(): number;
  14005. /**
  14006. * Dispose the particle system and frees its associated resources.
  14007. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14008. */
  14009. dispose(disposeTexture?: boolean): void;
  14010. /**
  14011. * An event triggered when the system is disposed
  14012. */
  14013. onDisposeObservable: Observable<IParticleSystem>;
  14014. /**
  14015. * Clones the particle system.
  14016. * @param name The name of the cloned object
  14017. * @param newEmitter The new emitter to use
  14018. * @returns the cloned particle system
  14019. */
  14020. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14021. /**
  14022. * Serializes the particle system to a JSON object
  14023. * @param serializeTexture defines if the texture must be serialized as well
  14024. * @returns the JSON object
  14025. */
  14026. serialize(serializeTexture: boolean): any;
  14027. /**
  14028. * Rebuild the particle system
  14029. */
  14030. rebuild(): void;
  14031. /** Force the system to rebuild all gradients that need to be resync */
  14032. forceRefreshGradients(): void;
  14033. /**
  14034. * Starts the particle system and begins to emit
  14035. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14036. */
  14037. start(delay?: number): void;
  14038. /**
  14039. * Stops the particle system.
  14040. */
  14041. stop(): void;
  14042. /**
  14043. * Remove all active particles
  14044. */
  14045. reset(): void;
  14046. /**
  14047. * Gets a boolean indicating that the system is stopping
  14048. * @returns true if the system is currently stopping
  14049. */
  14050. isStopping(): boolean;
  14051. /**
  14052. * Is this system ready to be used/rendered
  14053. * @return true if the system is ready
  14054. */
  14055. isReady(): boolean;
  14056. /**
  14057. * Returns the string "ParticleSystem"
  14058. * @returns a string containing the class name
  14059. */
  14060. getClassName(): string;
  14061. /**
  14062. * Gets the custom effect used to render the particles
  14063. * @param blendMode Blend mode for which the effect should be retrieved
  14064. * @returns The effect
  14065. */
  14066. getCustomEffect(blendMode: number): Nullable<Effect>;
  14067. /**
  14068. * Sets the custom effect used to render the particles
  14069. * @param effect The effect to set
  14070. * @param blendMode Blend mode for which the effect should be set
  14071. */
  14072. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14073. /**
  14074. * Fill the defines array according to the current settings of the particle system
  14075. * @param defines Array to be updated
  14076. * @param blendMode blend mode to take into account when updating the array
  14077. */
  14078. fillDefines(defines: Array<string>, blendMode: number): void;
  14079. /**
  14080. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14081. * @param uniforms Uniforms array to fill
  14082. * @param attributes Attributes array to fill
  14083. * @param samplers Samplers array to fill
  14084. */
  14085. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14086. /**
  14087. * Observable that will be called just before the particles are drawn
  14088. */
  14089. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14090. /**
  14091. * Gets the name of the particle vertex shader
  14092. */
  14093. vertexShaderName: string;
  14094. /**
  14095. * Adds a new color gradient
  14096. * @param gradient defines the gradient to use (between 0 and 1)
  14097. * @param color1 defines the color to affect to the specified gradient
  14098. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14099. * @returns the current particle system
  14100. */
  14101. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14102. /**
  14103. * Remove a specific color gradient
  14104. * @param gradient defines the gradient to remove
  14105. * @returns the current particle system
  14106. */
  14107. removeColorGradient(gradient: number): IParticleSystem;
  14108. /**
  14109. * Adds a new size gradient
  14110. * @param gradient defines the gradient to use (between 0 and 1)
  14111. * @param factor defines the size factor to affect to the specified gradient
  14112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14113. * @returns the current particle system
  14114. */
  14115. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14116. /**
  14117. * Remove a specific size gradient
  14118. * @param gradient defines the gradient to remove
  14119. * @returns the current particle system
  14120. */
  14121. removeSizeGradient(gradient: number): IParticleSystem;
  14122. /**
  14123. * Gets the current list of color gradients.
  14124. * You must use addColorGradient and removeColorGradient to udpate this list
  14125. * @returns the list of color gradients
  14126. */
  14127. getColorGradients(): Nullable<Array<ColorGradient>>;
  14128. /**
  14129. * Gets the current list of size gradients.
  14130. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14131. * @returns the list of size gradients
  14132. */
  14133. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14134. /**
  14135. * Gets the current list of angular speed gradients.
  14136. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14137. * @returns the list of angular speed gradients
  14138. */
  14139. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14140. /**
  14141. * Adds a new angular speed gradient
  14142. * @param gradient defines the gradient to use (between 0 and 1)
  14143. * @param factor defines the angular speed to affect to the specified gradient
  14144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14145. * @returns the current particle system
  14146. */
  14147. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14148. /**
  14149. * Remove a specific angular speed gradient
  14150. * @param gradient defines the gradient to remove
  14151. * @returns the current particle system
  14152. */
  14153. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14154. /**
  14155. * Gets the current list of velocity gradients.
  14156. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14157. * @returns the list of velocity gradients
  14158. */
  14159. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14160. /**
  14161. * Adds a new velocity gradient
  14162. * @param gradient defines the gradient to use (between 0 and 1)
  14163. * @param factor defines the velocity to affect to the specified gradient
  14164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14165. * @returns the current particle system
  14166. */
  14167. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14168. /**
  14169. * Remove a specific velocity gradient
  14170. * @param gradient defines the gradient to remove
  14171. * @returns the current particle system
  14172. */
  14173. removeVelocityGradient(gradient: number): IParticleSystem;
  14174. /**
  14175. * Gets the current list of limit velocity gradients.
  14176. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14177. * @returns the list of limit velocity gradients
  14178. */
  14179. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14180. /**
  14181. * Adds a new limit velocity gradient
  14182. * @param gradient defines the gradient to use (between 0 and 1)
  14183. * @param factor defines the limit velocity to affect to the specified gradient
  14184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14185. * @returns the current particle system
  14186. */
  14187. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14188. /**
  14189. * Remove a specific limit velocity gradient
  14190. * @param gradient defines the gradient to remove
  14191. * @returns the current particle system
  14192. */
  14193. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14194. /**
  14195. * Adds a new drag gradient
  14196. * @param gradient defines the gradient to use (between 0 and 1)
  14197. * @param factor defines the drag to affect to the specified gradient
  14198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14199. * @returns the current particle system
  14200. */
  14201. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14202. /**
  14203. * Remove a specific drag gradient
  14204. * @param gradient defines the gradient to remove
  14205. * @returns the current particle system
  14206. */
  14207. removeDragGradient(gradient: number): IParticleSystem;
  14208. /**
  14209. * Gets the current list of drag gradients.
  14210. * You must use addDragGradient and removeDragGradient to udpate this list
  14211. * @returns the list of drag gradients
  14212. */
  14213. getDragGradients(): Nullable<Array<FactorGradient>>;
  14214. /**
  14215. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14216. * @param gradient defines the gradient to use (between 0 and 1)
  14217. * @param factor defines the emit rate to affect to the specified gradient
  14218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14219. * @returns the current particle system
  14220. */
  14221. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14222. /**
  14223. * Remove a specific emit rate gradient
  14224. * @param gradient defines the gradient to remove
  14225. * @returns the current particle system
  14226. */
  14227. removeEmitRateGradient(gradient: number): IParticleSystem;
  14228. /**
  14229. * Gets the current list of emit rate gradients.
  14230. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14231. * @returns the list of emit rate gradients
  14232. */
  14233. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14234. /**
  14235. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14236. * @param gradient defines the gradient to use (between 0 and 1)
  14237. * @param factor defines the start size to affect to the specified gradient
  14238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14239. * @returns the current particle system
  14240. */
  14241. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14242. /**
  14243. * Remove a specific start size gradient
  14244. * @param gradient defines the gradient to remove
  14245. * @returns the current particle system
  14246. */
  14247. removeStartSizeGradient(gradient: number): IParticleSystem;
  14248. /**
  14249. * Gets the current list of start size gradients.
  14250. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14251. * @returns the list of start size gradients
  14252. */
  14253. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14254. /**
  14255. * Adds a new life time gradient
  14256. * @param gradient defines the gradient to use (between 0 and 1)
  14257. * @param factor defines the life time factor to affect to the specified gradient
  14258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14259. * @returns the current particle system
  14260. */
  14261. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14262. /**
  14263. * Remove a specific life time gradient
  14264. * @param gradient defines the gradient to remove
  14265. * @returns the current particle system
  14266. */
  14267. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14268. /**
  14269. * Gets the current list of life time gradients.
  14270. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14271. * @returns the list of life time gradients
  14272. */
  14273. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14274. /**
  14275. * Gets the current list of color gradients.
  14276. * You must use addColorGradient and removeColorGradient to udpate this list
  14277. * @returns the list of color gradients
  14278. */
  14279. getColorGradients(): Nullable<Array<ColorGradient>>;
  14280. /**
  14281. * Adds a new ramp gradient used to remap particle colors
  14282. * @param gradient defines the gradient to use (between 0 and 1)
  14283. * @param color defines the color to affect to the specified gradient
  14284. * @returns the current particle system
  14285. */
  14286. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14287. /**
  14288. * Gets the current list of ramp gradients.
  14289. * You must use addRampGradient and removeRampGradient to udpate this list
  14290. * @returns the list of ramp gradients
  14291. */
  14292. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14293. /** Gets or sets a boolean indicating that ramp gradients must be used
  14294. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14295. */
  14296. useRampGradients: boolean;
  14297. /**
  14298. * Adds a new color remap gradient
  14299. * @param gradient defines the gradient to use (between 0 and 1)
  14300. * @param min defines the color remap minimal range
  14301. * @param max defines the color remap maximal range
  14302. * @returns the current particle system
  14303. */
  14304. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14305. /**
  14306. * Gets the current list of color remap gradients.
  14307. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14308. * @returns the list of color remap gradients
  14309. */
  14310. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14311. /**
  14312. * Adds a new alpha remap gradient
  14313. * @param gradient defines the gradient to use (between 0 and 1)
  14314. * @param min defines the alpha remap minimal range
  14315. * @param max defines the alpha remap maximal range
  14316. * @returns the current particle system
  14317. */
  14318. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14319. /**
  14320. * Gets the current list of alpha remap gradients.
  14321. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14322. * @returns the list of alpha remap gradients
  14323. */
  14324. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14325. /**
  14326. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14327. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14328. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14329. * @returns the emitter
  14330. */
  14331. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14332. /**
  14333. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14334. * @param radius The radius of the hemisphere to emit from
  14335. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14336. * @returns the emitter
  14337. */
  14338. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14339. /**
  14340. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14341. * @param radius The radius of the sphere to emit from
  14342. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14343. * @returns the emitter
  14344. */
  14345. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14346. /**
  14347. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14348. * @param radius The radius of the sphere to emit from
  14349. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14350. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14351. * @returns the emitter
  14352. */
  14353. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14354. /**
  14355. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14356. * @param radius The radius of the emission cylinder
  14357. * @param height The height of the emission cylinder
  14358. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14359. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14360. * @returns the emitter
  14361. */
  14362. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14363. /**
  14364. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14365. * @param radius The radius of the cylinder to emit from
  14366. * @param height The height of the emission cylinder
  14367. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14368. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14369. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14370. * @returns the emitter
  14371. */
  14372. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14373. /**
  14374. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14375. * @param radius The radius of the cone to emit from
  14376. * @param angle The base angle of the cone
  14377. * @returns the emitter
  14378. */
  14379. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14380. /**
  14381. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14382. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14383. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14384. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14385. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14386. * @returns the emitter
  14387. */
  14388. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14389. /**
  14390. * Get hosting scene
  14391. * @returns the scene
  14392. */
  14393. getScene(): Scene;
  14394. }
  14395. }
  14396. declare module BABYLON {
  14397. /**
  14398. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14399. * @see https://doc.babylonjs.com/how_to/transformnode
  14400. */
  14401. export class TransformNode extends Node {
  14402. /**
  14403. * Object will not rotate to face the camera
  14404. */
  14405. static BILLBOARDMODE_NONE: number;
  14406. /**
  14407. * Object will rotate to face the camera but only on the x axis
  14408. */
  14409. static BILLBOARDMODE_X: number;
  14410. /**
  14411. * Object will rotate to face the camera but only on the y axis
  14412. */
  14413. static BILLBOARDMODE_Y: number;
  14414. /**
  14415. * Object will rotate to face the camera but only on the z axis
  14416. */
  14417. static BILLBOARDMODE_Z: number;
  14418. /**
  14419. * Object will rotate to face the camera
  14420. */
  14421. static BILLBOARDMODE_ALL: number;
  14422. /**
  14423. * Object will rotate to face the camera's position instead of orientation
  14424. */
  14425. static BILLBOARDMODE_USE_POSITION: number;
  14426. private static _TmpRotation;
  14427. private static _TmpScaling;
  14428. private static _TmpTranslation;
  14429. private _forward;
  14430. private _forwardInverted;
  14431. private _up;
  14432. private _right;
  14433. private _rightInverted;
  14434. private _position;
  14435. private _rotation;
  14436. private _rotationQuaternion;
  14437. protected _scaling: Vector3;
  14438. protected _isDirty: boolean;
  14439. private _transformToBoneReferal;
  14440. private _isAbsoluteSynced;
  14441. private _billboardMode;
  14442. /**
  14443. * Gets or sets the billboard mode. Default is 0.
  14444. *
  14445. * | Value | Type | Description |
  14446. * | --- | --- | --- |
  14447. * | 0 | BILLBOARDMODE_NONE | |
  14448. * | 1 | BILLBOARDMODE_X | |
  14449. * | 2 | BILLBOARDMODE_Y | |
  14450. * | 4 | BILLBOARDMODE_Z | |
  14451. * | 7 | BILLBOARDMODE_ALL | |
  14452. *
  14453. */
  14454. get billboardMode(): number;
  14455. set billboardMode(value: number);
  14456. private _preserveParentRotationForBillboard;
  14457. /**
  14458. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14459. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14460. */
  14461. get preserveParentRotationForBillboard(): boolean;
  14462. set preserveParentRotationForBillboard(value: boolean);
  14463. /**
  14464. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14465. */
  14466. scalingDeterminant: number;
  14467. private _infiniteDistance;
  14468. /**
  14469. * Gets or sets the distance of the object to max, often used by skybox
  14470. */
  14471. get infiniteDistance(): boolean;
  14472. set infiniteDistance(value: boolean);
  14473. /**
  14474. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14475. * By default the system will update normals to compensate
  14476. */
  14477. ignoreNonUniformScaling: boolean;
  14478. /**
  14479. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14480. */
  14481. reIntegrateRotationIntoRotationQuaternion: boolean;
  14482. /** @hidden */
  14483. _poseMatrix: Nullable<Matrix>;
  14484. /** @hidden */
  14485. _localMatrix: Matrix;
  14486. private _usePivotMatrix;
  14487. private _absolutePosition;
  14488. private _absoluteScaling;
  14489. private _absoluteRotationQuaternion;
  14490. private _pivotMatrix;
  14491. private _pivotMatrixInverse;
  14492. protected _postMultiplyPivotMatrix: boolean;
  14493. protected _isWorldMatrixFrozen: boolean;
  14494. /** @hidden */
  14495. _indexInSceneTransformNodesArray: number;
  14496. /**
  14497. * An event triggered after the world matrix is updated
  14498. */
  14499. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14500. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14501. /**
  14502. * Gets a string identifying the name of the class
  14503. * @returns "TransformNode" string
  14504. */
  14505. getClassName(): string;
  14506. /**
  14507. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14508. */
  14509. get position(): Vector3;
  14510. set position(newPosition: Vector3);
  14511. /**
  14512. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14513. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14514. */
  14515. get rotation(): Vector3;
  14516. set rotation(newRotation: Vector3);
  14517. /**
  14518. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14519. */
  14520. get scaling(): Vector3;
  14521. set scaling(newScaling: Vector3);
  14522. /**
  14523. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14524. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14525. */
  14526. get rotationQuaternion(): Nullable<Quaternion>;
  14527. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14528. /**
  14529. * The forward direction of that transform in world space.
  14530. */
  14531. get forward(): Vector3;
  14532. /**
  14533. * The up direction of that transform in world space.
  14534. */
  14535. get up(): Vector3;
  14536. /**
  14537. * The right direction of that transform in world space.
  14538. */
  14539. get right(): Vector3;
  14540. /**
  14541. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14542. * @param matrix the matrix to copy the pose from
  14543. * @returns this TransformNode.
  14544. */
  14545. updatePoseMatrix(matrix: Matrix): TransformNode;
  14546. /**
  14547. * Returns the mesh Pose matrix.
  14548. * @returns the pose matrix
  14549. */
  14550. getPoseMatrix(): Matrix;
  14551. /** @hidden */
  14552. _isSynchronized(): boolean;
  14553. /** @hidden */
  14554. _initCache(): void;
  14555. /**
  14556. * Flag the transform node as dirty (Forcing it to update everything)
  14557. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14558. * @returns this transform node
  14559. */
  14560. markAsDirty(property: string): TransformNode;
  14561. /**
  14562. * Returns the current mesh absolute position.
  14563. * Returns a Vector3.
  14564. */
  14565. get absolutePosition(): Vector3;
  14566. /**
  14567. * Returns the current mesh absolute scaling.
  14568. * Returns a Vector3.
  14569. */
  14570. get absoluteScaling(): Vector3;
  14571. /**
  14572. * Returns the current mesh absolute rotation.
  14573. * Returns a Quaternion.
  14574. */
  14575. get absoluteRotationQuaternion(): Quaternion;
  14576. /**
  14577. * Sets a new matrix to apply before all other transformation
  14578. * @param matrix defines the transform matrix
  14579. * @returns the current TransformNode
  14580. */
  14581. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14582. /**
  14583. * Sets a new pivot matrix to the current node
  14584. * @param matrix defines the new pivot matrix to use
  14585. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14586. * @returns the current TransformNode
  14587. */
  14588. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14589. /**
  14590. * Returns the mesh pivot matrix.
  14591. * Default : Identity.
  14592. * @returns the matrix
  14593. */
  14594. getPivotMatrix(): Matrix;
  14595. /**
  14596. * Instantiate (when possible) or clone that node with its hierarchy
  14597. * @param newParent defines the new parent to use for the instance (or clone)
  14598. * @param options defines options to configure how copy is done
  14599. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14600. * @returns an instance (or a clone) of the current node with its hiearchy
  14601. */
  14602. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14603. doNotInstantiate: boolean;
  14604. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14605. /**
  14606. * Prevents the World matrix to be computed any longer
  14607. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14608. * @returns the TransformNode.
  14609. */
  14610. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14611. /**
  14612. * Allows back the World matrix computation.
  14613. * @returns the TransformNode.
  14614. */
  14615. unfreezeWorldMatrix(): this;
  14616. /**
  14617. * True if the World matrix has been frozen.
  14618. */
  14619. get isWorldMatrixFrozen(): boolean;
  14620. /**
  14621. * Retuns the mesh absolute position in the World.
  14622. * @returns a Vector3.
  14623. */
  14624. getAbsolutePosition(): Vector3;
  14625. /**
  14626. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14627. * @param absolutePosition the absolute position to set
  14628. * @returns the TransformNode.
  14629. */
  14630. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14631. /**
  14632. * Sets the mesh position in its local space.
  14633. * @param vector3 the position to set in localspace
  14634. * @returns the TransformNode.
  14635. */
  14636. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14637. /**
  14638. * Returns the mesh position in the local space from the current World matrix values.
  14639. * @returns a new Vector3.
  14640. */
  14641. getPositionExpressedInLocalSpace(): Vector3;
  14642. /**
  14643. * Translates the mesh along the passed Vector3 in its local space.
  14644. * @param vector3 the distance to translate in localspace
  14645. * @returns the TransformNode.
  14646. */
  14647. locallyTranslate(vector3: Vector3): TransformNode;
  14648. private static _lookAtVectorCache;
  14649. /**
  14650. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14651. * @param targetPoint the position (must be in same space as current mesh) to look at
  14652. * @param yawCor optional yaw (y-axis) correction in radians
  14653. * @param pitchCor optional pitch (x-axis) correction in radians
  14654. * @param rollCor optional roll (z-axis) correction in radians
  14655. * @param space the choosen space of the target
  14656. * @returns the TransformNode.
  14657. */
  14658. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14659. /**
  14660. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14661. * This Vector3 is expressed in the World space.
  14662. * @param localAxis axis to rotate
  14663. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14664. */
  14665. getDirection(localAxis: Vector3): Vector3;
  14666. /**
  14667. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14668. * localAxis is expressed in the mesh local space.
  14669. * result is computed in the Wordl space from the mesh World matrix.
  14670. * @param localAxis axis to rotate
  14671. * @param result the resulting transformnode
  14672. * @returns this TransformNode.
  14673. */
  14674. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14675. /**
  14676. * Sets this transform node rotation to the given local axis.
  14677. * @param localAxis the axis in local space
  14678. * @param yawCor optional yaw (y-axis) correction in radians
  14679. * @param pitchCor optional pitch (x-axis) correction in radians
  14680. * @param rollCor optional roll (z-axis) correction in radians
  14681. * @returns this TransformNode
  14682. */
  14683. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14684. /**
  14685. * Sets a new pivot point to the current node
  14686. * @param point defines the new pivot point to use
  14687. * @param space defines if the point is in world or local space (local by default)
  14688. * @returns the current TransformNode
  14689. */
  14690. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14691. /**
  14692. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14693. * @returns the pivot point
  14694. */
  14695. getPivotPoint(): Vector3;
  14696. /**
  14697. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14698. * @param result the vector3 to store the result
  14699. * @returns this TransformNode.
  14700. */
  14701. getPivotPointToRef(result: Vector3): TransformNode;
  14702. /**
  14703. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14704. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14705. */
  14706. getAbsolutePivotPoint(): Vector3;
  14707. /**
  14708. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14709. * @param result vector3 to store the result
  14710. * @returns this TransformNode.
  14711. */
  14712. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14713. /**
  14714. * Defines the passed node as the parent of the current node.
  14715. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14716. * @see https://doc.babylonjs.com/how_to/parenting
  14717. * @param node the node ot set as the parent
  14718. * @returns this TransformNode.
  14719. */
  14720. setParent(node: Nullable<Node>): TransformNode;
  14721. private _nonUniformScaling;
  14722. /**
  14723. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14724. */
  14725. get nonUniformScaling(): boolean;
  14726. /** @hidden */
  14727. _updateNonUniformScalingState(value: boolean): boolean;
  14728. /**
  14729. * Attach the current TransformNode to another TransformNode associated with a bone
  14730. * @param bone Bone affecting the TransformNode
  14731. * @param affectedTransformNode TransformNode associated with the bone
  14732. * @returns this object
  14733. */
  14734. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14735. /**
  14736. * Detach the transform node if its associated with a bone
  14737. * @returns this object
  14738. */
  14739. detachFromBone(): TransformNode;
  14740. private static _rotationAxisCache;
  14741. /**
  14742. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14743. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14744. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14745. * The passed axis is also normalized.
  14746. * @param axis the axis to rotate around
  14747. * @param amount the amount to rotate in radians
  14748. * @param space Space to rotate in (Default: local)
  14749. * @returns the TransformNode.
  14750. */
  14751. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14752. /**
  14753. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14754. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14755. * The passed axis is also normalized. .
  14756. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14757. * @param point the point to rotate around
  14758. * @param axis the axis to rotate around
  14759. * @param amount the amount to rotate in radians
  14760. * @returns the TransformNode
  14761. */
  14762. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14763. /**
  14764. * Translates the mesh along the axis vector for the passed distance in the given space.
  14765. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14766. * @param axis the axis to translate in
  14767. * @param distance the distance to translate
  14768. * @param space Space to rotate in (Default: local)
  14769. * @returns the TransformNode.
  14770. */
  14771. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14772. /**
  14773. * Adds a rotation step to the mesh current rotation.
  14774. * x, y, z are Euler angles expressed in radians.
  14775. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14776. * This means this rotation is made in the mesh local space only.
  14777. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14778. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14779. * ```javascript
  14780. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14781. * ```
  14782. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14783. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14784. * @param x Rotation to add
  14785. * @param y Rotation to add
  14786. * @param z Rotation to add
  14787. * @returns the TransformNode.
  14788. */
  14789. addRotation(x: number, y: number, z: number): TransformNode;
  14790. /**
  14791. * @hidden
  14792. */
  14793. protected _getEffectiveParent(): Nullable<Node>;
  14794. /**
  14795. * Computes the world matrix of the node
  14796. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14797. * @returns the world matrix
  14798. */
  14799. computeWorldMatrix(force?: boolean): Matrix;
  14800. /**
  14801. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14802. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14803. */
  14804. resetLocalMatrix(independentOfChildren?: boolean): void;
  14805. protected _afterComputeWorldMatrix(): void;
  14806. /**
  14807. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14808. * @param func callback function to add
  14809. *
  14810. * @returns the TransformNode.
  14811. */
  14812. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14813. /**
  14814. * Removes a registered callback function.
  14815. * @param func callback function to remove
  14816. * @returns the TransformNode.
  14817. */
  14818. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14819. /**
  14820. * Gets the position of the current mesh in camera space
  14821. * @param camera defines the camera to use
  14822. * @returns a position
  14823. */
  14824. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14825. /**
  14826. * Returns the distance from the mesh to the active camera
  14827. * @param camera defines the camera to use
  14828. * @returns the distance
  14829. */
  14830. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14831. /**
  14832. * Clone the current transform node
  14833. * @param name Name of the new clone
  14834. * @param newParent New parent for the clone
  14835. * @param doNotCloneChildren Do not clone children hierarchy
  14836. * @returns the new transform node
  14837. */
  14838. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14839. /**
  14840. * Serializes the objects information.
  14841. * @param currentSerializationObject defines the object to serialize in
  14842. * @returns the serialized object
  14843. */
  14844. serialize(currentSerializationObject?: any): any;
  14845. /**
  14846. * Returns a new TransformNode object parsed from the source provided.
  14847. * @param parsedTransformNode is the source.
  14848. * @param scene the scne the object belongs to
  14849. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14850. * @returns a new TransformNode object parsed from the source provided.
  14851. */
  14852. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14853. /**
  14854. * Get all child-transformNodes of this node
  14855. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14856. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14857. * @returns an array of TransformNode
  14858. */
  14859. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14860. /**
  14861. * Releases resources associated with this transform node.
  14862. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14863. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14864. */
  14865. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14866. /**
  14867. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14868. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14869. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14870. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14871. * @returns the current mesh
  14872. */
  14873. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14874. private _syncAbsoluteScalingAndRotation;
  14875. }
  14876. }
  14877. declare module BABYLON {
  14878. /**
  14879. * Class used to override all child animations of a given target
  14880. */
  14881. export class AnimationPropertiesOverride {
  14882. /**
  14883. * Gets or sets a value indicating if animation blending must be used
  14884. */
  14885. enableBlending: boolean;
  14886. /**
  14887. * Gets or sets the blending speed to use when enableBlending is true
  14888. */
  14889. blendingSpeed: number;
  14890. /**
  14891. * Gets or sets the default loop mode to use
  14892. */
  14893. loopMode: number;
  14894. }
  14895. }
  14896. declare module BABYLON {
  14897. /**
  14898. * Class used to store bone information
  14899. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14900. */
  14901. export class Bone extends Node {
  14902. /**
  14903. * defines the bone name
  14904. */
  14905. name: string;
  14906. private static _tmpVecs;
  14907. private static _tmpQuat;
  14908. private static _tmpMats;
  14909. /**
  14910. * Gets the list of child bones
  14911. */
  14912. children: Bone[];
  14913. /** Gets the animations associated with this bone */
  14914. animations: Animation[];
  14915. /**
  14916. * Gets or sets bone length
  14917. */
  14918. length: number;
  14919. /**
  14920. * @hidden Internal only
  14921. * Set this value to map this bone to a different index in the transform matrices
  14922. * Set this value to -1 to exclude the bone from the transform matrices
  14923. */
  14924. _index: Nullable<number>;
  14925. private _skeleton;
  14926. private _localMatrix;
  14927. private _restPose;
  14928. private _baseMatrix;
  14929. private _absoluteTransform;
  14930. private _invertedAbsoluteTransform;
  14931. private _parent;
  14932. private _scalingDeterminant;
  14933. private _worldTransform;
  14934. private _localScaling;
  14935. private _localRotation;
  14936. private _localPosition;
  14937. private _needToDecompose;
  14938. private _needToCompose;
  14939. /** @hidden */
  14940. _linkedTransformNode: Nullable<TransformNode>;
  14941. /** @hidden */
  14942. _waitingTransformNodeId: Nullable<string>;
  14943. /** @hidden */
  14944. get _matrix(): Matrix;
  14945. /** @hidden */
  14946. set _matrix(value: Matrix);
  14947. /**
  14948. * Create a new bone
  14949. * @param name defines the bone name
  14950. * @param skeleton defines the parent skeleton
  14951. * @param parentBone defines the parent (can be null if the bone is the root)
  14952. * @param localMatrix defines the local matrix
  14953. * @param restPose defines the rest pose matrix
  14954. * @param baseMatrix defines the base matrix
  14955. * @param index defines index of the bone in the hiearchy
  14956. */
  14957. constructor(
  14958. /**
  14959. * defines the bone name
  14960. */
  14961. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14962. /**
  14963. * Gets the current object class name.
  14964. * @return the class name
  14965. */
  14966. getClassName(): string;
  14967. /**
  14968. * Gets the parent skeleton
  14969. * @returns a skeleton
  14970. */
  14971. getSkeleton(): Skeleton;
  14972. /**
  14973. * Gets parent bone
  14974. * @returns a bone or null if the bone is the root of the bone hierarchy
  14975. */
  14976. getParent(): Nullable<Bone>;
  14977. /**
  14978. * Returns an array containing the root bones
  14979. * @returns an array containing the root bones
  14980. */
  14981. getChildren(): Array<Bone>;
  14982. /**
  14983. * Gets the node index in matrix array generated for rendering
  14984. * @returns the node index
  14985. */
  14986. getIndex(): number;
  14987. /**
  14988. * Sets the parent bone
  14989. * @param parent defines the parent (can be null if the bone is the root)
  14990. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14991. */
  14992. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14993. /**
  14994. * Gets the local matrix
  14995. * @returns a matrix
  14996. */
  14997. getLocalMatrix(): Matrix;
  14998. /**
  14999. * Gets the base matrix (initial matrix which remains unchanged)
  15000. * @returns a matrix
  15001. */
  15002. getBaseMatrix(): Matrix;
  15003. /**
  15004. * Gets the rest pose matrix
  15005. * @returns a matrix
  15006. */
  15007. getRestPose(): Matrix;
  15008. /**
  15009. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15010. */
  15011. getWorldMatrix(): Matrix;
  15012. /**
  15013. * Sets the local matrix to rest pose matrix
  15014. */
  15015. returnToRest(): void;
  15016. /**
  15017. * Gets the inverse of the absolute transform matrix.
  15018. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15019. * @returns a matrix
  15020. */
  15021. getInvertedAbsoluteTransform(): Matrix;
  15022. /**
  15023. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15024. * @returns a matrix
  15025. */
  15026. getAbsoluteTransform(): Matrix;
  15027. /**
  15028. * Links with the given transform node.
  15029. * The local matrix of this bone is copied from the transform node every frame.
  15030. * @param transformNode defines the transform node to link to
  15031. */
  15032. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15033. /**
  15034. * Gets the node used to drive the bone's transformation
  15035. * @returns a transform node or null
  15036. */
  15037. getTransformNode(): Nullable<TransformNode>;
  15038. /** Gets or sets current position (in local space) */
  15039. get position(): Vector3;
  15040. set position(newPosition: Vector3);
  15041. /** Gets or sets current rotation (in local space) */
  15042. get rotation(): Vector3;
  15043. set rotation(newRotation: Vector3);
  15044. /** Gets or sets current rotation quaternion (in local space) */
  15045. get rotationQuaternion(): Quaternion;
  15046. set rotationQuaternion(newRotation: Quaternion);
  15047. /** Gets or sets current scaling (in local space) */
  15048. get scaling(): Vector3;
  15049. set scaling(newScaling: Vector3);
  15050. /**
  15051. * Gets the animation properties override
  15052. */
  15053. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15054. private _decompose;
  15055. private _compose;
  15056. /**
  15057. * Update the base and local matrices
  15058. * @param matrix defines the new base or local matrix
  15059. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15060. * @param updateLocalMatrix defines if the local matrix should be updated
  15061. */
  15062. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15063. /** @hidden */
  15064. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15065. /**
  15066. * Flag the bone as dirty (Forcing it to update everything)
  15067. */
  15068. markAsDirty(): void;
  15069. /** @hidden */
  15070. _markAsDirtyAndCompose(): void;
  15071. private _markAsDirtyAndDecompose;
  15072. /**
  15073. * Translate the bone in local or world space
  15074. * @param vec The amount to translate the bone
  15075. * @param space The space that the translation is in
  15076. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15077. */
  15078. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15079. /**
  15080. * Set the postion of the bone in local or world space
  15081. * @param position The position to set the bone
  15082. * @param space The space that the position is in
  15083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15084. */
  15085. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15086. /**
  15087. * Set the absolute position of the bone (world space)
  15088. * @param position The position to set the bone
  15089. * @param mesh The mesh that this bone is attached to
  15090. */
  15091. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15092. /**
  15093. * Scale the bone on the x, y and z axes (in local space)
  15094. * @param x The amount to scale the bone on the x axis
  15095. * @param y The amount to scale the bone on the y axis
  15096. * @param z The amount to scale the bone on the z axis
  15097. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15098. */
  15099. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15100. /**
  15101. * Set the bone scaling in local space
  15102. * @param scale defines the scaling vector
  15103. */
  15104. setScale(scale: Vector3): void;
  15105. /**
  15106. * Gets the current scaling in local space
  15107. * @returns the current scaling vector
  15108. */
  15109. getScale(): Vector3;
  15110. /**
  15111. * Gets the current scaling in local space and stores it in a target vector
  15112. * @param result defines the target vector
  15113. */
  15114. getScaleToRef(result: Vector3): void;
  15115. /**
  15116. * Set the yaw, pitch, and roll of the bone in local or world space
  15117. * @param yaw The rotation of the bone on the y axis
  15118. * @param pitch The rotation of the bone on the x axis
  15119. * @param roll The rotation of the bone on the z axis
  15120. * @param space The space that the axes of rotation are in
  15121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15122. */
  15123. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15124. /**
  15125. * Add a rotation to the bone on an axis in local or world space
  15126. * @param axis The axis to rotate the bone on
  15127. * @param amount The amount to rotate the bone
  15128. * @param space The space that the axis is in
  15129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15130. */
  15131. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15132. /**
  15133. * Set the rotation of the bone to a particular axis angle in local or world space
  15134. * @param axis The axis to rotate the bone on
  15135. * @param angle The angle that the bone should be rotated to
  15136. * @param space The space that the axis is in
  15137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15138. */
  15139. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15140. /**
  15141. * Set the euler rotation of the bone in local of world space
  15142. * @param rotation The euler rotation that the bone should be set to
  15143. * @param space The space that the rotation is in
  15144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15145. */
  15146. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15147. /**
  15148. * Set the quaternion rotation of the bone in local of world space
  15149. * @param quat The quaternion rotation that the bone should be set to
  15150. * @param space The space that the rotation is in
  15151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15152. */
  15153. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15154. /**
  15155. * Set the rotation matrix of the bone in local of world space
  15156. * @param rotMat The rotation matrix that the bone should be set to
  15157. * @param space The space that the rotation is in
  15158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15159. */
  15160. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15161. private _rotateWithMatrix;
  15162. private _getNegativeRotationToRef;
  15163. /**
  15164. * Get the position of the bone in local or world space
  15165. * @param space The space that the returned position is in
  15166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15167. * @returns The position of the bone
  15168. */
  15169. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15170. /**
  15171. * Copy the position of the bone to a vector3 in local or world space
  15172. * @param space The space that the returned position is in
  15173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15174. * @param result The vector3 to copy the position to
  15175. */
  15176. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15177. /**
  15178. * Get the absolute position of the bone (world space)
  15179. * @param mesh The mesh that this bone is attached to
  15180. * @returns The absolute position of the bone
  15181. */
  15182. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15183. /**
  15184. * Copy the absolute position of the bone (world space) to the result param
  15185. * @param mesh The mesh that this bone is attached to
  15186. * @param result The vector3 to copy the absolute position to
  15187. */
  15188. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15189. /**
  15190. * Compute the absolute transforms of this bone and its children
  15191. */
  15192. computeAbsoluteTransforms(): void;
  15193. /**
  15194. * Get the world direction from an axis that is in the local space of the bone
  15195. * @param localAxis The local direction that is used to compute the world direction
  15196. * @param mesh The mesh that this bone is attached to
  15197. * @returns The world direction
  15198. */
  15199. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15200. /**
  15201. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15202. * @param localAxis The local direction that is used to compute the world direction
  15203. * @param mesh The mesh that this bone is attached to
  15204. * @param result The vector3 that the world direction will be copied to
  15205. */
  15206. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15207. /**
  15208. * Get the euler rotation of the bone in local or world space
  15209. * @param space The space that the rotation should be in
  15210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15211. * @returns The euler rotation
  15212. */
  15213. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15214. /**
  15215. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15216. * @param space The space that the rotation should be in
  15217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15218. * @param result The vector3 that the rotation should be copied to
  15219. */
  15220. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15221. /**
  15222. * Get the quaternion rotation of the bone in either local or world space
  15223. * @param space The space that the rotation should be in
  15224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15225. * @returns The quaternion rotation
  15226. */
  15227. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15228. /**
  15229. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15230. * @param space The space that the rotation should be in
  15231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15232. * @param result The quaternion that the rotation should be copied to
  15233. */
  15234. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15235. /**
  15236. * Get the rotation matrix of the bone in local or world space
  15237. * @param space The space that the rotation should be in
  15238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15239. * @returns The rotation matrix
  15240. */
  15241. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15242. /**
  15243. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15244. * @param space The space that the rotation should be in
  15245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15246. * @param result The quaternion that the rotation should be copied to
  15247. */
  15248. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15249. /**
  15250. * Get the world position of a point that is in the local space of the bone
  15251. * @param position The local position
  15252. * @param mesh The mesh that this bone is attached to
  15253. * @returns The world position
  15254. */
  15255. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15256. /**
  15257. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15258. * @param position The local position
  15259. * @param mesh The mesh that this bone is attached to
  15260. * @param result The vector3 that the world position should be copied to
  15261. */
  15262. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15263. /**
  15264. * Get the local position of a point that is in world space
  15265. * @param position The world position
  15266. * @param mesh The mesh that this bone is attached to
  15267. * @returns The local position
  15268. */
  15269. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15270. /**
  15271. * Get the local position of a point that is in world space and copy it to the result param
  15272. * @param position The world position
  15273. * @param mesh The mesh that this bone is attached to
  15274. * @param result The vector3 that the local position should be copied to
  15275. */
  15276. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15277. }
  15278. }
  15279. declare module BABYLON {
  15280. /**
  15281. * Defines a runtime animation
  15282. */
  15283. export class RuntimeAnimation {
  15284. private _events;
  15285. /**
  15286. * The current frame of the runtime animation
  15287. */
  15288. private _currentFrame;
  15289. /**
  15290. * The animation used by the runtime animation
  15291. */
  15292. private _animation;
  15293. /**
  15294. * The target of the runtime animation
  15295. */
  15296. private _target;
  15297. /**
  15298. * The initiating animatable
  15299. */
  15300. private _host;
  15301. /**
  15302. * The original value of the runtime animation
  15303. */
  15304. private _originalValue;
  15305. /**
  15306. * The original blend value of the runtime animation
  15307. */
  15308. private _originalBlendValue;
  15309. /**
  15310. * The offsets cache of the runtime animation
  15311. */
  15312. private _offsetsCache;
  15313. /**
  15314. * The high limits cache of the runtime animation
  15315. */
  15316. private _highLimitsCache;
  15317. /**
  15318. * Specifies if the runtime animation has been stopped
  15319. */
  15320. private _stopped;
  15321. /**
  15322. * The blending factor of the runtime animation
  15323. */
  15324. private _blendingFactor;
  15325. /**
  15326. * The BabylonJS scene
  15327. */
  15328. private _scene;
  15329. /**
  15330. * The current value of the runtime animation
  15331. */
  15332. private _currentValue;
  15333. /** @hidden */
  15334. _animationState: _IAnimationState;
  15335. /**
  15336. * The active target of the runtime animation
  15337. */
  15338. private _activeTargets;
  15339. private _currentActiveTarget;
  15340. private _directTarget;
  15341. /**
  15342. * The target path of the runtime animation
  15343. */
  15344. private _targetPath;
  15345. /**
  15346. * The weight of the runtime animation
  15347. */
  15348. private _weight;
  15349. /**
  15350. * The ratio offset of the runtime animation
  15351. */
  15352. private _ratioOffset;
  15353. /**
  15354. * The previous delay of the runtime animation
  15355. */
  15356. private _previousDelay;
  15357. /**
  15358. * The previous ratio of the runtime animation
  15359. */
  15360. private _previousRatio;
  15361. private _enableBlending;
  15362. private _keys;
  15363. private _minFrame;
  15364. private _maxFrame;
  15365. private _minValue;
  15366. private _maxValue;
  15367. private _targetIsArray;
  15368. /**
  15369. * Gets the current frame of the runtime animation
  15370. */
  15371. get currentFrame(): number;
  15372. /**
  15373. * Gets the weight of the runtime animation
  15374. */
  15375. get weight(): number;
  15376. /**
  15377. * Gets the current value of the runtime animation
  15378. */
  15379. get currentValue(): any;
  15380. /**
  15381. * Gets the target path of the runtime animation
  15382. */
  15383. get targetPath(): string;
  15384. /**
  15385. * Gets the actual target of the runtime animation
  15386. */
  15387. get target(): any;
  15388. /**
  15389. * Gets the additive state of the runtime animation
  15390. */
  15391. get isAdditive(): boolean;
  15392. /** @hidden */
  15393. _onLoop: () => void;
  15394. /**
  15395. * Create a new RuntimeAnimation object
  15396. * @param target defines the target of the animation
  15397. * @param animation defines the source animation object
  15398. * @param scene defines the hosting scene
  15399. * @param host defines the initiating Animatable
  15400. */
  15401. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15402. private _preparePath;
  15403. /**
  15404. * Gets the animation from the runtime animation
  15405. */
  15406. get animation(): Animation;
  15407. /**
  15408. * Resets the runtime animation to the beginning
  15409. * @param restoreOriginal defines whether to restore the target property to the original value
  15410. */
  15411. reset(restoreOriginal?: boolean): void;
  15412. /**
  15413. * Specifies if the runtime animation is stopped
  15414. * @returns Boolean specifying if the runtime animation is stopped
  15415. */
  15416. isStopped(): boolean;
  15417. /**
  15418. * Disposes of the runtime animation
  15419. */
  15420. dispose(): void;
  15421. /**
  15422. * Apply the interpolated value to the target
  15423. * @param currentValue defines the value computed by the animation
  15424. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15425. */
  15426. setValue(currentValue: any, weight: number): void;
  15427. private _getOriginalValues;
  15428. private _setValue;
  15429. /**
  15430. * Gets the loop pmode of the runtime animation
  15431. * @returns Loop Mode
  15432. */
  15433. private _getCorrectLoopMode;
  15434. /**
  15435. * Move the current animation to a given frame
  15436. * @param frame defines the frame to move to
  15437. */
  15438. goToFrame(frame: number): void;
  15439. /**
  15440. * @hidden Internal use only
  15441. */
  15442. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15443. /**
  15444. * Execute the current animation
  15445. * @param delay defines the delay to add to the current frame
  15446. * @param from defines the lower bound of the animation range
  15447. * @param to defines the upper bound of the animation range
  15448. * @param loop defines if the current animation must loop
  15449. * @param speedRatio defines the current speed ratio
  15450. * @param weight defines the weight of the animation (default is -1 so no weight)
  15451. * @param onLoop optional callback called when animation loops
  15452. * @returns a boolean indicating if the animation is running
  15453. */
  15454. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15455. }
  15456. }
  15457. declare module BABYLON {
  15458. /**
  15459. * Class used to store an actual running animation
  15460. */
  15461. export class Animatable {
  15462. /** defines the target object */
  15463. target: any;
  15464. /** defines the starting frame number (default is 0) */
  15465. fromFrame: number;
  15466. /** defines the ending frame number (default is 100) */
  15467. toFrame: number;
  15468. /** defines if the animation must loop (default is false) */
  15469. loopAnimation: boolean;
  15470. /** defines a callback to call when animation ends if it is not looping */
  15471. onAnimationEnd?: (() => void) | null | undefined;
  15472. /** defines a callback to call when animation loops */
  15473. onAnimationLoop?: (() => void) | null | undefined;
  15474. /** defines whether the animation should be evaluated additively */
  15475. isAdditive: boolean;
  15476. private _localDelayOffset;
  15477. private _pausedDelay;
  15478. private _runtimeAnimations;
  15479. private _paused;
  15480. private _scene;
  15481. private _speedRatio;
  15482. private _weight;
  15483. private _syncRoot;
  15484. /**
  15485. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15486. * This will only apply for non looping animation (default is true)
  15487. */
  15488. disposeOnEnd: boolean;
  15489. /**
  15490. * Gets a boolean indicating if the animation has started
  15491. */
  15492. animationStarted: boolean;
  15493. /**
  15494. * Observer raised when the animation ends
  15495. */
  15496. onAnimationEndObservable: Observable<Animatable>;
  15497. /**
  15498. * Observer raised when the animation loops
  15499. */
  15500. onAnimationLoopObservable: Observable<Animatable>;
  15501. /**
  15502. * Gets the root Animatable used to synchronize and normalize animations
  15503. */
  15504. get syncRoot(): Nullable<Animatable>;
  15505. /**
  15506. * Gets the current frame of the first RuntimeAnimation
  15507. * Used to synchronize Animatables
  15508. */
  15509. get masterFrame(): number;
  15510. /**
  15511. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15512. */
  15513. get weight(): number;
  15514. set weight(value: number);
  15515. /**
  15516. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15517. */
  15518. get speedRatio(): number;
  15519. set speedRatio(value: number);
  15520. /**
  15521. * Creates a new Animatable
  15522. * @param scene defines the hosting scene
  15523. * @param target defines the target object
  15524. * @param fromFrame defines the starting frame number (default is 0)
  15525. * @param toFrame defines the ending frame number (default is 100)
  15526. * @param loopAnimation defines if the animation must loop (default is false)
  15527. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15528. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15529. * @param animations defines a group of animation to add to the new Animatable
  15530. * @param onAnimationLoop defines a callback to call when animation loops
  15531. * @param isAdditive defines whether the animation should be evaluated additively
  15532. */
  15533. constructor(scene: Scene,
  15534. /** defines the target object */
  15535. target: any,
  15536. /** defines the starting frame number (default is 0) */
  15537. fromFrame?: number,
  15538. /** defines the ending frame number (default is 100) */
  15539. toFrame?: number,
  15540. /** defines if the animation must loop (default is false) */
  15541. loopAnimation?: boolean, speedRatio?: number,
  15542. /** defines a callback to call when animation ends if it is not looping */
  15543. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15544. /** defines a callback to call when animation loops */
  15545. onAnimationLoop?: (() => void) | null | undefined,
  15546. /** defines whether the animation should be evaluated additively */
  15547. isAdditive?: boolean);
  15548. /**
  15549. * Synchronize and normalize current Animatable with a source Animatable
  15550. * This is useful when using animation weights and when animations are not of the same length
  15551. * @param root defines the root Animatable to synchronize with
  15552. * @returns the current Animatable
  15553. */
  15554. syncWith(root: Animatable): Animatable;
  15555. /**
  15556. * Gets the list of runtime animations
  15557. * @returns an array of RuntimeAnimation
  15558. */
  15559. getAnimations(): RuntimeAnimation[];
  15560. /**
  15561. * Adds more animations to the current animatable
  15562. * @param target defines the target of the animations
  15563. * @param animations defines the new animations to add
  15564. */
  15565. appendAnimations(target: any, animations: Animation[]): void;
  15566. /**
  15567. * Gets the source animation for a specific property
  15568. * @param property defines the propertyu to look for
  15569. * @returns null or the source animation for the given property
  15570. */
  15571. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15572. /**
  15573. * Gets the runtime animation for a specific property
  15574. * @param property defines the propertyu to look for
  15575. * @returns null or the runtime animation for the given property
  15576. */
  15577. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15578. /**
  15579. * Resets the animatable to its original state
  15580. */
  15581. reset(): void;
  15582. /**
  15583. * Allows the animatable to blend with current running animations
  15584. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15585. * @param blendingSpeed defines the blending speed to use
  15586. */
  15587. enableBlending(blendingSpeed: number): void;
  15588. /**
  15589. * Disable animation blending
  15590. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15591. */
  15592. disableBlending(): void;
  15593. /**
  15594. * Jump directly to a given frame
  15595. * @param frame defines the frame to jump to
  15596. */
  15597. goToFrame(frame: number): void;
  15598. /**
  15599. * Pause the animation
  15600. */
  15601. pause(): void;
  15602. /**
  15603. * Restart the animation
  15604. */
  15605. restart(): void;
  15606. private _raiseOnAnimationEnd;
  15607. /**
  15608. * Stop and delete the current animation
  15609. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15610. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  15611. */
  15612. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15613. /**
  15614. * Wait asynchronously for the animation to end
  15615. * @returns a promise which will be fullfilled when the animation ends
  15616. */
  15617. waitAsync(): Promise<Animatable>;
  15618. /** @hidden */
  15619. _animate(delay: number): boolean;
  15620. }
  15621. interface Scene {
  15622. /** @hidden */
  15623. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15624. /** @hidden */
  15625. _processLateAnimationBindingsForMatrices(holder: {
  15626. totalWeight: number;
  15627. totalAdditiveWeight: number;
  15628. animations: RuntimeAnimation[];
  15629. additiveAnimations: RuntimeAnimation[];
  15630. originalValue: Matrix;
  15631. }): any;
  15632. /** @hidden */
  15633. _processLateAnimationBindingsForQuaternions(holder: {
  15634. totalWeight: number;
  15635. totalAdditiveWeight: number;
  15636. animations: RuntimeAnimation[];
  15637. additiveAnimations: RuntimeAnimation[];
  15638. originalValue: Quaternion;
  15639. }, refQuaternion: Quaternion): Quaternion;
  15640. /** @hidden */
  15641. _processLateAnimationBindings(): void;
  15642. /**
  15643. * Will start the animation sequence of a given target
  15644. * @param target defines the target
  15645. * @param from defines from which frame should animation start
  15646. * @param to defines until which frame should animation run.
  15647. * @param weight defines the weight to apply to the animation (1.0 by default)
  15648. * @param loop defines if the animation loops
  15649. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15650. * @param onAnimationEnd defines the function to be executed when the animation ends
  15651. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15652. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15653. * @param onAnimationLoop defines the callback to call when an animation loops
  15654. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15655. * @returns the animatable object created for this animation
  15656. */
  15657. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15658. /**
  15659. * Will start the animation sequence of a given target
  15660. * @param target defines the target
  15661. * @param from defines from which frame should animation start
  15662. * @param to defines until which frame should animation run.
  15663. * @param loop defines if the animation loops
  15664. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15665. * @param onAnimationEnd defines the function to be executed when the animation ends
  15666. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15667. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15668. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15669. * @param onAnimationLoop defines the callback to call when an animation loops
  15670. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15671. * @returns the animatable object created for this animation
  15672. */
  15673. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15674. /**
  15675. * Will start the animation sequence of a given target and its hierarchy
  15676. * @param target defines the target
  15677. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15678. * @param from defines from which frame should animation start
  15679. * @param to defines until which frame should animation run.
  15680. * @param loop defines if the animation loops
  15681. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15682. * @param onAnimationEnd defines the function to be executed when the animation ends
  15683. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15684. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15685. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15686. * @param onAnimationLoop defines the callback to call when an animation loops
  15687. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15688. * @returns the list of created animatables
  15689. */
  15690. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15691. /**
  15692. * Begin a new animation on a given node
  15693. * @param target defines the target where the animation will take place
  15694. * @param animations defines the list of animations to start
  15695. * @param from defines the initial value
  15696. * @param to defines the final value
  15697. * @param loop defines if you want animation to loop (off by default)
  15698. * @param speedRatio defines the speed ratio to apply to all animations
  15699. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15700. * @param onAnimationLoop defines the callback to call when an animation loops
  15701. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15702. * @returns the list of created animatables
  15703. */
  15704. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15705. /**
  15706. * Begin a new animation on a given node and its hierarchy
  15707. * @param target defines the root node where the animation will take place
  15708. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15709. * @param animations defines the list of animations to start
  15710. * @param from defines the initial value
  15711. * @param to defines the final value
  15712. * @param loop defines if you want animation to loop (off by default)
  15713. * @param speedRatio defines the speed ratio to apply to all animations
  15714. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15715. * @param onAnimationLoop defines the callback to call when an animation loops
  15716. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15717. * @returns the list of animatables created for all nodes
  15718. */
  15719. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15720. /**
  15721. * Gets the animatable associated with a specific target
  15722. * @param target defines the target of the animatable
  15723. * @returns the required animatable if found
  15724. */
  15725. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15726. /**
  15727. * Gets all animatables associated with a given target
  15728. * @param target defines the target to look animatables for
  15729. * @returns an array of Animatables
  15730. */
  15731. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15732. /**
  15733. * Stops and removes all animations that have been applied to the scene
  15734. */
  15735. stopAllAnimations(): void;
  15736. /**
  15737. * Gets the current delta time used by animation engine
  15738. */
  15739. deltaTime: number;
  15740. }
  15741. interface Bone {
  15742. /**
  15743. * Copy an animation range from another bone
  15744. * @param source defines the source bone
  15745. * @param rangeName defines the range name to copy
  15746. * @param frameOffset defines the frame offset
  15747. * @param rescaleAsRequired defines if rescaling must be applied if required
  15748. * @param skelDimensionsRatio defines the scaling ratio
  15749. * @returns true if operation was successful
  15750. */
  15751. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15752. }
  15753. }
  15754. declare module BABYLON {
  15755. /**
  15756. * Class used to handle skinning animations
  15757. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15758. */
  15759. export class Skeleton implements IAnimatable {
  15760. /** defines the skeleton name */
  15761. name: string;
  15762. /** defines the skeleton Id */
  15763. id: string;
  15764. /**
  15765. * Defines the list of child bones
  15766. */
  15767. bones: Bone[];
  15768. /**
  15769. * Defines an estimate of the dimension of the skeleton at rest
  15770. */
  15771. dimensionsAtRest: Vector3;
  15772. /**
  15773. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15774. */
  15775. needInitialSkinMatrix: boolean;
  15776. /**
  15777. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15778. */
  15779. overrideMesh: Nullable<AbstractMesh>;
  15780. /**
  15781. * Gets the list of animations attached to this skeleton
  15782. */
  15783. animations: Array<Animation>;
  15784. private _scene;
  15785. private _isDirty;
  15786. private _transformMatrices;
  15787. private _transformMatrixTexture;
  15788. private _meshesWithPoseMatrix;
  15789. private _animatables;
  15790. private _identity;
  15791. private _synchronizedWithMesh;
  15792. private _ranges;
  15793. private _lastAbsoluteTransformsUpdateId;
  15794. private _canUseTextureForBones;
  15795. private _uniqueId;
  15796. /** @hidden */
  15797. _numBonesWithLinkedTransformNode: number;
  15798. /** @hidden */
  15799. _hasWaitingData: Nullable<boolean>;
  15800. /**
  15801. * Specifies if the skeleton should be serialized
  15802. */
  15803. doNotSerialize: boolean;
  15804. private _useTextureToStoreBoneMatrices;
  15805. /**
  15806. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15807. * Please note that this option is not available if the hardware does not support it
  15808. */
  15809. get useTextureToStoreBoneMatrices(): boolean;
  15810. set useTextureToStoreBoneMatrices(value: boolean);
  15811. private _animationPropertiesOverride;
  15812. /**
  15813. * Gets or sets the animation properties override
  15814. */
  15815. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15816. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15817. /**
  15818. * List of inspectable custom properties (used by the Inspector)
  15819. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15820. */
  15821. inspectableCustomProperties: IInspectable[];
  15822. /**
  15823. * An observable triggered before computing the skeleton's matrices
  15824. */
  15825. onBeforeComputeObservable: Observable<Skeleton>;
  15826. /**
  15827. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15828. */
  15829. get isUsingTextureForMatrices(): boolean;
  15830. /**
  15831. * Gets the unique ID of this skeleton
  15832. */
  15833. get uniqueId(): number;
  15834. /**
  15835. * Creates a new skeleton
  15836. * @param name defines the skeleton name
  15837. * @param id defines the skeleton Id
  15838. * @param scene defines the hosting scene
  15839. */
  15840. constructor(
  15841. /** defines the skeleton name */
  15842. name: string,
  15843. /** defines the skeleton Id */
  15844. id: string, scene: Scene);
  15845. /**
  15846. * Gets the current object class name.
  15847. * @return the class name
  15848. */
  15849. getClassName(): string;
  15850. /**
  15851. * Returns an array containing the root bones
  15852. * @returns an array containing the root bones
  15853. */
  15854. getChildren(): Array<Bone>;
  15855. /**
  15856. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15857. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15858. * @returns a Float32Array containing matrices data
  15859. */
  15860. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15861. /**
  15862. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15863. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15864. * @returns a raw texture containing the data
  15865. */
  15866. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15867. /**
  15868. * Gets the current hosting scene
  15869. * @returns a scene object
  15870. */
  15871. getScene(): Scene;
  15872. /**
  15873. * Gets a string representing the current skeleton data
  15874. * @param fullDetails defines a boolean indicating if we want a verbose version
  15875. * @returns a string representing the current skeleton data
  15876. */
  15877. toString(fullDetails?: boolean): string;
  15878. /**
  15879. * Get bone's index searching by name
  15880. * @param name defines bone's name to search for
  15881. * @return the indice of the bone. Returns -1 if not found
  15882. */
  15883. getBoneIndexByName(name: string): number;
  15884. /**
  15885. * Creater a new animation range
  15886. * @param name defines the name of the range
  15887. * @param from defines the start key
  15888. * @param to defines the end key
  15889. */
  15890. createAnimationRange(name: string, from: number, to: number): void;
  15891. /**
  15892. * Delete a specific animation range
  15893. * @param name defines the name of the range
  15894. * @param deleteFrames defines if frames must be removed as well
  15895. */
  15896. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15897. /**
  15898. * Gets a specific animation range
  15899. * @param name defines the name of the range to look for
  15900. * @returns the requested animation range or null if not found
  15901. */
  15902. getAnimationRange(name: string): Nullable<AnimationRange>;
  15903. /**
  15904. * Gets the list of all animation ranges defined on this skeleton
  15905. * @returns an array
  15906. */
  15907. getAnimationRanges(): Nullable<AnimationRange>[];
  15908. /**
  15909. * Copy animation range from a source skeleton.
  15910. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15911. * @param source defines the source skeleton
  15912. * @param name defines the name of the range to copy
  15913. * @param rescaleAsRequired defines if rescaling must be applied if required
  15914. * @returns true if operation was successful
  15915. */
  15916. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15917. /**
  15918. * Forces the skeleton to go to rest pose
  15919. */
  15920. returnToRest(): void;
  15921. private _getHighestAnimationFrame;
  15922. /**
  15923. * Begin a specific animation range
  15924. * @param name defines the name of the range to start
  15925. * @param loop defines if looping must be turned on (false by default)
  15926. * @param speedRatio defines the speed ratio to apply (1 by default)
  15927. * @param onAnimationEnd defines a callback which will be called when animation will end
  15928. * @returns a new animatable
  15929. */
  15930. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15931. /**
  15932. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15933. * @param skeleton defines the Skeleton containing the animation range to convert
  15934. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15935. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15936. * @returns the original skeleton
  15937. */
  15938. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15939. /** @hidden */
  15940. _markAsDirty(): void;
  15941. /** @hidden */
  15942. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15943. /** @hidden */
  15944. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15945. private _computeTransformMatrices;
  15946. /**
  15947. * Build all resources required to render a skeleton
  15948. */
  15949. prepare(): void;
  15950. /**
  15951. * Gets the list of animatables currently running for this skeleton
  15952. * @returns an array of animatables
  15953. */
  15954. getAnimatables(): IAnimatable[];
  15955. /**
  15956. * Clone the current skeleton
  15957. * @param name defines the name of the new skeleton
  15958. * @param id defines the id of the new skeleton
  15959. * @returns the new skeleton
  15960. */
  15961. clone(name: string, id?: string): Skeleton;
  15962. /**
  15963. * Enable animation blending for this skeleton
  15964. * @param blendingSpeed defines the blending speed to apply
  15965. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15966. */
  15967. enableBlending(blendingSpeed?: number): void;
  15968. /**
  15969. * Releases all resources associated with the current skeleton
  15970. */
  15971. dispose(): void;
  15972. /**
  15973. * Serialize the skeleton in a JSON object
  15974. * @returns a JSON object
  15975. */
  15976. serialize(): any;
  15977. /**
  15978. * Creates a new skeleton from serialized data
  15979. * @param parsedSkeleton defines the serialized data
  15980. * @param scene defines the hosting scene
  15981. * @returns a new skeleton
  15982. */
  15983. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15984. /**
  15985. * Compute all node absolute transforms
  15986. * @param forceUpdate defines if computation must be done even if cache is up to date
  15987. */
  15988. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15989. /**
  15990. * Gets the root pose matrix
  15991. * @returns a matrix
  15992. */
  15993. getPoseMatrix(): Nullable<Matrix>;
  15994. /**
  15995. * Sorts bones per internal index
  15996. */
  15997. sortBones(): void;
  15998. private _sortBones;
  15999. }
  16000. }
  16001. declare module BABYLON {
  16002. /**
  16003. * Creates an instance based on a source mesh.
  16004. */
  16005. export class InstancedMesh extends AbstractMesh {
  16006. private _sourceMesh;
  16007. private _currentLOD;
  16008. /** @hidden */
  16009. _indexInSourceMeshInstanceArray: number;
  16010. constructor(name: string, source: Mesh);
  16011. /**
  16012. * Returns the string "InstancedMesh".
  16013. */
  16014. getClassName(): string;
  16015. /** Gets the list of lights affecting that mesh */
  16016. get lightSources(): Light[];
  16017. _resyncLightSources(): void;
  16018. _resyncLightSource(light: Light): void;
  16019. _removeLightSource(light: Light, dispose: boolean): void;
  16020. /**
  16021. * If the source mesh receives shadows
  16022. */
  16023. get receiveShadows(): boolean;
  16024. /**
  16025. * The material of the source mesh
  16026. */
  16027. get material(): Nullable<Material>;
  16028. /**
  16029. * Visibility of the source mesh
  16030. */
  16031. get visibility(): number;
  16032. /**
  16033. * Skeleton of the source mesh
  16034. */
  16035. get skeleton(): Nullable<Skeleton>;
  16036. /**
  16037. * Rendering ground id of the source mesh
  16038. */
  16039. get renderingGroupId(): number;
  16040. set renderingGroupId(value: number);
  16041. /**
  16042. * Returns the total number of vertices (integer).
  16043. */
  16044. getTotalVertices(): number;
  16045. /**
  16046. * Returns a positive integer : the total number of indices in this mesh geometry.
  16047. * @returns the numner of indices or zero if the mesh has no geometry.
  16048. */
  16049. getTotalIndices(): number;
  16050. /**
  16051. * The source mesh of the instance
  16052. */
  16053. get sourceMesh(): Mesh;
  16054. /**
  16055. * Creates a new InstancedMesh object from the mesh model.
  16056. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16057. * @param name defines the name of the new instance
  16058. * @returns a new InstancedMesh
  16059. */
  16060. createInstance(name: string): InstancedMesh;
  16061. /**
  16062. * Is this node ready to be used/rendered
  16063. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16064. * @return {boolean} is it ready
  16065. */
  16066. isReady(completeCheck?: boolean): boolean;
  16067. /**
  16068. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16069. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16070. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16071. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16072. */
  16073. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16074. /**
  16075. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16076. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16077. * The `data` are either a numeric array either a Float32Array.
  16078. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16079. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16080. * Note that a new underlying VertexBuffer object is created each call.
  16081. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16082. *
  16083. * Possible `kind` values :
  16084. * - VertexBuffer.PositionKind
  16085. * - VertexBuffer.UVKind
  16086. * - VertexBuffer.UV2Kind
  16087. * - VertexBuffer.UV3Kind
  16088. * - VertexBuffer.UV4Kind
  16089. * - VertexBuffer.UV5Kind
  16090. * - VertexBuffer.UV6Kind
  16091. * - VertexBuffer.ColorKind
  16092. * - VertexBuffer.MatricesIndicesKind
  16093. * - VertexBuffer.MatricesIndicesExtraKind
  16094. * - VertexBuffer.MatricesWeightsKind
  16095. * - VertexBuffer.MatricesWeightsExtraKind
  16096. *
  16097. * Returns the Mesh.
  16098. */
  16099. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16100. /**
  16101. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16102. * If the mesh has no geometry, it is simply returned as it is.
  16103. * The `data` are either a numeric array either a Float32Array.
  16104. * No new underlying VertexBuffer object is created.
  16105. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16106. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16107. *
  16108. * Possible `kind` values :
  16109. * - VertexBuffer.PositionKind
  16110. * - VertexBuffer.UVKind
  16111. * - VertexBuffer.UV2Kind
  16112. * - VertexBuffer.UV3Kind
  16113. * - VertexBuffer.UV4Kind
  16114. * - VertexBuffer.UV5Kind
  16115. * - VertexBuffer.UV6Kind
  16116. * - VertexBuffer.ColorKind
  16117. * - VertexBuffer.MatricesIndicesKind
  16118. * - VertexBuffer.MatricesIndicesExtraKind
  16119. * - VertexBuffer.MatricesWeightsKind
  16120. * - VertexBuffer.MatricesWeightsExtraKind
  16121. *
  16122. * Returns the Mesh.
  16123. */
  16124. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16125. /**
  16126. * Sets the mesh indices.
  16127. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16128. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16129. * This method creates a new index buffer each call.
  16130. * Returns the Mesh.
  16131. */
  16132. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16133. /**
  16134. * Boolean : True if the mesh owns the requested kind of data.
  16135. */
  16136. isVerticesDataPresent(kind: string): boolean;
  16137. /**
  16138. * Returns an array of indices (IndicesArray).
  16139. */
  16140. getIndices(): Nullable<IndicesArray>;
  16141. get _positions(): Nullable<Vector3[]>;
  16142. /**
  16143. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16144. * This means the mesh underlying bounding box and sphere are recomputed.
  16145. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16146. * @returns the current mesh
  16147. */
  16148. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16149. /** @hidden */
  16150. _preActivate(): InstancedMesh;
  16151. /** @hidden */
  16152. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16153. /** @hidden */
  16154. _postActivate(): void;
  16155. getWorldMatrix(): Matrix;
  16156. get isAnInstance(): boolean;
  16157. /**
  16158. * Returns the current associated LOD AbstractMesh.
  16159. */
  16160. getLOD(camera: Camera): AbstractMesh;
  16161. /** @hidden */
  16162. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16163. /** @hidden */
  16164. _syncSubMeshes(): InstancedMesh;
  16165. /** @hidden */
  16166. _generatePointsArray(): boolean;
  16167. /**
  16168. * Creates a new InstancedMesh from the current mesh.
  16169. * - name (string) : the cloned mesh name
  16170. * - newParent (optional Node) : the optional Node to parent the clone to.
  16171. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16172. *
  16173. * Returns the clone.
  16174. */
  16175. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16176. /**
  16177. * Disposes the InstancedMesh.
  16178. * Returns nothing.
  16179. */
  16180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16181. }
  16182. interface Mesh {
  16183. /**
  16184. * Register a custom buffer that will be instanced
  16185. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16186. * @param kind defines the buffer kind
  16187. * @param stride defines the stride in floats
  16188. */
  16189. registerInstancedBuffer(kind: string, stride: number): void;
  16190. /**
  16191. * true to use the edge renderer for all instances of this mesh
  16192. */
  16193. edgesShareWithInstances: boolean;
  16194. /** @hidden */
  16195. _userInstancedBuffersStorage: {
  16196. data: {
  16197. [key: string]: Float32Array;
  16198. };
  16199. sizes: {
  16200. [key: string]: number;
  16201. };
  16202. vertexBuffers: {
  16203. [key: string]: Nullable<VertexBuffer>;
  16204. };
  16205. strides: {
  16206. [key: string]: number;
  16207. };
  16208. };
  16209. }
  16210. interface AbstractMesh {
  16211. /**
  16212. * Object used to store instanced buffers defined by user
  16213. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16214. */
  16215. instancedBuffers: {
  16216. [key: string]: any;
  16217. };
  16218. }
  16219. }
  16220. declare module BABYLON {
  16221. /**
  16222. * Defines the options associated with the creation of a shader material.
  16223. */
  16224. export interface IShaderMaterialOptions {
  16225. /**
  16226. * Does the material work in alpha blend mode
  16227. */
  16228. needAlphaBlending: boolean;
  16229. /**
  16230. * Does the material work in alpha test mode
  16231. */
  16232. needAlphaTesting: boolean;
  16233. /**
  16234. * The list of attribute names used in the shader
  16235. */
  16236. attributes: string[];
  16237. /**
  16238. * The list of unifrom names used in the shader
  16239. */
  16240. uniforms: string[];
  16241. /**
  16242. * The list of UBO names used in the shader
  16243. */
  16244. uniformBuffers: string[];
  16245. /**
  16246. * The list of sampler names used in the shader
  16247. */
  16248. samplers: string[];
  16249. /**
  16250. * The list of defines used in the shader
  16251. */
  16252. defines: string[];
  16253. }
  16254. /**
  16255. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16256. *
  16257. * This returned material effects how the mesh will look based on the code in the shaders.
  16258. *
  16259. * @see http://doc.babylonjs.com/how_to/shader_material
  16260. */
  16261. export class ShaderMaterial extends Material {
  16262. private _shaderPath;
  16263. private _options;
  16264. private _textures;
  16265. private _textureArrays;
  16266. private _floats;
  16267. private _ints;
  16268. private _floatsArrays;
  16269. private _colors3;
  16270. private _colors3Arrays;
  16271. private _colors4;
  16272. private _colors4Arrays;
  16273. private _vectors2;
  16274. private _vectors3;
  16275. private _vectors4;
  16276. private _matrices;
  16277. private _matrixArrays;
  16278. private _matrices3x3;
  16279. private _matrices2x2;
  16280. private _vectors2Arrays;
  16281. private _vectors3Arrays;
  16282. private _vectors4Arrays;
  16283. private _cachedWorldViewMatrix;
  16284. private _cachedWorldViewProjectionMatrix;
  16285. private _renderId;
  16286. private _multiview;
  16287. private _cachedDefines;
  16288. /** Define the Url to load snippets */
  16289. static SnippetUrl: string;
  16290. /** Snippet ID if the material was created from the snippet server */
  16291. snippetId: string;
  16292. /**
  16293. * Instantiate a new shader material.
  16294. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16295. * This returned material effects how the mesh will look based on the code in the shaders.
  16296. * @see http://doc.babylonjs.com/how_to/shader_material
  16297. * @param name Define the name of the material in the scene
  16298. * @param scene Define the scene the material belongs to
  16299. * @param shaderPath Defines the route to the shader code in one of three ways:
  16300. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16301. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16302. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16303. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16304. * @param options Define the options used to create the shader
  16305. */
  16306. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16307. /**
  16308. * Gets the shader path used to define the shader code
  16309. * It can be modified to trigger a new compilation
  16310. */
  16311. get shaderPath(): any;
  16312. /**
  16313. * Sets the shader path used to define the shader code
  16314. * It can be modified to trigger a new compilation
  16315. */
  16316. set shaderPath(shaderPath: any);
  16317. /**
  16318. * Gets the options used to compile the shader.
  16319. * They can be modified to trigger a new compilation
  16320. */
  16321. get options(): IShaderMaterialOptions;
  16322. /**
  16323. * Gets the current class name of the material e.g. "ShaderMaterial"
  16324. * Mainly use in serialization.
  16325. * @returns the class name
  16326. */
  16327. getClassName(): string;
  16328. /**
  16329. * Specifies if the material will require alpha blending
  16330. * @returns a boolean specifying if alpha blending is needed
  16331. */
  16332. needAlphaBlending(): boolean;
  16333. /**
  16334. * Specifies if this material should be rendered in alpha test mode
  16335. * @returns a boolean specifying if an alpha test is needed.
  16336. */
  16337. needAlphaTesting(): boolean;
  16338. private _checkUniform;
  16339. /**
  16340. * Set a texture in the shader.
  16341. * @param name Define the name of the uniform samplers as defined in the shader
  16342. * @param texture Define the texture to bind to this sampler
  16343. * @return the material itself allowing "fluent" like uniform updates
  16344. */
  16345. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16346. /**
  16347. * Set a texture array in the shader.
  16348. * @param name Define the name of the uniform sampler array as defined in the shader
  16349. * @param textures Define the list of textures to bind to this sampler
  16350. * @return the material itself allowing "fluent" like uniform updates
  16351. */
  16352. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16353. /**
  16354. * Set a float in the shader.
  16355. * @param name Define the name of the uniform as defined in the shader
  16356. * @param value Define the value to give to the uniform
  16357. * @return the material itself allowing "fluent" like uniform updates
  16358. */
  16359. setFloat(name: string, value: number): ShaderMaterial;
  16360. /**
  16361. * Set a int in the shader.
  16362. * @param name Define the name of the uniform as defined in the shader
  16363. * @param value Define the value to give to the uniform
  16364. * @return the material itself allowing "fluent" like uniform updates
  16365. */
  16366. setInt(name: string, value: number): ShaderMaterial;
  16367. /**
  16368. * Set an array of floats in the shader.
  16369. * @param name Define the name of the uniform as defined in the shader
  16370. * @param value Define the value to give to the uniform
  16371. * @return the material itself allowing "fluent" like uniform updates
  16372. */
  16373. setFloats(name: string, value: number[]): ShaderMaterial;
  16374. /**
  16375. * Set a vec3 in the shader from a Color3.
  16376. * @param name Define the name of the uniform as defined in the shader
  16377. * @param value Define the value to give to the uniform
  16378. * @return the material itself allowing "fluent" like uniform updates
  16379. */
  16380. setColor3(name: string, value: Color3): ShaderMaterial;
  16381. /**
  16382. * Set a vec3 array in the shader from a Color3 array.
  16383. * @param name Define the name of the uniform as defined in the shader
  16384. * @param value Define the value to give to the uniform
  16385. * @return the material itself allowing "fluent" like uniform updates
  16386. */
  16387. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16388. /**
  16389. * Set a vec4 in the shader from a Color4.
  16390. * @param name Define the name of the uniform as defined in the shader
  16391. * @param value Define the value to give to the uniform
  16392. * @return the material itself allowing "fluent" like uniform updates
  16393. */
  16394. setColor4(name: string, value: Color4): ShaderMaterial;
  16395. /**
  16396. * Set a vec4 array in the shader from a Color4 array.
  16397. * @param name Define the name of the uniform as defined in the shader
  16398. * @param value Define the value to give to the uniform
  16399. * @return the material itself allowing "fluent" like uniform updates
  16400. */
  16401. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16402. /**
  16403. * Set a vec2 in the shader from a Vector2.
  16404. * @param name Define the name of the uniform as defined in the shader
  16405. * @param value Define the value to give to the uniform
  16406. * @return the material itself allowing "fluent" like uniform updates
  16407. */
  16408. setVector2(name: string, value: Vector2): ShaderMaterial;
  16409. /**
  16410. * Set a vec3 in the shader from a Vector3.
  16411. * @param name Define the name of the uniform as defined in the shader
  16412. * @param value Define the value to give to the uniform
  16413. * @return the material itself allowing "fluent" like uniform updates
  16414. */
  16415. setVector3(name: string, value: Vector3): ShaderMaterial;
  16416. /**
  16417. * Set a vec4 in the shader from a Vector4.
  16418. * @param name Define the name of the uniform as defined in the shader
  16419. * @param value Define the value to give to the uniform
  16420. * @return the material itself allowing "fluent" like uniform updates
  16421. */
  16422. setVector4(name: string, value: Vector4): ShaderMaterial;
  16423. /**
  16424. * Set a mat4 in the shader from a Matrix.
  16425. * @param name Define the name of the uniform as defined in the shader
  16426. * @param value Define the value to give to the uniform
  16427. * @return the material itself allowing "fluent" like uniform updates
  16428. */
  16429. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16430. /**
  16431. * Set a float32Array in the shader from a matrix array.
  16432. * @param name Define the name of the uniform as defined in the shader
  16433. * @param value Define the value to give to the uniform
  16434. * @return the material itself allowing "fluent" like uniform updates
  16435. */
  16436. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16437. /**
  16438. * Set a mat3 in the shader from a Float32Array.
  16439. * @param name Define the name of the uniform as defined in the shader
  16440. * @param value Define the value to give to the uniform
  16441. * @return the material itself allowing "fluent" like uniform updates
  16442. */
  16443. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16444. /**
  16445. * Set a mat2 in the shader from a Float32Array.
  16446. * @param name Define the name of the uniform as defined in the shader
  16447. * @param value Define the value to give to the uniform
  16448. * @return the material itself allowing "fluent" like uniform updates
  16449. */
  16450. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16451. /**
  16452. * Set a vec2 array in the shader from a number array.
  16453. * @param name Define the name of the uniform as defined in the shader
  16454. * @param value Define the value to give to the uniform
  16455. * @return the material itself allowing "fluent" like uniform updates
  16456. */
  16457. setArray2(name: string, value: number[]): ShaderMaterial;
  16458. /**
  16459. * Set a vec3 array in the shader from a number array.
  16460. * @param name Define the name of the uniform as defined in the shader
  16461. * @param value Define the value to give to the uniform
  16462. * @return the material itself allowing "fluent" like uniform updates
  16463. */
  16464. setArray3(name: string, value: number[]): ShaderMaterial;
  16465. /**
  16466. * Set a vec4 array in the shader from a number array.
  16467. * @param name Define the name of the uniform as defined in the shader
  16468. * @param value Define the value to give to the uniform
  16469. * @return the material itself allowing "fluent" like uniform updates
  16470. */
  16471. setArray4(name: string, value: number[]): ShaderMaterial;
  16472. private _checkCache;
  16473. /**
  16474. * Specifies that the submesh is ready to be used
  16475. * @param mesh defines the mesh to check
  16476. * @param subMesh defines which submesh to check
  16477. * @param useInstances specifies that instances should be used
  16478. * @returns a boolean indicating that the submesh is ready or not
  16479. */
  16480. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16481. /**
  16482. * Checks if the material is ready to render the requested mesh
  16483. * @param mesh Define the mesh to render
  16484. * @param useInstances Define whether or not the material is used with instances
  16485. * @returns true if ready, otherwise false
  16486. */
  16487. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16488. /**
  16489. * Binds the world matrix to the material
  16490. * @param world defines the world transformation matrix
  16491. * @param effectOverride - If provided, use this effect instead of internal effect
  16492. */
  16493. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16494. /**
  16495. * Binds the submesh to this material by preparing the effect and shader to draw
  16496. * @param world defines the world transformation matrix
  16497. * @param mesh defines the mesh containing the submesh
  16498. * @param subMesh defines the submesh to bind the material to
  16499. */
  16500. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16501. /**
  16502. * Binds the material to the mesh
  16503. * @param world defines the world transformation matrix
  16504. * @param mesh defines the mesh to bind the material to
  16505. * @param effectOverride - If provided, use this effect instead of internal effect
  16506. */
  16507. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16508. protected _afterBind(mesh?: Mesh): void;
  16509. /**
  16510. * Gets the active textures from the material
  16511. * @returns an array of textures
  16512. */
  16513. getActiveTextures(): BaseTexture[];
  16514. /**
  16515. * Specifies if the material uses a texture
  16516. * @param texture defines the texture to check against the material
  16517. * @returns a boolean specifying if the material uses the texture
  16518. */
  16519. hasTexture(texture: BaseTexture): boolean;
  16520. /**
  16521. * Makes a duplicate of the material, and gives it a new name
  16522. * @param name defines the new name for the duplicated material
  16523. * @returns the cloned material
  16524. */
  16525. clone(name: string): ShaderMaterial;
  16526. /**
  16527. * Disposes the material
  16528. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16529. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16530. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16531. */
  16532. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16533. /**
  16534. * Serializes this material in a JSON representation
  16535. * @returns the serialized material object
  16536. */
  16537. serialize(): any;
  16538. /**
  16539. * Creates a shader material from parsed shader material data
  16540. * @param source defines the JSON represnetation of the material
  16541. * @param scene defines the hosting scene
  16542. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16543. * @returns a new material
  16544. */
  16545. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16546. /**
  16547. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16548. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16549. * @param url defines the url to load from
  16550. * @param scene defines the hosting scene
  16551. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16552. * @returns a promise that will resolve to the new ShaderMaterial
  16553. */
  16554. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16555. /**
  16556. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16557. * @param snippetId defines the snippet to load
  16558. * @param scene defines the hosting scene
  16559. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16560. * @returns a promise that will resolve to the new ShaderMaterial
  16561. */
  16562. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16563. }
  16564. }
  16565. declare module BABYLON {
  16566. /** @hidden */
  16567. export var colorPixelShader: {
  16568. name: string;
  16569. shader: string;
  16570. };
  16571. }
  16572. declare module BABYLON {
  16573. /** @hidden */
  16574. export var colorVertexShader: {
  16575. name: string;
  16576. shader: string;
  16577. };
  16578. }
  16579. declare module BABYLON {
  16580. /**
  16581. * Line mesh
  16582. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16583. */
  16584. export class LinesMesh extends Mesh {
  16585. /**
  16586. * If vertex color should be applied to the mesh
  16587. */
  16588. readonly useVertexColor?: boolean | undefined;
  16589. /**
  16590. * If vertex alpha should be applied to the mesh
  16591. */
  16592. readonly useVertexAlpha?: boolean | undefined;
  16593. /**
  16594. * Color of the line (Default: White)
  16595. */
  16596. color: Color3;
  16597. /**
  16598. * Alpha of the line (Default: 1)
  16599. */
  16600. alpha: number;
  16601. /**
  16602. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16603. * This margin is expressed in world space coordinates, so its value may vary.
  16604. * Default value is 0.1
  16605. */
  16606. intersectionThreshold: number;
  16607. private _colorShader;
  16608. private color4;
  16609. /**
  16610. * Creates a new LinesMesh
  16611. * @param name defines the name
  16612. * @param scene defines the hosting scene
  16613. * @param parent defines the parent mesh if any
  16614. * @param source defines the optional source LinesMesh used to clone data from
  16615. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16616. * When false, achieved by calling a clone(), also passing False.
  16617. * This will make creation of children, recursive.
  16618. * @param useVertexColor defines if this LinesMesh supports vertex color
  16619. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16620. */
  16621. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16622. /**
  16623. * If vertex color should be applied to the mesh
  16624. */
  16625. useVertexColor?: boolean | undefined,
  16626. /**
  16627. * If vertex alpha should be applied to the mesh
  16628. */
  16629. useVertexAlpha?: boolean | undefined);
  16630. private _addClipPlaneDefine;
  16631. private _removeClipPlaneDefine;
  16632. isReady(): boolean;
  16633. /**
  16634. * Returns the string "LineMesh"
  16635. */
  16636. getClassName(): string;
  16637. /**
  16638. * @hidden
  16639. */
  16640. get material(): Material;
  16641. /**
  16642. * @hidden
  16643. */
  16644. set material(value: Material);
  16645. /**
  16646. * @hidden
  16647. */
  16648. get checkCollisions(): boolean;
  16649. /** @hidden */
  16650. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16651. /** @hidden */
  16652. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16653. /**
  16654. * Disposes of the line mesh
  16655. * @param doNotRecurse If children should be disposed
  16656. */
  16657. dispose(doNotRecurse?: boolean): void;
  16658. /**
  16659. * Returns a new LineMesh object cloned from the current one.
  16660. */
  16661. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16662. /**
  16663. * Creates a new InstancedLinesMesh object from the mesh model.
  16664. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16665. * @param name defines the name of the new instance
  16666. * @returns a new InstancedLinesMesh
  16667. */
  16668. createInstance(name: string): InstancedLinesMesh;
  16669. }
  16670. /**
  16671. * Creates an instance based on a source LinesMesh
  16672. */
  16673. export class InstancedLinesMesh extends InstancedMesh {
  16674. /**
  16675. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16676. * This margin is expressed in world space coordinates, so its value may vary.
  16677. * Initilized with the intersectionThreshold value of the source LinesMesh
  16678. */
  16679. intersectionThreshold: number;
  16680. constructor(name: string, source: LinesMesh);
  16681. /**
  16682. * Returns the string "InstancedLinesMesh".
  16683. */
  16684. getClassName(): string;
  16685. }
  16686. }
  16687. declare module BABYLON {
  16688. /** @hidden */
  16689. export var linePixelShader: {
  16690. name: string;
  16691. shader: string;
  16692. };
  16693. }
  16694. declare module BABYLON {
  16695. /** @hidden */
  16696. export var lineVertexShader: {
  16697. name: string;
  16698. shader: string;
  16699. };
  16700. }
  16701. declare module BABYLON {
  16702. interface Scene {
  16703. /** @hidden */
  16704. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16705. }
  16706. interface AbstractMesh {
  16707. /**
  16708. * Gets the edgesRenderer associated with the mesh
  16709. */
  16710. edgesRenderer: Nullable<EdgesRenderer>;
  16711. }
  16712. interface LinesMesh {
  16713. /**
  16714. * Enables the edge rendering mode on the mesh.
  16715. * This mode makes the mesh edges visible
  16716. * @param epsilon defines the maximal distance between two angles to detect a face
  16717. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16718. * @returns the currentAbstractMesh
  16719. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16720. */
  16721. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16722. }
  16723. interface InstancedLinesMesh {
  16724. /**
  16725. * Enables the edge rendering mode on the mesh.
  16726. * This mode makes the mesh edges visible
  16727. * @param epsilon defines the maximal distance between two angles to detect a face
  16728. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16729. * @returns the current InstancedLinesMesh
  16730. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16731. */
  16732. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16733. }
  16734. /**
  16735. * Defines the minimum contract an Edges renderer should follow.
  16736. */
  16737. export interface IEdgesRenderer extends IDisposable {
  16738. /**
  16739. * Gets or sets a boolean indicating if the edgesRenderer is active
  16740. */
  16741. isEnabled: boolean;
  16742. /**
  16743. * Renders the edges of the attached mesh,
  16744. */
  16745. render(): void;
  16746. /**
  16747. * Checks wether or not the edges renderer is ready to render.
  16748. * @return true if ready, otherwise false.
  16749. */
  16750. isReady(): boolean;
  16751. /**
  16752. * List of instances to render in case the source mesh has instances
  16753. */
  16754. customInstances: SmartArray<Matrix>;
  16755. }
  16756. /**
  16757. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16758. */
  16759. export class EdgesRenderer implements IEdgesRenderer {
  16760. /**
  16761. * Define the size of the edges with an orthographic camera
  16762. */
  16763. edgesWidthScalerForOrthographic: number;
  16764. /**
  16765. * Define the size of the edges with a perspective camera
  16766. */
  16767. edgesWidthScalerForPerspective: number;
  16768. protected _source: AbstractMesh;
  16769. protected _linesPositions: number[];
  16770. protected _linesNormals: number[];
  16771. protected _linesIndices: number[];
  16772. protected _epsilon: number;
  16773. protected _indicesCount: number;
  16774. protected _lineShader: ShaderMaterial;
  16775. protected _ib: DataBuffer;
  16776. protected _buffers: {
  16777. [key: string]: Nullable<VertexBuffer>;
  16778. };
  16779. protected _buffersForInstances: {
  16780. [key: string]: Nullable<VertexBuffer>;
  16781. };
  16782. protected _checkVerticesInsteadOfIndices: boolean;
  16783. private _meshRebuildObserver;
  16784. private _meshDisposeObserver;
  16785. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16786. isEnabled: boolean;
  16787. /**
  16788. * List of instances to render in case the source mesh has instances
  16789. */
  16790. customInstances: SmartArray<Matrix>;
  16791. private static GetShader;
  16792. /**
  16793. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16794. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16795. * @param source Mesh used to create edges
  16796. * @param epsilon sum of angles in adjacency to check for edge
  16797. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16798. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16799. */
  16800. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16801. protected _prepareRessources(): void;
  16802. /** @hidden */
  16803. _rebuild(): void;
  16804. /**
  16805. * Releases the required resources for the edges renderer
  16806. */
  16807. dispose(): void;
  16808. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16809. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16810. /**
  16811. * Checks if the pair of p0 and p1 is en edge
  16812. * @param faceIndex
  16813. * @param edge
  16814. * @param faceNormals
  16815. * @param p0
  16816. * @param p1
  16817. * @private
  16818. */
  16819. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16820. /**
  16821. * push line into the position, normal and index buffer
  16822. * @protected
  16823. */
  16824. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16825. /**
  16826. * Generates lines edges from adjacencjes
  16827. * @private
  16828. */
  16829. _generateEdgesLines(): void;
  16830. /**
  16831. * Checks wether or not the edges renderer is ready to render.
  16832. * @return true if ready, otherwise false.
  16833. */
  16834. isReady(): boolean;
  16835. /**
  16836. * Renders the edges of the attached mesh,
  16837. */
  16838. render(): void;
  16839. }
  16840. /**
  16841. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16842. */
  16843. export class LineEdgesRenderer extends EdgesRenderer {
  16844. /**
  16845. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16846. * @param source LineMesh used to generate edges
  16847. * @param epsilon not important (specified angle for edge detection)
  16848. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16849. */
  16850. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16851. /**
  16852. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16853. */
  16854. _generateEdgesLines(): void;
  16855. }
  16856. }
  16857. declare module BABYLON {
  16858. /**
  16859. * This represents the object necessary to create a rendering group.
  16860. * This is exclusively used and created by the rendering manager.
  16861. * To modify the behavior, you use the available helpers in your scene or meshes.
  16862. * @hidden
  16863. */
  16864. export class RenderingGroup {
  16865. index: number;
  16866. private static _zeroVector;
  16867. private _scene;
  16868. private _opaqueSubMeshes;
  16869. private _transparentSubMeshes;
  16870. private _alphaTestSubMeshes;
  16871. private _depthOnlySubMeshes;
  16872. private _particleSystems;
  16873. private _spriteManagers;
  16874. private _opaqueSortCompareFn;
  16875. private _alphaTestSortCompareFn;
  16876. private _transparentSortCompareFn;
  16877. private _renderOpaque;
  16878. private _renderAlphaTest;
  16879. private _renderTransparent;
  16880. /** @hidden */
  16881. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16882. onBeforeTransparentRendering: () => void;
  16883. /**
  16884. * Set the opaque sort comparison function.
  16885. * If null the sub meshes will be render in the order they were created
  16886. */
  16887. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16888. /**
  16889. * Set the alpha test sort comparison function.
  16890. * If null the sub meshes will be render in the order they were created
  16891. */
  16892. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16893. /**
  16894. * Set the transparent sort comparison function.
  16895. * If null the sub meshes will be render in the order they were created
  16896. */
  16897. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16898. /**
  16899. * Creates a new rendering group.
  16900. * @param index The rendering group index
  16901. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16902. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16903. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16904. */
  16905. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16906. /**
  16907. * Render all the sub meshes contained in the group.
  16908. * @param customRenderFunction Used to override the default render behaviour of the group.
  16909. * @returns true if rendered some submeshes.
  16910. */
  16911. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16912. /**
  16913. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16914. * @param subMeshes The submeshes to render
  16915. */
  16916. private renderOpaqueSorted;
  16917. /**
  16918. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16919. * @param subMeshes The submeshes to render
  16920. */
  16921. private renderAlphaTestSorted;
  16922. /**
  16923. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16924. * @param subMeshes The submeshes to render
  16925. */
  16926. private renderTransparentSorted;
  16927. /**
  16928. * Renders the submeshes in a specified order.
  16929. * @param subMeshes The submeshes to sort before render
  16930. * @param sortCompareFn The comparison function use to sort
  16931. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16932. * @param transparent Specifies to activate blending if true
  16933. */
  16934. private static renderSorted;
  16935. /**
  16936. * Renders the submeshes in the order they were dispatched (no sort applied).
  16937. * @param subMeshes The submeshes to render
  16938. */
  16939. private static renderUnsorted;
  16940. /**
  16941. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16942. * are rendered back to front if in the same alpha index.
  16943. *
  16944. * @param a The first submesh
  16945. * @param b The second submesh
  16946. * @returns The result of the comparison
  16947. */
  16948. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16949. /**
  16950. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16951. * are rendered back to front.
  16952. *
  16953. * @param a The first submesh
  16954. * @param b The second submesh
  16955. * @returns The result of the comparison
  16956. */
  16957. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16958. /**
  16959. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16960. * are rendered front to back (prevent overdraw).
  16961. *
  16962. * @param a The first submesh
  16963. * @param b The second submesh
  16964. * @returns The result of the comparison
  16965. */
  16966. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16967. /**
  16968. * Resets the different lists of submeshes to prepare a new frame.
  16969. */
  16970. prepare(): void;
  16971. dispose(): void;
  16972. /**
  16973. * Inserts the submesh in its correct queue depending on its material.
  16974. * @param subMesh The submesh to dispatch
  16975. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16976. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16977. */
  16978. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16979. dispatchSprites(spriteManager: ISpriteManager): void;
  16980. dispatchParticles(particleSystem: IParticleSystem): void;
  16981. private _renderParticles;
  16982. private _renderSprites;
  16983. }
  16984. }
  16985. declare module BABYLON {
  16986. /**
  16987. * Interface describing the different options available in the rendering manager
  16988. * regarding Auto Clear between groups.
  16989. */
  16990. export interface IRenderingManagerAutoClearSetup {
  16991. /**
  16992. * Defines whether or not autoclear is enable.
  16993. */
  16994. autoClear: boolean;
  16995. /**
  16996. * Defines whether or not to autoclear the depth buffer.
  16997. */
  16998. depth: boolean;
  16999. /**
  17000. * Defines whether or not to autoclear the stencil buffer.
  17001. */
  17002. stencil: boolean;
  17003. }
  17004. /**
  17005. * This class is used by the onRenderingGroupObservable
  17006. */
  17007. export class RenderingGroupInfo {
  17008. /**
  17009. * The Scene that being rendered
  17010. */
  17011. scene: Scene;
  17012. /**
  17013. * The camera currently used for the rendering pass
  17014. */
  17015. camera: Nullable<Camera>;
  17016. /**
  17017. * The ID of the renderingGroup being processed
  17018. */
  17019. renderingGroupId: number;
  17020. }
  17021. /**
  17022. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17023. * It is enable to manage the different groups as well as the different necessary sort functions.
  17024. * This should not be used directly aside of the few static configurations
  17025. */
  17026. export class RenderingManager {
  17027. /**
  17028. * The max id used for rendering groups (not included)
  17029. */
  17030. static MAX_RENDERINGGROUPS: number;
  17031. /**
  17032. * The min id used for rendering groups (included)
  17033. */
  17034. static MIN_RENDERINGGROUPS: number;
  17035. /**
  17036. * Used to globally prevent autoclearing scenes.
  17037. */
  17038. static AUTOCLEAR: boolean;
  17039. /**
  17040. * @hidden
  17041. */
  17042. _useSceneAutoClearSetup: boolean;
  17043. private _scene;
  17044. private _renderingGroups;
  17045. private _depthStencilBufferAlreadyCleaned;
  17046. private _autoClearDepthStencil;
  17047. private _customOpaqueSortCompareFn;
  17048. private _customAlphaTestSortCompareFn;
  17049. private _customTransparentSortCompareFn;
  17050. private _renderingGroupInfo;
  17051. /**
  17052. * Instantiates a new rendering group for a particular scene
  17053. * @param scene Defines the scene the groups belongs to
  17054. */
  17055. constructor(scene: Scene);
  17056. private _clearDepthStencilBuffer;
  17057. /**
  17058. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17059. * @hidden
  17060. */
  17061. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17062. /**
  17063. * Resets the different information of the group to prepare a new frame
  17064. * @hidden
  17065. */
  17066. reset(): void;
  17067. /**
  17068. * Dispose and release the group and its associated resources.
  17069. * @hidden
  17070. */
  17071. dispose(): void;
  17072. /**
  17073. * Clear the info related to rendering groups preventing retention points during dispose.
  17074. */
  17075. freeRenderingGroups(): void;
  17076. private _prepareRenderingGroup;
  17077. /**
  17078. * Add a sprite manager to the rendering manager in order to render it this frame.
  17079. * @param spriteManager Define the sprite manager to render
  17080. */
  17081. dispatchSprites(spriteManager: ISpriteManager): void;
  17082. /**
  17083. * Add a particle system to the rendering manager in order to render it this frame.
  17084. * @param particleSystem Define the particle system to render
  17085. */
  17086. dispatchParticles(particleSystem: IParticleSystem): void;
  17087. /**
  17088. * Add a submesh to the manager in order to render it this frame
  17089. * @param subMesh The submesh to dispatch
  17090. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17091. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17092. */
  17093. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17094. /**
  17095. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17096. * This allowed control for front to back rendering or reversly depending of the special needs.
  17097. *
  17098. * @param renderingGroupId The rendering group id corresponding to its index
  17099. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17100. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17101. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17102. */
  17103. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17104. /**
  17105. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17106. *
  17107. * @param renderingGroupId The rendering group id corresponding to its index
  17108. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17109. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17110. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17111. */
  17112. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17113. /**
  17114. * Gets the current auto clear configuration for one rendering group of the rendering
  17115. * manager.
  17116. * @param index the rendering group index to get the information for
  17117. * @returns The auto clear setup for the requested rendering group
  17118. */
  17119. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17120. }
  17121. }
  17122. declare module BABYLON {
  17123. /**
  17124. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17125. */
  17126. export interface ICustomShaderOptions {
  17127. /**
  17128. * Gets or sets the custom shader name to use
  17129. */
  17130. shaderName: string;
  17131. /**
  17132. * The list of attribute names used in the shader
  17133. */
  17134. attributes?: string[];
  17135. /**
  17136. * The list of unifrom names used in the shader
  17137. */
  17138. uniforms?: string[];
  17139. /**
  17140. * The list of sampler names used in the shader
  17141. */
  17142. samplers?: string[];
  17143. /**
  17144. * The list of defines used in the shader
  17145. */
  17146. defines?: string[];
  17147. }
  17148. /**
  17149. * Interface to implement to create a shadow generator compatible with BJS.
  17150. */
  17151. export interface IShadowGenerator {
  17152. /**
  17153. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17154. * @returns The render target texture if present otherwise, null
  17155. */
  17156. getShadowMap(): Nullable<RenderTargetTexture>;
  17157. /**
  17158. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17159. * @param subMesh The submesh we want to render in the shadow map
  17160. * @param useInstances Defines wether will draw in the map using instances
  17161. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17162. * @returns true if ready otherwise, false
  17163. */
  17164. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17165. /**
  17166. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17167. * @param defines Defines of the material we want to update
  17168. * @param lightIndex Index of the light in the enabled light list of the material
  17169. */
  17170. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17171. /**
  17172. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17173. * defined in the generator but impacting the effect).
  17174. * It implies the unifroms available on the materials are the standard BJS ones.
  17175. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17176. * @param effect The effect we are binfing the information for
  17177. */
  17178. bindShadowLight(lightIndex: string, effect: Effect): void;
  17179. /**
  17180. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17181. * (eq to shadow prjection matrix * light transform matrix)
  17182. * @returns The transform matrix used to create the shadow map
  17183. */
  17184. getTransformMatrix(): Matrix;
  17185. /**
  17186. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17187. * Cube and 2D textures for instance.
  17188. */
  17189. recreateShadowMap(): void;
  17190. /**
  17191. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17192. * @param onCompiled Callback triggered at the and of the effects compilation
  17193. * @param options Sets of optional options forcing the compilation with different modes
  17194. */
  17195. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17196. useInstances: boolean;
  17197. }>): void;
  17198. /**
  17199. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17200. * @param options Sets of optional options forcing the compilation with different modes
  17201. * @returns A promise that resolves when the compilation completes
  17202. */
  17203. forceCompilationAsync(options?: Partial<{
  17204. useInstances: boolean;
  17205. }>): Promise<void>;
  17206. /**
  17207. * Serializes the shadow generator setup to a json object.
  17208. * @returns The serialized JSON object
  17209. */
  17210. serialize(): any;
  17211. /**
  17212. * Disposes the Shadow map and related Textures and effects.
  17213. */
  17214. dispose(): void;
  17215. }
  17216. /**
  17217. * Default implementation IShadowGenerator.
  17218. * This is the main object responsible of generating shadows in the framework.
  17219. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17220. */
  17221. export class ShadowGenerator implements IShadowGenerator {
  17222. /**
  17223. * Name of the shadow generator class
  17224. */
  17225. static CLASSNAME: string;
  17226. /**
  17227. * Shadow generator mode None: no filtering applied.
  17228. */
  17229. static readonly FILTER_NONE: number;
  17230. /**
  17231. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17232. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17233. */
  17234. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17235. /**
  17236. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17237. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17238. */
  17239. static readonly FILTER_POISSONSAMPLING: number;
  17240. /**
  17241. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17242. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17243. */
  17244. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17245. /**
  17246. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17247. * edge artifacts on steep falloff.
  17248. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17249. */
  17250. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17251. /**
  17252. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17253. * edge artifacts on steep falloff.
  17254. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17255. */
  17256. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17257. /**
  17258. * Shadow generator mode PCF: Percentage Closer Filtering
  17259. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17260. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17261. */
  17262. static readonly FILTER_PCF: number;
  17263. /**
  17264. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17265. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17266. * Contact Hardening
  17267. */
  17268. static readonly FILTER_PCSS: number;
  17269. /**
  17270. * Reserved for PCF and PCSS
  17271. * Highest Quality.
  17272. *
  17273. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17274. *
  17275. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17276. */
  17277. static readonly QUALITY_HIGH: number;
  17278. /**
  17279. * Reserved for PCF and PCSS
  17280. * Good tradeoff for quality/perf cross devices
  17281. *
  17282. * Execute PCF on a 3*3 kernel.
  17283. *
  17284. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17285. */
  17286. static readonly QUALITY_MEDIUM: number;
  17287. /**
  17288. * Reserved for PCF and PCSS
  17289. * The lowest quality but the fastest.
  17290. *
  17291. * Execute PCF on a 1*1 kernel.
  17292. *
  17293. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17294. */
  17295. static readonly QUALITY_LOW: number;
  17296. /** Gets or sets the custom shader name to use */
  17297. customShaderOptions: ICustomShaderOptions;
  17298. /**
  17299. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17300. */
  17301. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17302. /**
  17303. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17304. */
  17305. onAfterShadowMapRenderObservable: Observable<Effect>;
  17306. /**
  17307. * Observable triggered before a mesh is rendered in the shadow map.
  17308. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17309. */
  17310. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17311. /**
  17312. * Observable triggered after a mesh is rendered in the shadow map.
  17313. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17314. */
  17315. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17316. protected _bias: number;
  17317. /**
  17318. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17319. */
  17320. get bias(): number;
  17321. /**
  17322. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17323. */
  17324. set bias(bias: number);
  17325. protected _normalBias: number;
  17326. /**
  17327. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17328. */
  17329. get normalBias(): number;
  17330. /**
  17331. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17332. */
  17333. set normalBias(normalBias: number);
  17334. protected _blurBoxOffset: number;
  17335. /**
  17336. * Gets the blur box offset: offset applied during the blur pass.
  17337. * Only useful if useKernelBlur = false
  17338. */
  17339. get blurBoxOffset(): number;
  17340. /**
  17341. * Sets the blur box offset: offset applied during the blur pass.
  17342. * Only useful if useKernelBlur = false
  17343. */
  17344. set blurBoxOffset(value: number);
  17345. protected _blurScale: number;
  17346. /**
  17347. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17348. * 2 means half of the size.
  17349. */
  17350. get blurScale(): number;
  17351. /**
  17352. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17353. * 2 means half of the size.
  17354. */
  17355. set blurScale(value: number);
  17356. protected _blurKernel: number;
  17357. /**
  17358. * Gets the blur kernel: kernel size of the blur pass.
  17359. * Only useful if useKernelBlur = true
  17360. */
  17361. get blurKernel(): number;
  17362. /**
  17363. * Sets the blur kernel: kernel size of the blur pass.
  17364. * Only useful if useKernelBlur = true
  17365. */
  17366. set blurKernel(value: number);
  17367. protected _useKernelBlur: boolean;
  17368. /**
  17369. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17370. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17371. */
  17372. get useKernelBlur(): boolean;
  17373. /**
  17374. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17375. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17376. */
  17377. set useKernelBlur(value: boolean);
  17378. protected _depthScale: number;
  17379. /**
  17380. * Gets the depth scale used in ESM mode.
  17381. */
  17382. get depthScale(): number;
  17383. /**
  17384. * Sets the depth scale used in ESM mode.
  17385. * This can override the scale stored on the light.
  17386. */
  17387. set depthScale(value: number);
  17388. protected _validateFilter(filter: number): number;
  17389. protected _filter: number;
  17390. /**
  17391. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17392. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17393. */
  17394. get filter(): number;
  17395. /**
  17396. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17397. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17398. */
  17399. set filter(value: number);
  17400. /**
  17401. * Gets if the current filter is set to Poisson Sampling.
  17402. */
  17403. get usePoissonSampling(): boolean;
  17404. /**
  17405. * Sets the current filter to Poisson Sampling.
  17406. */
  17407. set usePoissonSampling(value: boolean);
  17408. /**
  17409. * Gets if the current filter is set to ESM.
  17410. */
  17411. get useExponentialShadowMap(): boolean;
  17412. /**
  17413. * Sets the current filter is to ESM.
  17414. */
  17415. set useExponentialShadowMap(value: boolean);
  17416. /**
  17417. * Gets if the current filter is set to filtered ESM.
  17418. */
  17419. get useBlurExponentialShadowMap(): boolean;
  17420. /**
  17421. * Gets if the current filter is set to filtered ESM.
  17422. */
  17423. set useBlurExponentialShadowMap(value: boolean);
  17424. /**
  17425. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17426. * exponential to prevent steep falloff artifacts).
  17427. */
  17428. get useCloseExponentialShadowMap(): boolean;
  17429. /**
  17430. * Sets the current filter to "close ESM" (using the inverse of the
  17431. * exponential to prevent steep falloff artifacts).
  17432. */
  17433. set useCloseExponentialShadowMap(value: boolean);
  17434. /**
  17435. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17436. * exponential to prevent steep falloff artifacts).
  17437. */
  17438. get useBlurCloseExponentialShadowMap(): boolean;
  17439. /**
  17440. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17441. * exponential to prevent steep falloff artifacts).
  17442. */
  17443. set useBlurCloseExponentialShadowMap(value: boolean);
  17444. /**
  17445. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17446. */
  17447. get usePercentageCloserFiltering(): boolean;
  17448. /**
  17449. * Sets the current filter to "PCF" (percentage closer filtering).
  17450. */
  17451. set usePercentageCloserFiltering(value: boolean);
  17452. protected _filteringQuality: number;
  17453. /**
  17454. * Gets the PCF or PCSS Quality.
  17455. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17456. */
  17457. get filteringQuality(): number;
  17458. /**
  17459. * Sets the PCF or PCSS Quality.
  17460. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17461. */
  17462. set filteringQuality(filteringQuality: number);
  17463. /**
  17464. * Gets if the current filter is set to "PCSS" (contact hardening).
  17465. */
  17466. get useContactHardeningShadow(): boolean;
  17467. /**
  17468. * Sets the current filter to "PCSS" (contact hardening).
  17469. */
  17470. set useContactHardeningShadow(value: boolean);
  17471. protected _contactHardeningLightSizeUVRatio: number;
  17472. /**
  17473. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17474. * Using a ratio helps keeping shape stability independently of the map size.
  17475. *
  17476. * It does not account for the light projection as it was having too much
  17477. * instability during the light setup or during light position changes.
  17478. *
  17479. * Only valid if useContactHardeningShadow is true.
  17480. */
  17481. get contactHardeningLightSizeUVRatio(): number;
  17482. /**
  17483. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17484. * Using a ratio helps keeping shape stability independently of the map size.
  17485. *
  17486. * It does not account for the light projection as it was having too much
  17487. * instability during the light setup or during light position changes.
  17488. *
  17489. * Only valid if useContactHardeningShadow is true.
  17490. */
  17491. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17492. protected _darkness: number;
  17493. /** Gets or sets the actual darkness of a shadow */
  17494. get darkness(): number;
  17495. set darkness(value: number);
  17496. /**
  17497. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17498. * 0 means strongest and 1 would means no shadow.
  17499. * @returns the darkness.
  17500. */
  17501. getDarkness(): number;
  17502. /**
  17503. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17504. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17505. * @returns the shadow generator allowing fluent coding.
  17506. */
  17507. setDarkness(darkness: number): ShadowGenerator;
  17508. protected _transparencyShadow: boolean;
  17509. /** Gets or sets the ability to have transparent shadow */
  17510. get transparencyShadow(): boolean;
  17511. set transparencyShadow(value: boolean);
  17512. /**
  17513. * Sets the ability to have transparent shadow (boolean).
  17514. * @param transparent True if transparent else False
  17515. * @returns the shadow generator allowing fluent coding
  17516. */
  17517. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17518. /**
  17519. * Enables or disables shadows with varying strength based on the transparency
  17520. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17521. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17522. * mesh.visibility * alphaTexture.a
  17523. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17524. */
  17525. enableSoftTransparentShadow: boolean;
  17526. protected _shadowMap: Nullable<RenderTargetTexture>;
  17527. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17528. /**
  17529. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17530. * @returns The render target texture if present otherwise, null
  17531. */
  17532. getShadowMap(): Nullable<RenderTargetTexture>;
  17533. /**
  17534. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17535. * @returns The render target texture if the shadow map is present otherwise, null
  17536. */
  17537. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17538. /**
  17539. * Gets the class name of that object
  17540. * @returns "ShadowGenerator"
  17541. */
  17542. getClassName(): string;
  17543. /**
  17544. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17545. * @param mesh Mesh to add
  17546. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17547. * @returns the Shadow Generator itself
  17548. */
  17549. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17550. /**
  17551. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17552. * @param mesh Mesh to remove
  17553. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17554. * @returns the Shadow Generator itself
  17555. */
  17556. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17557. /**
  17558. * Controls the extent to which the shadows fade out at the edge of the frustum
  17559. */
  17560. frustumEdgeFalloff: number;
  17561. protected _light: IShadowLight;
  17562. /**
  17563. * Returns the associated light object.
  17564. * @returns the light generating the shadow
  17565. */
  17566. getLight(): IShadowLight;
  17567. /**
  17568. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17569. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17570. * It might on the other hand introduce peter panning.
  17571. */
  17572. forceBackFacesOnly: boolean;
  17573. protected _scene: Scene;
  17574. protected _lightDirection: Vector3;
  17575. protected _effect: Effect;
  17576. protected _viewMatrix: Matrix;
  17577. protected _projectionMatrix: Matrix;
  17578. protected _transformMatrix: Matrix;
  17579. protected _cachedPosition: Vector3;
  17580. protected _cachedDirection: Vector3;
  17581. protected _cachedDefines: string;
  17582. protected _currentRenderID: number;
  17583. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17584. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17585. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17586. protected _blurPostProcesses: PostProcess[];
  17587. protected _mapSize: number;
  17588. protected _currentFaceIndex: number;
  17589. protected _currentFaceIndexCache: number;
  17590. protected _textureType: number;
  17591. protected _defaultTextureMatrix: Matrix;
  17592. protected _storedUniqueId: Nullable<number>;
  17593. /** @hidden */
  17594. static _SceneComponentInitialization: (scene: Scene) => void;
  17595. /**
  17596. * Creates a ShadowGenerator object.
  17597. * A ShadowGenerator is the required tool to use the shadows.
  17598. * Each light casting shadows needs to use its own ShadowGenerator.
  17599. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17600. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17601. * @param light The light object generating the shadows.
  17602. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  17603. */
  17604. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17605. protected _initializeGenerator(): void;
  17606. protected _createTargetRenderTexture(): void;
  17607. protected _initializeShadowMap(): void;
  17608. protected _initializeBlurRTTAndPostProcesses(): void;
  17609. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17610. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17611. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17612. protected _applyFilterValues(): void;
  17613. /**
  17614. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17615. * @param onCompiled Callback triggered at the and of the effects compilation
  17616. * @param options Sets of optional options forcing the compilation with different modes
  17617. */
  17618. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17619. useInstances: boolean;
  17620. }>): void;
  17621. /**
  17622. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17623. * @param options Sets of optional options forcing the compilation with different modes
  17624. * @returns A promise that resolves when the compilation completes
  17625. */
  17626. forceCompilationAsync(options?: Partial<{
  17627. useInstances: boolean;
  17628. }>): Promise<void>;
  17629. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17630. private _prepareShadowDefines;
  17631. /**
  17632. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17633. * @param subMesh The submesh we want to render in the shadow map
  17634. * @param useInstances Defines wether will draw in the map using instances
  17635. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17636. * @returns true if ready otherwise, false
  17637. */
  17638. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17639. /**
  17640. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17641. * @param defines Defines of the material we want to update
  17642. * @param lightIndex Index of the light in the enabled light list of the material
  17643. */
  17644. prepareDefines(defines: any, lightIndex: number): void;
  17645. /**
  17646. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17647. * defined in the generator but impacting the effect).
  17648. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17649. * @param effect The effect we are binfing the information for
  17650. */
  17651. bindShadowLight(lightIndex: string, effect: Effect): void;
  17652. /**
  17653. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17654. * (eq to shadow prjection matrix * light transform matrix)
  17655. * @returns The transform matrix used to create the shadow map
  17656. */
  17657. getTransformMatrix(): Matrix;
  17658. /**
  17659. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17660. * Cube and 2D textures for instance.
  17661. */
  17662. recreateShadowMap(): void;
  17663. protected _disposeBlurPostProcesses(): void;
  17664. protected _disposeRTTandPostProcesses(): void;
  17665. /**
  17666. * Disposes the ShadowGenerator.
  17667. * Returns nothing.
  17668. */
  17669. dispose(): void;
  17670. /**
  17671. * Serializes the shadow generator setup to a json object.
  17672. * @returns The serialized JSON object
  17673. */
  17674. serialize(): any;
  17675. /**
  17676. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17677. * @param parsedShadowGenerator The JSON object to parse
  17678. * @param scene The scene to create the shadow map for
  17679. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17680. * @returns The parsed shadow generator
  17681. */
  17682. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17683. }
  17684. }
  17685. declare module BABYLON {
  17686. /**
  17687. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17688. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17689. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  17690. */
  17691. export abstract class Light extends Node {
  17692. /**
  17693. * Falloff Default: light is falling off following the material specification:
  17694. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17695. */
  17696. static readonly FALLOFF_DEFAULT: number;
  17697. /**
  17698. * Falloff Physical: light is falling off following the inverse squared distance law.
  17699. */
  17700. static readonly FALLOFF_PHYSICAL: number;
  17701. /**
  17702. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17703. * to enhance interoperability with other engines.
  17704. */
  17705. static readonly FALLOFF_GLTF: number;
  17706. /**
  17707. * Falloff Standard: light is falling off like in the standard material
  17708. * to enhance interoperability with other materials.
  17709. */
  17710. static readonly FALLOFF_STANDARD: number;
  17711. /**
  17712. * If every light affecting the material is in this lightmapMode,
  17713. * material.lightmapTexture adds or multiplies
  17714. * (depends on material.useLightmapAsShadowmap)
  17715. * after every other light calculations.
  17716. */
  17717. static readonly LIGHTMAP_DEFAULT: number;
  17718. /**
  17719. * material.lightmapTexture as only diffuse lighting from this light
  17720. * adds only specular lighting from this light
  17721. * adds dynamic shadows
  17722. */
  17723. static readonly LIGHTMAP_SPECULAR: number;
  17724. /**
  17725. * material.lightmapTexture as only lighting
  17726. * no light calculation from this light
  17727. * only adds dynamic shadows from this light
  17728. */
  17729. static readonly LIGHTMAP_SHADOWSONLY: number;
  17730. /**
  17731. * Each light type uses the default quantity according to its type:
  17732. * point/spot lights use luminous intensity
  17733. * directional lights use illuminance
  17734. */
  17735. static readonly INTENSITYMODE_AUTOMATIC: number;
  17736. /**
  17737. * lumen (lm)
  17738. */
  17739. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17740. /**
  17741. * candela (lm/sr)
  17742. */
  17743. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17744. /**
  17745. * lux (lm/m^2)
  17746. */
  17747. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17748. /**
  17749. * nit (cd/m^2)
  17750. */
  17751. static readonly INTENSITYMODE_LUMINANCE: number;
  17752. /**
  17753. * Light type const id of the point light.
  17754. */
  17755. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17756. /**
  17757. * Light type const id of the directional light.
  17758. */
  17759. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17760. /**
  17761. * Light type const id of the spot light.
  17762. */
  17763. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17764. /**
  17765. * Light type const id of the hemispheric light.
  17766. */
  17767. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17768. /**
  17769. * Diffuse gives the basic color to an object.
  17770. */
  17771. diffuse: Color3;
  17772. /**
  17773. * Specular produces a highlight color on an object.
  17774. * Note: This is note affecting PBR materials.
  17775. */
  17776. specular: Color3;
  17777. /**
  17778. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17779. * falling off base on range or angle.
  17780. * This can be set to any values in Light.FALLOFF_x.
  17781. *
  17782. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17783. * other types of materials.
  17784. */
  17785. falloffType: number;
  17786. /**
  17787. * Strength of the light.
  17788. * Note: By default it is define in the framework own unit.
  17789. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17790. */
  17791. intensity: number;
  17792. private _range;
  17793. protected _inverseSquaredRange: number;
  17794. /**
  17795. * Defines how far from the source the light is impacting in scene units.
  17796. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17797. */
  17798. get range(): number;
  17799. /**
  17800. * Defines how far from the source the light is impacting in scene units.
  17801. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17802. */
  17803. set range(value: number);
  17804. /**
  17805. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17806. * of light.
  17807. */
  17808. private _photometricScale;
  17809. private _intensityMode;
  17810. /**
  17811. * Gets the photometric scale used to interpret the intensity.
  17812. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17813. */
  17814. get intensityMode(): number;
  17815. /**
  17816. * Sets the photometric scale used to interpret the intensity.
  17817. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17818. */
  17819. set intensityMode(value: number);
  17820. private _radius;
  17821. /**
  17822. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17823. */
  17824. get radius(): number;
  17825. /**
  17826. * sets the light radius used by PBR Materials to simulate soft area lights.
  17827. */
  17828. set radius(value: number);
  17829. private _renderPriority;
  17830. /**
  17831. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17832. * exceeding the number allowed of the materials.
  17833. */
  17834. renderPriority: number;
  17835. private _shadowEnabled;
  17836. /**
  17837. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17838. * the current shadow generator.
  17839. */
  17840. get shadowEnabled(): boolean;
  17841. /**
  17842. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17843. * the current shadow generator.
  17844. */
  17845. set shadowEnabled(value: boolean);
  17846. private _includedOnlyMeshes;
  17847. /**
  17848. * Gets the only meshes impacted by this light.
  17849. */
  17850. get includedOnlyMeshes(): AbstractMesh[];
  17851. /**
  17852. * Sets the only meshes impacted by this light.
  17853. */
  17854. set includedOnlyMeshes(value: AbstractMesh[]);
  17855. private _excludedMeshes;
  17856. /**
  17857. * Gets the meshes not impacted by this light.
  17858. */
  17859. get excludedMeshes(): AbstractMesh[];
  17860. /**
  17861. * Sets the meshes not impacted by this light.
  17862. */
  17863. set excludedMeshes(value: AbstractMesh[]);
  17864. private _excludeWithLayerMask;
  17865. /**
  17866. * Gets the layer id use to find what meshes are not impacted by the light.
  17867. * Inactive if 0
  17868. */
  17869. get excludeWithLayerMask(): number;
  17870. /**
  17871. * Sets the layer id use to find what meshes are not impacted by the light.
  17872. * Inactive if 0
  17873. */
  17874. set excludeWithLayerMask(value: number);
  17875. private _includeOnlyWithLayerMask;
  17876. /**
  17877. * Gets the layer id use to find what meshes are impacted by the light.
  17878. * Inactive if 0
  17879. */
  17880. get includeOnlyWithLayerMask(): number;
  17881. /**
  17882. * Sets the layer id use to find what meshes are impacted by the light.
  17883. * Inactive if 0
  17884. */
  17885. set includeOnlyWithLayerMask(value: number);
  17886. private _lightmapMode;
  17887. /**
  17888. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17889. */
  17890. get lightmapMode(): number;
  17891. /**
  17892. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17893. */
  17894. set lightmapMode(value: number);
  17895. /**
  17896. * Shadow generator associted to the light.
  17897. * @hidden Internal use only.
  17898. */
  17899. _shadowGenerator: Nullable<IShadowGenerator>;
  17900. /**
  17901. * @hidden Internal use only.
  17902. */
  17903. _excludedMeshesIds: string[];
  17904. /**
  17905. * @hidden Internal use only.
  17906. */
  17907. _includedOnlyMeshesIds: string[];
  17908. /**
  17909. * The current light unifom buffer.
  17910. * @hidden Internal use only.
  17911. */
  17912. _uniformBuffer: UniformBuffer;
  17913. /** @hidden */
  17914. _renderId: number;
  17915. /**
  17916. * Creates a Light object in the scene.
  17917. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17918. * @param name The firendly name of the light
  17919. * @param scene The scene the light belongs too
  17920. */
  17921. constructor(name: string, scene: Scene);
  17922. protected abstract _buildUniformLayout(): void;
  17923. /**
  17924. * Sets the passed Effect "effect" with the Light information.
  17925. * @param effect The effect to update
  17926. * @param lightIndex The index of the light in the effect to update
  17927. * @returns The light
  17928. */
  17929. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17930. /**
  17931. * Sets the passed Effect "effect" with the Light textures.
  17932. * @param effect The effect to update
  17933. * @param lightIndex The index of the light in the effect to update
  17934. * @returns The light
  17935. */
  17936. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17937. /**
  17938. * Binds the lights information from the scene to the effect for the given mesh.
  17939. * @param lightIndex Light index
  17940. * @param scene The scene where the light belongs to
  17941. * @param effect The effect we are binding the data to
  17942. * @param useSpecular Defines if specular is supported
  17943. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17944. */
  17945. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17946. /**
  17947. * Sets the passed Effect "effect" with the Light information.
  17948. * @param effect The effect to update
  17949. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17950. * @returns The light
  17951. */
  17952. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17953. /**
  17954. * Returns the string "Light".
  17955. * @returns the class name
  17956. */
  17957. getClassName(): string;
  17958. /** @hidden */
  17959. readonly _isLight: boolean;
  17960. /**
  17961. * Converts the light information to a readable string for debug purpose.
  17962. * @param fullDetails Supports for multiple levels of logging within scene loading
  17963. * @returns the human readable light info
  17964. */
  17965. toString(fullDetails?: boolean): string;
  17966. /** @hidden */
  17967. protected _syncParentEnabledState(): void;
  17968. /**
  17969. * Set the enabled state of this node.
  17970. * @param value - the new enabled state
  17971. */
  17972. setEnabled(value: boolean): void;
  17973. /**
  17974. * Returns the Light associated shadow generator if any.
  17975. * @return the associated shadow generator.
  17976. */
  17977. getShadowGenerator(): Nullable<IShadowGenerator>;
  17978. /**
  17979. * Returns a Vector3, the absolute light position in the World.
  17980. * @returns the world space position of the light
  17981. */
  17982. getAbsolutePosition(): Vector3;
  17983. /**
  17984. * Specifies if the light will affect the passed mesh.
  17985. * @param mesh The mesh to test against the light
  17986. * @return true the mesh is affected otherwise, false.
  17987. */
  17988. canAffectMesh(mesh: AbstractMesh): boolean;
  17989. /**
  17990. * Sort function to order lights for rendering.
  17991. * @param a First Light object to compare to second.
  17992. * @param b Second Light object to compare first.
  17993. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17994. */
  17995. static CompareLightsPriority(a: Light, b: Light): number;
  17996. /**
  17997. * Releases resources associated with this node.
  17998. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17999. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18000. */
  18001. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18002. /**
  18003. * Returns the light type ID (integer).
  18004. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18005. */
  18006. getTypeID(): number;
  18007. /**
  18008. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18009. * @returns the scaled intensity in intensity mode unit
  18010. */
  18011. getScaledIntensity(): number;
  18012. /**
  18013. * Returns a new Light object, named "name", from the current one.
  18014. * @param name The name of the cloned light
  18015. * @param newParent The parent of this light, if it has one
  18016. * @returns the new created light
  18017. */
  18018. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18019. /**
  18020. * Serializes the current light into a Serialization object.
  18021. * @returns the serialized object.
  18022. */
  18023. serialize(): any;
  18024. /**
  18025. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18026. * This new light is named "name" and added to the passed scene.
  18027. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18028. * @param name The friendly name of the light
  18029. * @param scene The scene the new light will belong to
  18030. * @returns the constructor function
  18031. */
  18032. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18033. /**
  18034. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18035. * @param parsedLight The JSON representation of the light
  18036. * @param scene The scene to create the parsed light in
  18037. * @returns the created light after parsing
  18038. */
  18039. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18040. private _hookArrayForExcluded;
  18041. private _hookArrayForIncludedOnly;
  18042. private _resyncMeshes;
  18043. /**
  18044. * Forces the meshes to update their light related information in their rendering used effects
  18045. * @hidden Internal Use Only
  18046. */
  18047. _markMeshesAsLightDirty(): void;
  18048. /**
  18049. * Recomputes the cached photometric scale if needed.
  18050. */
  18051. private _computePhotometricScale;
  18052. /**
  18053. * Returns the Photometric Scale according to the light type and intensity mode.
  18054. */
  18055. private _getPhotometricScale;
  18056. /**
  18057. * Reorder the light in the scene according to their defined priority.
  18058. * @hidden Internal Use Only
  18059. */
  18060. _reorderLightsInScene(): void;
  18061. /**
  18062. * Prepares the list of defines specific to the light type.
  18063. * @param defines the list of defines
  18064. * @param lightIndex defines the index of the light for the effect
  18065. */
  18066. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18067. }
  18068. }
  18069. declare module BABYLON {
  18070. /**
  18071. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18072. * This is the base of the follow, arc rotate cameras and Free camera
  18073. * @see http://doc.babylonjs.com/features/cameras
  18074. */
  18075. export class TargetCamera extends Camera {
  18076. private static _RigCamTransformMatrix;
  18077. private static _TargetTransformMatrix;
  18078. private static _TargetFocalPoint;
  18079. private _tmpUpVector;
  18080. private _tmpTargetVector;
  18081. /**
  18082. * Define the current direction the camera is moving to
  18083. */
  18084. cameraDirection: Vector3;
  18085. /**
  18086. * Define the current rotation the camera is rotating to
  18087. */
  18088. cameraRotation: Vector2;
  18089. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18090. ignoreParentScaling: boolean;
  18091. /**
  18092. * When set, the up vector of the camera will be updated by the rotation of the camera
  18093. */
  18094. updateUpVectorFromRotation: boolean;
  18095. private _tmpQuaternion;
  18096. /**
  18097. * Define the current rotation of the camera
  18098. */
  18099. rotation: Vector3;
  18100. /**
  18101. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18102. */
  18103. rotationQuaternion: Quaternion;
  18104. /**
  18105. * Define the current speed of the camera
  18106. */
  18107. speed: number;
  18108. /**
  18109. * Add constraint to the camera to prevent it to move freely in all directions and
  18110. * around all axis.
  18111. */
  18112. noRotationConstraint: boolean;
  18113. /**
  18114. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18115. * panning
  18116. */
  18117. invertRotation: boolean;
  18118. /**
  18119. * Speed multiplier for inverse camera panning
  18120. */
  18121. inverseRotationSpeed: number;
  18122. /**
  18123. * Define the current target of the camera as an object or a position.
  18124. */
  18125. lockedTarget: any;
  18126. /** @hidden */
  18127. _currentTarget: Vector3;
  18128. /** @hidden */
  18129. _initialFocalDistance: number;
  18130. /** @hidden */
  18131. _viewMatrix: Matrix;
  18132. /** @hidden */
  18133. _camMatrix: Matrix;
  18134. /** @hidden */
  18135. _cameraTransformMatrix: Matrix;
  18136. /** @hidden */
  18137. _cameraRotationMatrix: Matrix;
  18138. /** @hidden */
  18139. _referencePoint: Vector3;
  18140. /** @hidden */
  18141. _transformedReferencePoint: Vector3;
  18142. /** @hidden */
  18143. _reset: () => void;
  18144. private _defaultUp;
  18145. /**
  18146. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18147. * This is the base of the follow, arc rotate cameras and Free camera
  18148. * @see http://doc.babylonjs.com/features/cameras
  18149. * @param name Defines the name of the camera in the scene
  18150. * @param position Defines the start position of the camera in the scene
  18151. * @param scene Defines the scene the camera belongs to
  18152. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18153. */
  18154. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18155. /**
  18156. * Gets the position in front of the camera at a given distance.
  18157. * @param distance The distance from the camera we want the position to be
  18158. * @returns the position
  18159. */
  18160. getFrontPosition(distance: number): Vector3;
  18161. /** @hidden */
  18162. _getLockedTargetPosition(): Nullable<Vector3>;
  18163. private _storedPosition;
  18164. private _storedRotation;
  18165. private _storedRotationQuaternion;
  18166. /**
  18167. * Store current camera state of the camera (fov, position, rotation, etc..)
  18168. * @returns the camera
  18169. */
  18170. storeState(): Camera;
  18171. /**
  18172. * Restored camera state. You must call storeState() first
  18173. * @returns whether it was successful or not
  18174. * @hidden
  18175. */
  18176. _restoreStateValues(): boolean;
  18177. /** @hidden */
  18178. _initCache(): void;
  18179. /** @hidden */
  18180. _updateCache(ignoreParentClass?: boolean): void;
  18181. /** @hidden */
  18182. _isSynchronizedViewMatrix(): boolean;
  18183. /** @hidden */
  18184. _computeLocalCameraSpeed(): number;
  18185. /**
  18186. * Defines the target the camera should look at.
  18187. * @param target Defines the new target as a Vector or a mesh
  18188. */
  18189. setTarget(target: Vector3): void;
  18190. /**
  18191. * Return the current target position of the camera. This value is expressed in local space.
  18192. * @returns the target position
  18193. */
  18194. getTarget(): Vector3;
  18195. /** @hidden */
  18196. _decideIfNeedsToMove(): boolean;
  18197. /** @hidden */
  18198. _updatePosition(): void;
  18199. /** @hidden */
  18200. _checkInputs(): void;
  18201. protected _updateCameraRotationMatrix(): void;
  18202. /**
  18203. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  18204. * @returns the current camera
  18205. */
  18206. private _rotateUpVectorWithCameraRotationMatrix;
  18207. private _cachedRotationZ;
  18208. private _cachedQuaternionRotationZ;
  18209. /** @hidden */
  18210. _getViewMatrix(): Matrix;
  18211. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18212. /**
  18213. * @hidden
  18214. */
  18215. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18216. /**
  18217. * @hidden
  18218. */
  18219. _updateRigCameras(): void;
  18220. private _getRigCamPositionAndTarget;
  18221. /**
  18222. * Gets the current object class name.
  18223. * @return the class name
  18224. */
  18225. getClassName(): string;
  18226. }
  18227. }
  18228. declare module BABYLON {
  18229. /**
  18230. * Gather the list of keyboard event types as constants.
  18231. */
  18232. export class KeyboardEventTypes {
  18233. /**
  18234. * The keydown event is fired when a key becomes active (pressed).
  18235. */
  18236. static readonly KEYDOWN: number;
  18237. /**
  18238. * The keyup event is fired when a key has been released.
  18239. */
  18240. static readonly KEYUP: number;
  18241. }
  18242. /**
  18243. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18244. */
  18245. export class KeyboardInfo {
  18246. /**
  18247. * Defines the type of event (KeyboardEventTypes)
  18248. */
  18249. type: number;
  18250. /**
  18251. * Defines the related dom event
  18252. */
  18253. event: KeyboardEvent;
  18254. /**
  18255. * Instantiates a new keyboard info.
  18256. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18257. * @param type Defines the type of event (KeyboardEventTypes)
  18258. * @param event Defines the related dom event
  18259. */
  18260. constructor(
  18261. /**
  18262. * Defines the type of event (KeyboardEventTypes)
  18263. */
  18264. type: number,
  18265. /**
  18266. * Defines the related dom event
  18267. */
  18268. event: KeyboardEvent);
  18269. }
  18270. /**
  18271. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18272. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18273. */
  18274. export class KeyboardInfoPre extends KeyboardInfo {
  18275. /**
  18276. * Defines the type of event (KeyboardEventTypes)
  18277. */
  18278. type: number;
  18279. /**
  18280. * Defines the related dom event
  18281. */
  18282. event: KeyboardEvent;
  18283. /**
  18284. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18285. */
  18286. skipOnPointerObservable: boolean;
  18287. /**
  18288. * Instantiates a new keyboard pre info.
  18289. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18290. * @param type Defines the type of event (KeyboardEventTypes)
  18291. * @param event Defines the related dom event
  18292. */
  18293. constructor(
  18294. /**
  18295. * Defines the type of event (KeyboardEventTypes)
  18296. */
  18297. type: number,
  18298. /**
  18299. * Defines the related dom event
  18300. */
  18301. event: KeyboardEvent);
  18302. }
  18303. }
  18304. declare module BABYLON {
  18305. /**
  18306. * Manage the keyboard inputs to control the movement of a free camera.
  18307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18308. */
  18309. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18310. /**
  18311. * Defines the camera the input is attached to.
  18312. */
  18313. camera: FreeCamera;
  18314. /**
  18315. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18316. */
  18317. keysUp: number[];
  18318. /**
  18319. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18320. */
  18321. keysUpward: number[];
  18322. /**
  18323. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18324. */
  18325. keysDown: number[];
  18326. /**
  18327. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18328. */
  18329. keysDownward: number[];
  18330. /**
  18331. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18332. */
  18333. keysLeft: number[];
  18334. /**
  18335. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18336. */
  18337. keysRight: number[];
  18338. private _keys;
  18339. private _onCanvasBlurObserver;
  18340. private _onKeyboardObserver;
  18341. private _engine;
  18342. private _scene;
  18343. /**
  18344. * Attach the input controls to a specific dom element to get the input from.
  18345. * @param element Defines the element the controls should be listened from
  18346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18347. */
  18348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18349. /**
  18350. * Detach the current controls from the specified dom element.
  18351. * @param element Defines the element to stop listening the inputs from
  18352. */
  18353. detachControl(element: Nullable<HTMLElement>): void;
  18354. /**
  18355. * Update the current camera state depending on the inputs that have been used this frame.
  18356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18357. */
  18358. checkInputs(): void;
  18359. /**
  18360. * Gets the class name of the current intput.
  18361. * @returns the class name
  18362. */
  18363. getClassName(): string;
  18364. /** @hidden */
  18365. _onLostFocus(): void;
  18366. /**
  18367. * Get the friendly name associated with the input class.
  18368. * @returns the input friendly name
  18369. */
  18370. getSimpleName(): string;
  18371. }
  18372. }
  18373. declare module BABYLON {
  18374. /**
  18375. * Gather the list of pointer event types as constants.
  18376. */
  18377. export class PointerEventTypes {
  18378. /**
  18379. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18380. */
  18381. static readonly POINTERDOWN: number;
  18382. /**
  18383. * The pointerup event is fired when a pointer is no longer active.
  18384. */
  18385. static readonly POINTERUP: number;
  18386. /**
  18387. * The pointermove event is fired when a pointer changes coordinates.
  18388. */
  18389. static readonly POINTERMOVE: number;
  18390. /**
  18391. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18392. */
  18393. static readonly POINTERWHEEL: number;
  18394. /**
  18395. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18396. */
  18397. static readonly POINTERPICK: number;
  18398. /**
  18399. * The pointertap event is fired when a the object has been touched and released without drag.
  18400. */
  18401. static readonly POINTERTAP: number;
  18402. /**
  18403. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18404. */
  18405. static readonly POINTERDOUBLETAP: number;
  18406. }
  18407. /**
  18408. * Base class of pointer info types.
  18409. */
  18410. export class PointerInfoBase {
  18411. /**
  18412. * Defines the type of event (PointerEventTypes)
  18413. */
  18414. type: number;
  18415. /**
  18416. * Defines the related dom event
  18417. */
  18418. event: PointerEvent | MouseWheelEvent;
  18419. /**
  18420. * Instantiates the base class of pointers info.
  18421. * @param type Defines the type of event (PointerEventTypes)
  18422. * @param event Defines the related dom event
  18423. */
  18424. constructor(
  18425. /**
  18426. * Defines the type of event (PointerEventTypes)
  18427. */
  18428. type: number,
  18429. /**
  18430. * Defines the related dom event
  18431. */
  18432. event: PointerEvent | MouseWheelEvent);
  18433. }
  18434. /**
  18435. * This class is used to store pointer related info for the onPrePointerObservable event.
  18436. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18437. */
  18438. export class PointerInfoPre extends PointerInfoBase {
  18439. /**
  18440. * Ray from a pointer if availible (eg. 6dof controller)
  18441. */
  18442. ray: Nullable<Ray>;
  18443. /**
  18444. * Defines the local position of the pointer on the canvas.
  18445. */
  18446. localPosition: Vector2;
  18447. /**
  18448. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18449. */
  18450. skipOnPointerObservable: boolean;
  18451. /**
  18452. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18453. * @param type Defines the type of event (PointerEventTypes)
  18454. * @param event Defines the related dom event
  18455. * @param localX Defines the local x coordinates of the pointer when the event occured
  18456. * @param localY Defines the local y coordinates of the pointer when the event occured
  18457. */
  18458. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18459. }
  18460. /**
  18461. * This type contains all the data related to a pointer event in Babylon.js.
  18462. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18463. */
  18464. export class PointerInfo extends PointerInfoBase {
  18465. /**
  18466. * Defines the picking info associated to the info (if any)\
  18467. */
  18468. pickInfo: Nullable<PickingInfo>;
  18469. /**
  18470. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18471. * @param type Defines the type of event (PointerEventTypes)
  18472. * @param event Defines the related dom event
  18473. * @param pickInfo Defines the picking info associated to the info (if any)\
  18474. */
  18475. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18476. /**
  18477. * Defines the picking info associated to the info (if any)\
  18478. */
  18479. pickInfo: Nullable<PickingInfo>);
  18480. }
  18481. /**
  18482. * Data relating to a touch event on the screen.
  18483. */
  18484. export interface PointerTouch {
  18485. /**
  18486. * X coordinate of touch.
  18487. */
  18488. x: number;
  18489. /**
  18490. * Y coordinate of touch.
  18491. */
  18492. y: number;
  18493. /**
  18494. * Id of touch. Unique for each finger.
  18495. */
  18496. pointerId: number;
  18497. /**
  18498. * Event type passed from DOM.
  18499. */
  18500. type: any;
  18501. }
  18502. }
  18503. declare module BABYLON {
  18504. /**
  18505. * Manage the mouse inputs to control the movement of a free camera.
  18506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18507. */
  18508. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18509. /**
  18510. * Define if touch is enabled in the mouse input
  18511. */
  18512. touchEnabled: boolean;
  18513. /**
  18514. * Defines the camera the input is attached to.
  18515. */
  18516. camera: FreeCamera;
  18517. /**
  18518. * Defines the buttons associated with the input to handle camera move.
  18519. */
  18520. buttons: number[];
  18521. /**
  18522. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18523. */
  18524. angularSensibility: number;
  18525. private _pointerInput;
  18526. private _onMouseMove;
  18527. private _observer;
  18528. private previousPosition;
  18529. /**
  18530. * Observable for when a pointer move event occurs containing the move offset
  18531. */
  18532. onPointerMovedObservable: Observable<{
  18533. offsetX: number;
  18534. offsetY: number;
  18535. }>;
  18536. /**
  18537. * @hidden
  18538. * If the camera should be rotated automatically based on pointer movement
  18539. */
  18540. _allowCameraRotation: boolean;
  18541. /**
  18542. * Manage the mouse inputs to control the movement of a free camera.
  18543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18544. * @param touchEnabled Defines if touch is enabled or not
  18545. */
  18546. constructor(
  18547. /**
  18548. * Define if touch is enabled in the mouse input
  18549. */
  18550. touchEnabled?: boolean);
  18551. /**
  18552. * Attach the input controls to a specific dom element to get the input from.
  18553. * @param element Defines the element the controls should be listened from
  18554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18555. */
  18556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18557. /**
  18558. * Called on JS contextmenu event.
  18559. * Override this method to provide functionality.
  18560. */
  18561. protected onContextMenu(evt: PointerEvent): void;
  18562. /**
  18563. * Detach the current controls from the specified dom element.
  18564. * @param element Defines the element to stop listening the inputs from
  18565. */
  18566. detachControl(element: Nullable<HTMLElement>): void;
  18567. /**
  18568. * Gets the class name of the current intput.
  18569. * @returns the class name
  18570. */
  18571. getClassName(): string;
  18572. /**
  18573. * Get the friendly name associated with the input class.
  18574. * @returns the input friendly name
  18575. */
  18576. getSimpleName(): string;
  18577. }
  18578. }
  18579. declare module BABYLON {
  18580. /**
  18581. * Manage the touch inputs to control the movement of a free camera.
  18582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18583. */
  18584. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18585. /**
  18586. * Defines the camera the input is attached to.
  18587. */
  18588. camera: FreeCamera;
  18589. /**
  18590. * Defines the touch sensibility for rotation.
  18591. * The higher the faster.
  18592. */
  18593. touchAngularSensibility: number;
  18594. /**
  18595. * Defines the touch sensibility for move.
  18596. * The higher the faster.
  18597. */
  18598. touchMoveSensibility: number;
  18599. private _offsetX;
  18600. private _offsetY;
  18601. private _pointerPressed;
  18602. private _pointerInput;
  18603. private _observer;
  18604. private _onLostFocus;
  18605. /**
  18606. * Attach the input controls to a specific dom element to get the input from.
  18607. * @param element Defines the element the controls should be listened from
  18608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18609. */
  18610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18611. /**
  18612. * Detach the current controls from the specified dom element.
  18613. * @param element Defines the element to stop listening the inputs from
  18614. */
  18615. detachControl(element: Nullable<HTMLElement>): void;
  18616. /**
  18617. * Update the current camera state depending on the inputs that have been used this frame.
  18618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18619. */
  18620. checkInputs(): void;
  18621. /**
  18622. * Gets the class name of the current intput.
  18623. * @returns the class name
  18624. */
  18625. getClassName(): string;
  18626. /**
  18627. * Get the friendly name associated with the input class.
  18628. * @returns the input friendly name
  18629. */
  18630. getSimpleName(): string;
  18631. }
  18632. }
  18633. declare module BABYLON {
  18634. /**
  18635. * Default Inputs manager for the FreeCamera.
  18636. * It groups all the default supported inputs for ease of use.
  18637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18638. */
  18639. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18640. /**
  18641. * @hidden
  18642. */
  18643. _mouseInput: Nullable<FreeCameraMouseInput>;
  18644. /**
  18645. * Instantiates a new FreeCameraInputsManager.
  18646. * @param camera Defines the camera the inputs belong to
  18647. */
  18648. constructor(camera: FreeCamera);
  18649. /**
  18650. * Add keyboard input support to the input manager.
  18651. * @returns the current input manager
  18652. */
  18653. addKeyboard(): FreeCameraInputsManager;
  18654. /**
  18655. * Add mouse input support to the input manager.
  18656. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18657. * @returns the current input manager
  18658. */
  18659. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18660. /**
  18661. * Removes the mouse input support from the manager
  18662. * @returns the current input manager
  18663. */
  18664. removeMouse(): FreeCameraInputsManager;
  18665. /**
  18666. * Add touch input support to the input manager.
  18667. * @returns the current input manager
  18668. */
  18669. addTouch(): FreeCameraInputsManager;
  18670. /**
  18671. * Remove all attached input methods from a camera
  18672. */
  18673. clear(): void;
  18674. }
  18675. }
  18676. declare module BABYLON {
  18677. /**
  18678. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18679. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18680. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18681. */
  18682. export class FreeCamera extends TargetCamera {
  18683. /**
  18684. * Define the collision ellipsoid of the camera.
  18685. * This is helpful to simulate a camera body like the player body around the camera
  18686. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18687. */
  18688. ellipsoid: Vector3;
  18689. /**
  18690. * Define an offset for the position of the ellipsoid around the camera.
  18691. * This can be helpful to determine the center of the body near the gravity center of the body
  18692. * instead of its head.
  18693. */
  18694. ellipsoidOffset: Vector3;
  18695. /**
  18696. * Enable or disable collisions of the camera with the rest of the scene objects.
  18697. */
  18698. checkCollisions: boolean;
  18699. /**
  18700. * Enable or disable gravity on the camera.
  18701. */
  18702. applyGravity: boolean;
  18703. /**
  18704. * Define the input manager associated to the camera.
  18705. */
  18706. inputs: FreeCameraInputsManager;
  18707. /**
  18708. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18709. * Higher values reduce sensitivity.
  18710. */
  18711. get angularSensibility(): number;
  18712. /**
  18713. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18714. * Higher values reduce sensitivity.
  18715. */
  18716. set angularSensibility(value: number);
  18717. /**
  18718. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18719. */
  18720. get keysUp(): number[];
  18721. set keysUp(value: number[]);
  18722. /**
  18723. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18724. */
  18725. get keysUpward(): number[];
  18726. set keysUpward(value: number[]);
  18727. /**
  18728. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18729. */
  18730. get keysDown(): number[];
  18731. set keysDown(value: number[]);
  18732. /**
  18733. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18734. */
  18735. get keysDownward(): number[];
  18736. set keysDownward(value: number[]);
  18737. /**
  18738. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18739. */
  18740. get keysLeft(): number[];
  18741. set keysLeft(value: number[]);
  18742. /**
  18743. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18744. */
  18745. get keysRight(): number[];
  18746. set keysRight(value: number[]);
  18747. /**
  18748. * Event raised when the camera collide with a mesh in the scene.
  18749. */
  18750. onCollide: (collidedMesh: AbstractMesh) => void;
  18751. private _collider;
  18752. private _needMoveForGravity;
  18753. private _oldPosition;
  18754. private _diffPosition;
  18755. private _newPosition;
  18756. /** @hidden */
  18757. _localDirection: Vector3;
  18758. /** @hidden */
  18759. _transformedDirection: Vector3;
  18760. /**
  18761. * Instantiates a Free Camera.
  18762. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18763. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18764. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18765. * @param name Define the name of the camera in the scene
  18766. * @param position Define the start position of the camera in the scene
  18767. * @param scene Define the scene the camera belongs to
  18768. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18769. */
  18770. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18771. /**
  18772. * Attached controls to the current camera.
  18773. * @param element Defines the element the controls should be listened from
  18774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18775. */
  18776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18777. /**
  18778. * Detach the current controls from the camera.
  18779. * The camera will stop reacting to inputs.
  18780. * @param element Defines the element to stop listening the inputs from
  18781. */
  18782. detachControl(element: HTMLElement): void;
  18783. private _collisionMask;
  18784. /**
  18785. * Define a collision mask to limit the list of object the camera can collide with
  18786. */
  18787. get collisionMask(): number;
  18788. set collisionMask(mask: number);
  18789. /** @hidden */
  18790. _collideWithWorld(displacement: Vector3): void;
  18791. private _onCollisionPositionChange;
  18792. /** @hidden */
  18793. _checkInputs(): void;
  18794. /** @hidden */
  18795. _decideIfNeedsToMove(): boolean;
  18796. /** @hidden */
  18797. _updatePosition(): void;
  18798. /**
  18799. * Destroy the camera and release the current resources hold by it.
  18800. */
  18801. dispose(): void;
  18802. /**
  18803. * Gets the current object class name.
  18804. * @return the class name
  18805. */
  18806. getClassName(): string;
  18807. }
  18808. }
  18809. declare module BABYLON {
  18810. /**
  18811. * Represents a gamepad control stick position
  18812. */
  18813. export class StickValues {
  18814. /**
  18815. * The x component of the control stick
  18816. */
  18817. x: number;
  18818. /**
  18819. * The y component of the control stick
  18820. */
  18821. y: number;
  18822. /**
  18823. * Initializes the gamepad x and y control stick values
  18824. * @param x The x component of the gamepad control stick value
  18825. * @param y The y component of the gamepad control stick value
  18826. */
  18827. constructor(
  18828. /**
  18829. * The x component of the control stick
  18830. */
  18831. x: number,
  18832. /**
  18833. * The y component of the control stick
  18834. */
  18835. y: number);
  18836. }
  18837. /**
  18838. * An interface which manages callbacks for gamepad button changes
  18839. */
  18840. export interface GamepadButtonChanges {
  18841. /**
  18842. * Called when a gamepad has been changed
  18843. */
  18844. changed: boolean;
  18845. /**
  18846. * Called when a gamepad press event has been triggered
  18847. */
  18848. pressChanged: boolean;
  18849. /**
  18850. * Called when a touch event has been triggered
  18851. */
  18852. touchChanged: boolean;
  18853. /**
  18854. * Called when a value has changed
  18855. */
  18856. valueChanged: boolean;
  18857. }
  18858. /**
  18859. * Represents a gamepad
  18860. */
  18861. export class Gamepad {
  18862. /**
  18863. * The id of the gamepad
  18864. */
  18865. id: string;
  18866. /**
  18867. * The index of the gamepad
  18868. */
  18869. index: number;
  18870. /**
  18871. * The browser gamepad
  18872. */
  18873. browserGamepad: any;
  18874. /**
  18875. * Specifies what type of gamepad this represents
  18876. */
  18877. type: number;
  18878. private _leftStick;
  18879. private _rightStick;
  18880. /** @hidden */
  18881. _isConnected: boolean;
  18882. private _leftStickAxisX;
  18883. private _leftStickAxisY;
  18884. private _rightStickAxisX;
  18885. private _rightStickAxisY;
  18886. /**
  18887. * Triggered when the left control stick has been changed
  18888. */
  18889. private _onleftstickchanged;
  18890. /**
  18891. * Triggered when the right control stick has been changed
  18892. */
  18893. private _onrightstickchanged;
  18894. /**
  18895. * Represents a gamepad controller
  18896. */
  18897. static GAMEPAD: number;
  18898. /**
  18899. * Represents a generic controller
  18900. */
  18901. static GENERIC: number;
  18902. /**
  18903. * Represents an XBox controller
  18904. */
  18905. static XBOX: number;
  18906. /**
  18907. * Represents a pose-enabled controller
  18908. */
  18909. static POSE_ENABLED: number;
  18910. /**
  18911. * Represents an Dual Shock controller
  18912. */
  18913. static DUALSHOCK: number;
  18914. /**
  18915. * Specifies whether the left control stick should be Y-inverted
  18916. */
  18917. protected _invertLeftStickY: boolean;
  18918. /**
  18919. * Specifies if the gamepad has been connected
  18920. */
  18921. get isConnected(): boolean;
  18922. /**
  18923. * Initializes the gamepad
  18924. * @param id The id of the gamepad
  18925. * @param index The index of the gamepad
  18926. * @param browserGamepad The browser gamepad
  18927. * @param leftStickX The x component of the left joystick
  18928. * @param leftStickY The y component of the left joystick
  18929. * @param rightStickX The x component of the right joystick
  18930. * @param rightStickY The y component of the right joystick
  18931. */
  18932. constructor(
  18933. /**
  18934. * The id of the gamepad
  18935. */
  18936. id: string,
  18937. /**
  18938. * The index of the gamepad
  18939. */
  18940. index: number,
  18941. /**
  18942. * The browser gamepad
  18943. */
  18944. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18945. /**
  18946. * Callback triggered when the left joystick has changed
  18947. * @param callback
  18948. */
  18949. onleftstickchanged(callback: (values: StickValues) => void): void;
  18950. /**
  18951. * Callback triggered when the right joystick has changed
  18952. * @param callback
  18953. */
  18954. onrightstickchanged(callback: (values: StickValues) => void): void;
  18955. /**
  18956. * Gets the left joystick
  18957. */
  18958. get leftStick(): StickValues;
  18959. /**
  18960. * Sets the left joystick values
  18961. */
  18962. set leftStick(newValues: StickValues);
  18963. /**
  18964. * Gets the right joystick
  18965. */
  18966. get rightStick(): StickValues;
  18967. /**
  18968. * Sets the right joystick value
  18969. */
  18970. set rightStick(newValues: StickValues);
  18971. /**
  18972. * Updates the gamepad joystick positions
  18973. */
  18974. update(): void;
  18975. /**
  18976. * Disposes the gamepad
  18977. */
  18978. dispose(): void;
  18979. }
  18980. /**
  18981. * Represents a generic gamepad
  18982. */
  18983. export class GenericPad extends Gamepad {
  18984. private _buttons;
  18985. private _onbuttondown;
  18986. private _onbuttonup;
  18987. /**
  18988. * Observable triggered when a button has been pressed
  18989. */
  18990. onButtonDownObservable: Observable<number>;
  18991. /**
  18992. * Observable triggered when a button has been released
  18993. */
  18994. onButtonUpObservable: Observable<number>;
  18995. /**
  18996. * Callback triggered when a button has been pressed
  18997. * @param callback Called when a button has been pressed
  18998. */
  18999. onbuttondown(callback: (buttonPressed: number) => void): void;
  19000. /**
  19001. * Callback triggered when a button has been released
  19002. * @param callback Called when a button has been released
  19003. */
  19004. onbuttonup(callback: (buttonReleased: number) => void): void;
  19005. /**
  19006. * Initializes the generic gamepad
  19007. * @param id The id of the generic gamepad
  19008. * @param index The index of the generic gamepad
  19009. * @param browserGamepad The browser gamepad
  19010. */
  19011. constructor(id: string, index: number, browserGamepad: any);
  19012. private _setButtonValue;
  19013. /**
  19014. * Updates the generic gamepad
  19015. */
  19016. update(): void;
  19017. /**
  19018. * Disposes the generic gamepad
  19019. */
  19020. dispose(): void;
  19021. }
  19022. }
  19023. declare module BABYLON {
  19024. /**
  19025. * Defines the types of pose enabled controllers that are supported
  19026. */
  19027. export enum PoseEnabledControllerType {
  19028. /**
  19029. * HTC Vive
  19030. */
  19031. VIVE = 0,
  19032. /**
  19033. * Oculus Rift
  19034. */
  19035. OCULUS = 1,
  19036. /**
  19037. * Windows mixed reality
  19038. */
  19039. WINDOWS = 2,
  19040. /**
  19041. * Samsung gear VR
  19042. */
  19043. GEAR_VR = 3,
  19044. /**
  19045. * Google Daydream
  19046. */
  19047. DAYDREAM = 4,
  19048. /**
  19049. * Generic
  19050. */
  19051. GENERIC = 5
  19052. }
  19053. /**
  19054. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19055. */
  19056. export interface MutableGamepadButton {
  19057. /**
  19058. * Value of the button/trigger
  19059. */
  19060. value: number;
  19061. /**
  19062. * If the button/trigger is currently touched
  19063. */
  19064. touched: boolean;
  19065. /**
  19066. * If the button/trigger is currently pressed
  19067. */
  19068. pressed: boolean;
  19069. }
  19070. /**
  19071. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19072. * @hidden
  19073. */
  19074. export interface ExtendedGamepadButton extends GamepadButton {
  19075. /**
  19076. * If the button/trigger is currently pressed
  19077. */
  19078. readonly pressed: boolean;
  19079. /**
  19080. * If the button/trigger is currently touched
  19081. */
  19082. readonly touched: boolean;
  19083. /**
  19084. * Value of the button/trigger
  19085. */
  19086. readonly value: number;
  19087. }
  19088. /** @hidden */
  19089. export interface _GamePadFactory {
  19090. /**
  19091. * Returns whether or not the current gamepad can be created for this type of controller.
  19092. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19093. * @returns true if it can be created, otherwise false
  19094. */
  19095. canCreate(gamepadInfo: any): boolean;
  19096. /**
  19097. * Creates a new instance of the Gamepad.
  19098. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19099. * @returns the new gamepad instance
  19100. */
  19101. create(gamepadInfo: any): Gamepad;
  19102. }
  19103. /**
  19104. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19105. */
  19106. export class PoseEnabledControllerHelper {
  19107. /** @hidden */
  19108. static _ControllerFactories: _GamePadFactory[];
  19109. /** @hidden */
  19110. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19111. /**
  19112. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19113. * @param vrGamepad the gamepad to initialized
  19114. * @returns a vr controller of the type the gamepad identified as
  19115. */
  19116. static InitiateController(vrGamepad: any): Gamepad;
  19117. }
  19118. /**
  19119. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19120. */
  19121. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19122. /**
  19123. * If the controller is used in a webXR session
  19124. */
  19125. isXR: boolean;
  19126. private _deviceRoomPosition;
  19127. private _deviceRoomRotationQuaternion;
  19128. /**
  19129. * The device position in babylon space
  19130. */
  19131. devicePosition: Vector3;
  19132. /**
  19133. * The device rotation in babylon space
  19134. */
  19135. deviceRotationQuaternion: Quaternion;
  19136. /**
  19137. * The scale factor of the device in babylon space
  19138. */
  19139. deviceScaleFactor: number;
  19140. /**
  19141. * (Likely devicePosition should be used instead) The device position in its room space
  19142. */
  19143. position: Vector3;
  19144. /**
  19145. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19146. */
  19147. rotationQuaternion: Quaternion;
  19148. /**
  19149. * The type of controller (Eg. Windows mixed reality)
  19150. */
  19151. controllerType: PoseEnabledControllerType;
  19152. protected _calculatedPosition: Vector3;
  19153. private _calculatedRotation;
  19154. /**
  19155. * The raw pose from the device
  19156. */
  19157. rawPose: DevicePose;
  19158. private _trackPosition;
  19159. private _maxRotationDistFromHeadset;
  19160. private _draggedRoomRotation;
  19161. /**
  19162. * @hidden
  19163. */
  19164. _disableTrackPosition(fixedPosition: Vector3): void;
  19165. /**
  19166. * Internal, the mesh attached to the controller
  19167. * @hidden
  19168. */
  19169. _mesh: Nullable<AbstractMesh>;
  19170. private _poseControlledCamera;
  19171. private _leftHandSystemQuaternion;
  19172. /**
  19173. * Internal, matrix used to convert room space to babylon space
  19174. * @hidden
  19175. */
  19176. _deviceToWorld: Matrix;
  19177. /**
  19178. * Node to be used when casting a ray from the controller
  19179. * @hidden
  19180. */
  19181. _pointingPoseNode: Nullable<TransformNode>;
  19182. /**
  19183. * Name of the child mesh that can be used to cast a ray from the controller
  19184. */
  19185. static readonly POINTING_POSE: string;
  19186. /**
  19187. * Creates a new PoseEnabledController from a gamepad
  19188. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19189. */
  19190. constructor(browserGamepad: any);
  19191. private _workingMatrix;
  19192. /**
  19193. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19194. */
  19195. update(): void;
  19196. /**
  19197. * Updates only the pose device and mesh without doing any button event checking
  19198. */
  19199. protected _updatePoseAndMesh(): void;
  19200. /**
  19201. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19202. * @param poseData raw pose fromthe device
  19203. */
  19204. updateFromDevice(poseData: DevicePose): void;
  19205. /**
  19206. * @hidden
  19207. */
  19208. _meshAttachedObservable: Observable<AbstractMesh>;
  19209. /**
  19210. * Attaches a mesh to the controller
  19211. * @param mesh the mesh to be attached
  19212. */
  19213. attachToMesh(mesh: AbstractMesh): void;
  19214. /**
  19215. * Attaches the controllers mesh to a camera
  19216. * @param camera the camera the mesh should be attached to
  19217. */
  19218. attachToPoseControlledCamera(camera: TargetCamera): void;
  19219. /**
  19220. * Disposes of the controller
  19221. */
  19222. dispose(): void;
  19223. /**
  19224. * The mesh that is attached to the controller
  19225. */
  19226. get mesh(): Nullable<AbstractMesh>;
  19227. /**
  19228. * Gets the ray of the controller in the direction the controller is pointing
  19229. * @param length the length the resulting ray should be
  19230. * @returns a ray in the direction the controller is pointing
  19231. */
  19232. getForwardRay(length?: number): Ray;
  19233. }
  19234. }
  19235. declare module BABYLON {
  19236. /**
  19237. * Defines the WebVRController object that represents controllers tracked in 3D space
  19238. */
  19239. export abstract class WebVRController extends PoseEnabledController {
  19240. /**
  19241. * Internal, the default controller model for the controller
  19242. */
  19243. protected _defaultModel: Nullable<AbstractMesh>;
  19244. /**
  19245. * Fired when the trigger state has changed
  19246. */
  19247. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19248. /**
  19249. * Fired when the main button state has changed
  19250. */
  19251. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19252. /**
  19253. * Fired when the secondary button state has changed
  19254. */
  19255. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19256. /**
  19257. * Fired when the pad state has changed
  19258. */
  19259. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19260. /**
  19261. * Fired when controllers stick values have changed
  19262. */
  19263. onPadValuesChangedObservable: Observable<StickValues>;
  19264. /**
  19265. * Array of button availible on the controller
  19266. */
  19267. protected _buttons: Array<MutableGamepadButton>;
  19268. private _onButtonStateChange;
  19269. /**
  19270. * Fired when a controller button's state has changed
  19271. * @param callback the callback containing the button that was modified
  19272. */
  19273. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19274. /**
  19275. * X and Y axis corresponding to the controllers joystick
  19276. */
  19277. pad: StickValues;
  19278. /**
  19279. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19280. */
  19281. hand: string;
  19282. /**
  19283. * The default controller model for the controller
  19284. */
  19285. get defaultModel(): Nullable<AbstractMesh>;
  19286. /**
  19287. * Creates a new WebVRController from a gamepad
  19288. * @param vrGamepad the gamepad that the WebVRController should be created from
  19289. */
  19290. constructor(vrGamepad: any);
  19291. /**
  19292. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19293. */
  19294. update(): void;
  19295. /**
  19296. * Function to be called when a button is modified
  19297. */
  19298. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19299. /**
  19300. * Loads a mesh and attaches it to the controller
  19301. * @param scene the scene the mesh should be added to
  19302. * @param meshLoaded callback for when the mesh has been loaded
  19303. */
  19304. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19305. private _setButtonValue;
  19306. private _changes;
  19307. private _checkChanges;
  19308. /**
  19309. * Disposes of th webVRCOntroller
  19310. */
  19311. dispose(): void;
  19312. }
  19313. }
  19314. declare module BABYLON {
  19315. /**
  19316. * The HemisphericLight simulates the ambient environment light,
  19317. * so the passed direction is the light reflection direction, not the incoming direction.
  19318. */
  19319. export class HemisphericLight extends Light {
  19320. /**
  19321. * The groundColor is the light in the opposite direction to the one specified during creation.
  19322. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  19323. */
  19324. groundColor: Color3;
  19325. /**
  19326. * The light reflection direction, not the incoming direction.
  19327. */
  19328. direction: Vector3;
  19329. /**
  19330. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19331. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19332. * The HemisphericLight can't cast shadows.
  19333. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19334. * @param name The friendly name of the light
  19335. * @param direction The direction of the light reflection
  19336. * @param scene The scene the light belongs to
  19337. */
  19338. constructor(name: string, direction: Vector3, scene: Scene);
  19339. protected _buildUniformLayout(): void;
  19340. /**
  19341. * Returns the string "HemisphericLight".
  19342. * @return The class name
  19343. */
  19344. getClassName(): string;
  19345. /**
  19346. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19347. * Returns the updated direction.
  19348. * @param target The target the direction should point to
  19349. * @return The computed direction
  19350. */
  19351. setDirectionToTarget(target: Vector3): Vector3;
  19352. /**
  19353. * Returns the shadow generator associated to the light.
  19354. * @returns Always null for hemispheric lights because it does not support shadows.
  19355. */
  19356. getShadowGenerator(): Nullable<IShadowGenerator>;
  19357. /**
  19358. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19359. * @param effect The effect to update
  19360. * @param lightIndex The index of the light in the effect to update
  19361. * @returns The hemispheric light
  19362. */
  19363. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19364. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19365. /**
  19366. * Computes the world matrix of the node
  19367. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19368. * @param useWasUpdatedFlag defines a reserved property
  19369. * @returns the world matrix
  19370. */
  19371. computeWorldMatrix(): Matrix;
  19372. /**
  19373. * Returns the integer 3.
  19374. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19375. */
  19376. getTypeID(): number;
  19377. /**
  19378. * Prepares the list of defines specific to the light type.
  19379. * @param defines the list of defines
  19380. * @param lightIndex defines the index of the light for the effect
  19381. */
  19382. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19383. }
  19384. }
  19385. declare module BABYLON {
  19386. /** @hidden */
  19387. export var vrMultiviewToSingleviewPixelShader: {
  19388. name: string;
  19389. shader: string;
  19390. };
  19391. }
  19392. declare module BABYLON {
  19393. /**
  19394. * Renders to multiple views with a single draw call
  19395. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19396. */
  19397. export class MultiviewRenderTarget extends RenderTargetTexture {
  19398. /**
  19399. * Creates a multiview render target
  19400. * @param scene scene used with the render target
  19401. * @param size the size of the render target (used for each view)
  19402. */
  19403. constructor(scene: Scene, size?: number | {
  19404. width: number;
  19405. height: number;
  19406. } | {
  19407. ratio: number;
  19408. });
  19409. /**
  19410. * @hidden
  19411. * @param faceIndex the face index, if its a cube texture
  19412. */
  19413. _bindFrameBuffer(faceIndex?: number): void;
  19414. /**
  19415. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19416. * @returns the view count
  19417. */
  19418. getViewCount(): number;
  19419. }
  19420. }
  19421. declare module BABYLON {
  19422. interface Engine {
  19423. /**
  19424. * Creates a new multiview render target
  19425. * @param width defines the width of the texture
  19426. * @param height defines the height of the texture
  19427. * @returns the created multiview texture
  19428. */
  19429. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19430. /**
  19431. * Binds a multiview framebuffer to be drawn to
  19432. * @param multiviewTexture texture to bind
  19433. */
  19434. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19435. }
  19436. interface Camera {
  19437. /**
  19438. * @hidden
  19439. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19440. */
  19441. _useMultiviewToSingleView: boolean;
  19442. /**
  19443. * @hidden
  19444. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19445. */
  19446. _multiviewTexture: Nullable<RenderTargetTexture>;
  19447. /**
  19448. * @hidden
  19449. * ensures the multiview texture of the camera exists and has the specified width/height
  19450. * @param width height to set on the multiview texture
  19451. * @param height width to set on the multiview texture
  19452. */
  19453. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19454. }
  19455. interface Scene {
  19456. /** @hidden */
  19457. _transformMatrixR: Matrix;
  19458. /** @hidden */
  19459. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19460. /** @hidden */
  19461. _createMultiviewUbo(): void;
  19462. /** @hidden */
  19463. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19464. /** @hidden */
  19465. _renderMultiviewToSingleView(camera: Camera): void;
  19466. }
  19467. }
  19468. declare module BABYLON {
  19469. /**
  19470. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19471. * This will not be used for webXR as it supports displaying texture arrays directly
  19472. */
  19473. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19474. /**
  19475. * Initializes a VRMultiviewToSingleview
  19476. * @param name name of the post process
  19477. * @param camera camera to be applied to
  19478. * @param scaleFactor scaling factor to the size of the output texture
  19479. */
  19480. constructor(name: string, camera: Camera, scaleFactor: number);
  19481. }
  19482. }
  19483. declare module BABYLON {
  19484. /**
  19485. * Interface used to define additional presentation attributes
  19486. */
  19487. export interface IVRPresentationAttributes {
  19488. /**
  19489. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19490. */
  19491. highRefreshRate: boolean;
  19492. /**
  19493. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19494. */
  19495. foveationLevel: number;
  19496. }
  19497. interface Engine {
  19498. /** @hidden */
  19499. _vrDisplay: any;
  19500. /** @hidden */
  19501. _vrSupported: boolean;
  19502. /** @hidden */
  19503. _oldSize: Size;
  19504. /** @hidden */
  19505. _oldHardwareScaleFactor: number;
  19506. /** @hidden */
  19507. _vrExclusivePointerMode: boolean;
  19508. /** @hidden */
  19509. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19510. /** @hidden */
  19511. _onVRDisplayPointerRestricted: () => void;
  19512. /** @hidden */
  19513. _onVRDisplayPointerUnrestricted: () => void;
  19514. /** @hidden */
  19515. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19516. /** @hidden */
  19517. _onVrDisplayDisconnect: Nullable<() => void>;
  19518. /** @hidden */
  19519. _onVrDisplayPresentChange: Nullable<() => void>;
  19520. /**
  19521. * Observable signaled when VR display mode changes
  19522. */
  19523. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19524. /**
  19525. * Observable signaled when VR request present is complete
  19526. */
  19527. onVRRequestPresentComplete: Observable<boolean>;
  19528. /**
  19529. * Observable signaled when VR request present starts
  19530. */
  19531. onVRRequestPresentStart: Observable<Engine>;
  19532. /**
  19533. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19534. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19535. */
  19536. isInVRExclusivePointerMode: boolean;
  19537. /**
  19538. * Gets a boolean indicating if a webVR device was detected
  19539. * @returns true if a webVR device was detected
  19540. */
  19541. isVRDevicePresent(): boolean;
  19542. /**
  19543. * Gets the current webVR device
  19544. * @returns the current webVR device (or null)
  19545. */
  19546. getVRDevice(): any;
  19547. /**
  19548. * Initializes a webVR display and starts listening to display change events
  19549. * The onVRDisplayChangedObservable will be notified upon these changes
  19550. * @returns A promise containing a VRDisplay and if vr is supported
  19551. */
  19552. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19553. /** @hidden */
  19554. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19555. /**
  19556. * Gets or sets the presentation attributes used to configure VR rendering
  19557. */
  19558. vrPresentationAttributes?: IVRPresentationAttributes;
  19559. /**
  19560. * Call this function to switch to webVR mode
  19561. * Will do nothing if webVR is not supported or if there is no webVR device
  19562. * @param options the webvr options provided to the camera. mainly used for multiview
  19563. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19564. */
  19565. enableVR(options: WebVROptions): void;
  19566. /** @hidden */
  19567. _onVRFullScreenTriggered(): void;
  19568. }
  19569. }
  19570. declare module BABYLON {
  19571. /**
  19572. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19573. * IMPORTANT!! The data is right-hand data.
  19574. * @export
  19575. * @interface DevicePose
  19576. */
  19577. export interface DevicePose {
  19578. /**
  19579. * The position of the device, values in array are [x,y,z].
  19580. */
  19581. readonly position: Nullable<Float32Array>;
  19582. /**
  19583. * The linearVelocity of the device, values in array are [x,y,z].
  19584. */
  19585. readonly linearVelocity: Nullable<Float32Array>;
  19586. /**
  19587. * The linearAcceleration of the device, values in array are [x,y,z].
  19588. */
  19589. readonly linearAcceleration: Nullable<Float32Array>;
  19590. /**
  19591. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19592. */
  19593. readonly orientation: Nullable<Float32Array>;
  19594. /**
  19595. * The angularVelocity of the device, values in array are [x,y,z].
  19596. */
  19597. readonly angularVelocity: Nullable<Float32Array>;
  19598. /**
  19599. * The angularAcceleration of the device, values in array are [x,y,z].
  19600. */
  19601. readonly angularAcceleration: Nullable<Float32Array>;
  19602. }
  19603. /**
  19604. * Interface representing a pose controlled object in Babylon.
  19605. * A pose controlled object has both regular pose values as well as pose values
  19606. * from an external device such as a VR head mounted display
  19607. */
  19608. export interface PoseControlled {
  19609. /**
  19610. * The position of the object in babylon space.
  19611. */
  19612. position: Vector3;
  19613. /**
  19614. * The rotation quaternion of the object in babylon space.
  19615. */
  19616. rotationQuaternion: Quaternion;
  19617. /**
  19618. * The position of the device in babylon space.
  19619. */
  19620. devicePosition?: Vector3;
  19621. /**
  19622. * The rotation quaternion of the device in babylon space.
  19623. */
  19624. deviceRotationQuaternion: Quaternion;
  19625. /**
  19626. * The raw pose coming from the device.
  19627. */
  19628. rawPose: Nullable<DevicePose>;
  19629. /**
  19630. * The scale of the device to be used when translating from device space to babylon space.
  19631. */
  19632. deviceScaleFactor: number;
  19633. /**
  19634. * Updates the poseControlled values based on the input device pose.
  19635. * @param poseData the pose data to update the object with
  19636. */
  19637. updateFromDevice(poseData: DevicePose): void;
  19638. }
  19639. /**
  19640. * Set of options to customize the webVRCamera
  19641. */
  19642. export interface WebVROptions {
  19643. /**
  19644. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19645. */
  19646. trackPosition?: boolean;
  19647. /**
  19648. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19649. */
  19650. positionScale?: number;
  19651. /**
  19652. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19653. */
  19654. displayName?: string;
  19655. /**
  19656. * Should the native controller meshes be initialized. (default: true)
  19657. */
  19658. controllerMeshes?: boolean;
  19659. /**
  19660. * Creating a default HemiLight only on controllers. (default: true)
  19661. */
  19662. defaultLightingOnControllers?: boolean;
  19663. /**
  19664. * If you don't want to use the default VR button of the helper. (default: false)
  19665. */
  19666. useCustomVRButton?: boolean;
  19667. /**
  19668. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19669. */
  19670. customVRButton?: HTMLButtonElement;
  19671. /**
  19672. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19673. */
  19674. rayLength?: number;
  19675. /**
  19676. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19677. */
  19678. defaultHeight?: number;
  19679. /**
  19680. * If multiview should be used if availible (default: false)
  19681. */
  19682. useMultiview?: boolean;
  19683. }
  19684. /**
  19685. * This represents a WebVR camera.
  19686. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19687. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19688. */
  19689. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19690. private webVROptions;
  19691. /**
  19692. * @hidden
  19693. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19694. */
  19695. _vrDevice: any;
  19696. /**
  19697. * The rawPose of the vrDevice.
  19698. */
  19699. rawPose: Nullable<DevicePose>;
  19700. private _onVREnabled;
  19701. private _specsVersion;
  19702. private _attached;
  19703. private _frameData;
  19704. protected _descendants: Array<Node>;
  19705. private _deviceRoomPosition;
  19706. /** @hidden */
  19707. _deviceRoomRotationQuaternion: Quaternion;
  19708. private _standingMatrix;
  19709. /**
  19710. * Represents device position in babylon space.
  19711. */
  19712. devicePosition: Vector3;
  19713. /**
  19714. * Represents device rotation in babylon space.
  19715. */
  19716. deviceRotationQuaternion: Quaternion;
  19717. /**
  19718. * The scale of the device to be used when translating from device space to babylon space.
  19719. */
  19720. deviceScaleFactor: number;
  19721. private _deviceToWorld;
  19722. private _worldToDevice;
  19723. /**
  19724. * References to the webVR controllers for the vrDevice.
  19725. */
  19726. controllers: Array<WebVRController>;
  19727. /**
  19728. * Emits an event when a controller is attached.
  19729. */
  19730. onControllersAttachedObservable: Observable<WebVRController[]>;
  19731. /**
  19732. * Emits an event when a controller's mesh has been loaded;
  19733. */
  19734. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19735. /**
  19736. * Emits an event when the HMD's pose has been updated.
  19737. */
  19738. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19739. private _poseSet;
  19740. /**
  19741. * If the rig cameras be used as parent instead of this camera.
  19742. */
  19743. rigParenting: boolean;
  19744. private _lightOnControllers;
  19745. private _defaultHeight?;
  19746. /**
  19747. * Instantiates a WebVRFreeCamera.
  19748. * @param name The name of the WebVRFreeCamera
  19749. * @param position The starting anchor position for the camera
  19750. * @param scene The scene the camera belongs to
  19751. * @param webVROptions a set of customizable options for the webVRCamera
  19752. */
  19753. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19754. /**
  19755. * Gets the device distance from the ground in meters.
  19756. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  19757. */
  19758. deviceDistanceToRoomGround(): number;
  19759. /**
  19760. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19761. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19762. */
  19763. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19764. /**
  19765. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19766. * @returns A promise with a boolean set to if the standing matrix is supported.
  19767. */
  19768. useStandingMatrixAsync(): Promise<boolean>;
  19769. /**
  19770. * Disposes the camera
  19771. */
  19772. dispose(): void;
  19773. /**
  19774. * Gets a vrController by name.
  19775. * @param name The name of the controller to retreive
  19776. * @returns the controller matching the name specified or null if not found
  19777. */
  19778. getControllerByName(name: string): Nullable<WebVRController>;
  19779. private _leftController;
  19780. /**
  19781. * The controller corresponding to the users left hand.
  19782. */
  19783. get leftController(): Nullable<WebVRController>;
  19784. private _rightController;
  19785. /**
  19786. * The controller corresponding to the users right hand.
  19787. */
  19788. get rightController(): Nullable<WebVRController>;
  19789. /**
  19790. * Casts a ray forward from the vrCamera's gaze.
  19791. * @param length Length of the ray (default: 100)
  19792. * @returns the ray corresponding to the gaze
  19793. */
  19794. getForwardRay(length?: number): Ray;
  19795. /**
  19796. * @hidden
  19797. * Updates the camera based on device's frame data
  19798. */
  19799. _checkInputs(): void;
  19800. /**
  19801. * Updates the poseControlled values based on the input device pose.
  19802. * @param poseData Pose coming from the device
  19803. */
  19804. updateFromDevice(poseData: DevicePose): void;
  19805. private _htmlElementAttached;
  19806. private _detachIfAttached;
  19807. /**
  19808. * WebVR's attach control will start broadcasting frames to the device.
  19809. * Note that in certain browsers (chrome for example) this function must be called
  19810. * within a user-interaction callback. Example:
  19811. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19812. *
  19813. * @param element html element to attach the vrDevice to
  19814. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19815. */
  19816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19817. /**
  19818. * Detaches the camera from the html element and disables VR
  19819. *
  19820. * @param element html element to detach from
  19821. */
  19822. detachControl(element: HTMLElement): void;
  19823. /**
  19824. * @returns the name of this class
  19825. */
  19826. getClassName(): string;
  19827. /**
  19828. * Calls resetPose on the vrDisplay
  19829. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19830. */
  19831. resetToCurrentRotation(): void;
  19832. /**
  19833. * @hidden
  19834. * Updates the rig cameras (left and right eye)
  19835. */
  19836. _updateRigCameras(): void;
  19837. private _workingVector;
  19838. private _oneVector;
  19839. private _workingMatrix;
  19840. private updateCacheCalled;
  19841. private _correctPositionIfNotTrackPosition;
  19842. /**
  19843. * @hidden
  19844. * Updates the cached values of the camera
  19845. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19846. */
  19847. _updateCache(ignoreParentClass?: boolean): void;
  19848. /**
  19849. * @hidden
  19850. * Get current device position in babylon world
  19851. */
  19852. _computeDevicePosition(): void;
  19853. /**
  19854. * Updates the current device position and rotation in the babylon world
  19855. */
  19856. update(): void;
  19857. /**
  19858. * @hidden
  19859. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19860. * @returns an identity matrix
  19861. */
  19862. _getViewMatrix(): Matrix;
  19863. private _tmpMatrix;
  19864. /**
  19865. * This function is called by the two RIG cameras.
  19866. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19867. * @hidden
  19868. */
  19869. _getWebVRViewMatrix(): Matrix;
  19870. /** @hidden */
  19871. _getWebVRProjectionMatrix(): Matrix;
  19872. private _onGamepadConnectedObserver;
  19873. private _onGamepadDisconnectedObserver;
  19874. private _updateCacheWhenTrackingDisabledObserver;
  19875. /**
  19876. * Initializes the controllers and their meshes
  19877. */
  19878. initControllers(): void;
  19879. }
  19880. }
  19881. declare module BABYLON {
  19882. /**
  19883. * "Static Class" containing the most commonly used helper while dealing with material for
  19884. * rendering purpose.
  19885. *
  19886. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19887. *
  19888. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19889. */
  19890. export class MaterialHelper {
  19891. /**
  19892. * Bind the current view position to an effect.
  19893. * @param effect The effect to be bound
  19894. * @param scene The scene the eyes position is used from
  19895. * @param variableName name of the shader variable that will hold the eye position
  19896. */
  19897. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19898. /**
  19899. * Helps preparing the defines values about the UVs in used in the effect.
  19900. * UVs are shared as much as we can accross channels in the shaders.
  19901. * @param texture The texture we are preparing the UVs for
  19902. * @param defines The defines to update
  19903. * @param key The channel key "diffuse", "specular"... used in the shader
  19904. */
  19905. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19906. /**
  19907. * Binds a texture matrix value to its corrsponding uniform
  19908. * @param texture The texture to bind the matrix for
  19909. * @param uniformBuffer The uniform buffer receivin the data
  19910. * @param key The channel key "diffuse", "specular"... used in the shader
  19911. */
  19912. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19913. /**
  19914. * Gets the current status of the fog (should it be enabled?)
  19915. * @param mesh defines the mesh to evaluate for fog support
  19916. * @param scene defines the hosting scene
  19917. * @returns true if fog must be enabled
  19918. */
  19919. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19920. /**
  19921. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19922. * @param mesh defines the current mesh
  19923. * @param scene defines the current scene
  19924. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19925. * @param pointsCloud defines if point cloud rendering has to be turned on
  19926. * @param fogEnabled defines if fog has to be turned on
  19927. * @param alphaTest defines if alpha testing has to be turned on
  19928. * @param defines defines the current list of defines
  19929. */
  19930. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19931. /**
  19932. * Helper used to prepare the list of defines associated with frame values for shader compilation
  19933. * @param scene defines the current scene
  19934. * @param engine defines the current engine
  19935. * @param defines specifies the list of active defines
  19936. * @param useInstances defines if instances have to be turned on
  19937. * @param useClipPlane defines if clip plane have to be turned on
  19938. * @param useInstances defines if instances have to be turned on
  19939. * @param useThinInstances defines if thin instances have to be turned on
  19940. */
  19941. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  19942. /**
  19943. * Prepares the defines for bones
  19944. * @param mesh The mesh containing the geometry data we will draw
  19945. * @param defines The defines to update
  19946. */
  19947. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  19948. /**
  19949. * Prepares the defines for morph targets
  19950. * @param mesh The mesh containing the geometry data we will draw
  19951. * @param defines The defines to update
  19952. */
  19953. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  19954. /**
  19955. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  19956. * @param mesh The mesh containing the geometry data we will draw
  19957. * @param defines The defines to update
  19958. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  19959. * @param useBones Precise whether bones should be used or not (override mesh info)
  19960. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  19961. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  19962. * @returns false if defines are considered not dirty and have not been checked
  19963. */
  19964. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  19965. /**
  19966. * Prepares the defines related to multiview
  19967. * @param scene The scene we are intending to draw
  19968. * @param defines The defines to update
  19969. */
  19970. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  19971. /**
  19972. * Prepares the defines related to the light information passed in parameter
  19973. * @param scene The scene we are intending to draw
  19974. * @param mesh The mesh the effect is compiling for
  19975. * @param light The light the effect is compiling for
  19976. * @param lightIndex The index of the light
  19977. * @param defines The defines to update
  19978. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  19979. * @param state Defines the current state regarding what is needed (normals, etc...)
  19980. */
  19981. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  19982. needNormals: boolean;
  19983. needRebuild: boolean;
  19984. shadowEnabled: boolean;
  19985. specularEnabled: boolean;
  19986. lightmapMode: boolean;
  19987. }): void;
  19988. /**
  19989. * Prepares the defines related to the light information passed in parameter
  19990. * @param scene The scene we are intending to draw
  19991. * @param mesh The mesh the effect is compiling for
  19992. * @param defines The defines to update
  19993. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  19994. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  19995. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  19996. * @returns true if normals will be required for the rest of the effect
  19997. */
  19998. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  19999. /**
  20000. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20001. * @param lightIndex defines the light index
  20002. * @param uniformsList The uniform list
  20003. * @param samplersList The sampler list
  20004. * @param projectedLightTexture defines if projected texture must be used
  20005. * @param uniformBuffersList defines an optional list of uniform buffers
  20006. */
  20007. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20008. /**
  20009. * Prepares the uniforms and samplers list to be used in the effect
  20010. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20011. * @param samplersList The sampler list
  20012. * @param defines The defines helping in the list generation
  20013. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20014. */
  20015. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20016. /**
  20017. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20018. * @param defines The defines to update while falling back
  20019. * @param fallbacks The authorized effect fallbacks
  20020. * @param maxSimultaneousLights The maximum number of lights allowed
  20021. * @param rank the current rank of the Effect
  20022. * @returns The newly affected rank
  20023. */
  20024. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20025. private static _TmpMorphInfluencers;
  20026. /**
  20027. * Prepares the list of attributes required for morph targets according to the effect defines.
  20028. * @param attribs The current list of supported attribs
  20029. * @param mesh The mesh to prepare the morph targets attributes for
  20030. * @param influencers The number of influencers
  20031. */
  20032. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20033. /**
  20034. * Prepares the list of attributes required for morph targets according to the effect defines.
  20035. * @param attribs The current list of supported attribs
  20036. * @param mesh The mesh to prepare the morph targets attributes for
  20037. * @param defines The current Defines of the effect
  20038. */
  20039. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20040. /**
  20041. * Prepares the list of attributes required for bones according to the effect defines.
  20042. * @param attribs The current list of supported attribs
  20043. * @param mesh The mesh to prepare the bones attributes for
  20044. * @param defines The current Defines of the effect
  20045. * @param fallbacks The current efffect fallback strategy
  20046. */
  20047. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20048. /**
  20049. * Check and prepare the list of attributes required for instances according to the effect defines.
  20050. * @param attribs The current list of supported attribs
  20051. * @param defines The current MaterialDefines of the effect
  20052. */
  20053. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20054. /**
  20055. * Add the list of attributes required for instances to the attribs array.
  20056. * @param attribs The current list of supported attribs
  20057. */
  20058. static PushAttributesForInstances(attribs: string[]): void;
  20059. /**
  20060. * Binds the light information to the effect.
  20061. * @param light The light containing the generator
  20062. * @param effect The effect we are binding the data to
  20063. * @param lightIndex The light index in the effect used to render
  20064. */
  20065. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20066. /**
  20067. * Binds the lights information from the scene to the effect for the given mesh.
  20068. * @param light Light to bind
  20069. * @param lightIndex Light index
  20070. * @param scene The scene where the light belongs to
  20071. * @param effect The effect we are binding the data to
  20072. * @param useSpecular Defines if specular is supported
  20073. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20074. */
  20075. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20076. /**
  20077. * Binds the lights information from the scene to the effect for the given mesh.
  20078. * @param scene The scene the lights belongs to
  20079. * @param mesh The mesh we are binding the information to render
  20080. * @param effect The effect we are binding the data to
  20081. * @param defines The generated defines for the effect
  20082. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20083. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20084. */
  20085. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20086. private static _tempFogColor;
  20087. /**
  20088. * Binds the fog information from the scene to the effect for the given mesh.
  20089. * @param scene The scene the lights belongs to
  20090. * @param mesh The mesh we are binding the information to render
  20091. * @param effect The effect we are binding the data to
  20092. * @param linearSpace Defines if the fog effect is applied in linear space
  20093. */
  20094. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20095. /**
  20096. * Binds the bones information from the mesh to the effect.
  20097. * @param mesh The mesh we are binding the information to render
  20098. * @param effect The effect we are binding the data to
  20099. */
  20100. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20101. /**
  20102. * Binds the morph targets information from the mesh to the effect.
  20103. * @param abstractMesh The mesh we are binding the information to render
  20104. * @param effect The effect we are binding the data to
  20105. */
  20106. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20107. /**
  20108. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20109. * @param defines The generated defines used in the effect
  20110. * @param effect The effect we are binding the data to
  20111. * @param scene The scene we are willing to render with logarithmic scale for
  20112. */
  20113. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20114. /**
  20115. * Binds the clip plane information from the scene to the effect.
  20116. * @param scene The scene the clip plane information are extracted from
  20117. * @param effect The effect we are binding the data to
  20118. */
  20119. static BindClipPlane(effect: Effect, scene: Scene): void;
  20120. }
  20121. }
  20122. declare module BABYLON {
  20123. /**
  20124. * Block used to expose an input value
  20125. */
  20126. export class InputBlock extends NodeMaterialBlock {
  20127. private _mode;
  20128. private _associatedVariableName;
  20129. private _storedValue;
  20130. private _valueCallback;
  20131. private _type;
  20132. private _animationType;
  20133. /** Gets or set a value used to limit the range of float values */
  20134. min: number;
  20135. /** Gets or set a value used to limit the range of float values */
  20136. max: number;
  20137. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20138. isBoolean: boolean;
  20139. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20140. matrixMode: number;
  20141. /** @hidden */
  20142. _systemValue: Nullable<NodeMaterialSystemValues>;
  20143. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20144. visibleInInspector: boolean;
  20145. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20146. isConstant: boolean;
  20147. /** Gets or sets the group to use to display this block in the Inspector */
  20148. groupInInspector: string;
  20149. /** Gets an observable raised when the value is changed */
  20150. onValueChangedObservable: Observable<InputBlock>;
  20151. /**
  20152. * Gets or sets the connection point type (default is float)
  20153. */
  20154. get type(): NodeMaterialBlockConnectionPointTypes;
  20155. /**
  20156. * Creates a new InputBlock
  20157. * @param name defines the block name
  20158. * @param target defines the target of that block (Vertex by default)
  20159. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20160. */
  20161. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20162. /**
  20163. * Gets the output component
  20164. */
  20165. get output(): NodeMaterialConnectionPoint;
  20166. /**
  20167. * Set the source of this connection point to a vertex attribute
  20168. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20169. * @returns the current connection point
  20170. */
  20171. setAsAttribute(attributeName?: string): InputBlock;
  20172. /**
  20173. * Set the source of this connection point to a system value
  20174. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20175. * @returns the current connection point
  20176. */
  20177. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20178. /**
  20179. * Gets or sets the value of that point.
  20180. * Please note that this value will be ignored if valueCallback is defined
  20181. */
  20182. get value(): any;
  20183. set value(value: any);
  20184. /**
  20185. * Gets or sets a callback used to get the value of that point.
  20186. * Please note that setting this value will force the connection point to ignore the value property
  20187. */
  20188. get valueCallback(): () => any;
  20189. set valueCallback(value: () => any);
  20190. /**
  20191. * Gets or sets the associated variable name in the shader
  20192. */
  20193. get associatedVariableName(): string;
  20194. set associatedVariableName(value: string);
  20195. /** Gets or sets the type of animation applied to the input */
  20196. get animationType(): AnimatedInputBlockTypes;
  20197. set animationType(value: AnimatedInputBlockTypes);
  20198. /**
  20199. * Gets a boolean indicating that this connection point not defined yet
  20200. */
  20201. get isUndefined(): boolean;
  20202. /**
  20203. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20204. * In this case the connection point name must be the name of the uniform to use.
  20205. * Can only be set on inputs
  20206. */
  20207. get isUniform(): boolean;
  20208. set isUniform(value: boolean);
  20209. /**
  20210. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20211. * In this case the connection point name must be the name of the attribute to use
  20212. * Can only be set on inputs
  20213. */
  20214. get isAttribute(): boolean;
  20215. set isAttribute(value: boolean);
  20216. /**
  20217. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20218. * Can only be set on exit points
  20219. */
  20220. get isVarying(): boolean;
  20221. set isVarying(value: boolean);
  20222. /**
  20223. * Gets a boolean indicating that the current connection point is a system value
  20224. */
  20225. get isSystemValue(): boolean;
  20226. /**
  20227. * Gets or sets the current well known value or null if not defined as a system value
  20228. */
  20229. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20230. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20231. /**
  20232. * Gets the current class name
  20233. * @returns the class name
  20234. */
  20235. getClassName(): string;
  20236. /**
  20237. * Animate the input if animationType !== None
  20238. * @param scene defines the rendering scene
  20239. */
  20240. animate(scene: Scene): void;
  20241. private _emitDefine;
  20242. initialize(state: NodeMaterialBuildState): void;
  20243. /**
  20244. * Set the input block to its default value (based on its type)
  20245. */
  20246. setDefaultValue(): void;
  20247. private _emitConstant;
  20248. /** @hidden */
  20249. get _noContextSwitch(): boolean;
  20250. private _emit;
  20251. /** @hidden */
  20252. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20253. /** @hidden */
  20254. _transmit(effect: Effect, scene: Scene): void;
  20255. protected _buildBlock(state: NodeMaterialBuildState): void;
  20256. protected _dumpPropertiesCode(): string;
  20257. dispose(): void;
  20258. serialize(): any;
  20259. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20260. }
  20261. }
  20262. declare module BABYLON {
  20263. /**
  20264. * Enum used to define the compatibility state between two connection points
  20265. */
  20266. export enum NodeMaterialConnectionPointCompatibilityStates {
  20267. /** Points are compatibles */
  20268. Compatible = 0,
  20269. /** Points are incompatible because of their types */
  20270. TypeIncompatible = 1,
  20271. /** Points are incompatible because of their targets (vertex vs fragment) */
  20272. TargetIncompatible = 2
  20273. }
  20274. /**
  20275. * Defines the direction of a connection point
  20276. */
  20277. export enum NodeMaterialConnectionPointDirection {
  20278. /** Input */
  20279. Input = 0,
  20280. /** Output */
  20281. Output = 1
  20282. }
  20283. /**
  20284. * Defines a connection point for a block
  20285. */
  20286. export class NodeMaterialConnectionPoint {
  20287. /** @hidden */
  20288. _ownerBlock: NodeMaterialBlock;
  20289. /** @hidden */
  20290. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20291. private _endpoints;
  20292. private _associatedVariableName;
  20293. private _direction;
  20294. /** @hidden */
  20295. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20296. /** @hidden */
  20297. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20298. private _type;
  20299. /** @hidden */
  20300. _enforceAssociatedVariableName: boolean;
  20301. /** Gets the direction of the point */
  20302. get direction(): NodeMaterialConnectionPointDirection;
  20303. /** Indicates that this connection point needs dual validation before being connected to another point */
  20304. needDualDirectionValidation: boolean;
  20305. /**
  20306. * Gets or sets the additional types supported by this connection point
  20307. */
  20308. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20309. /**
  20310. * Gets or sets the additional types excluded by this connection point
  20311. */
  20312. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20313. /**
  20314. * Observable triggered when this point is connected
  20315. */
  20316. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20317. /**
  20318. * Gets or sets the associated variable name in the shader
  20319. */
  20320. get associatedVariableName(): string;
  20321. set associatedVariableName(value: string);
  20322. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20323. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20324. /**
  20325. * Gets or sets the connection point type (default is float)
  20326. */
  20327. get type(): NodeMaterialBlockConnectionPointTypes;
  20328. set type(value: NodeMaterialBlockConnectionPointTypes);
  20329. /**
  20330. * Gets or sets the connection point name
  20331. */
  20332. name: string;
  20333. /**
  20334. * Gets or sets the connection point name
  20335. */
  20336. displayName: string;
  20337. /**
  20338. * Gets or sets a boolean indicating that this connection point can be omitted
  20339. */
  20340. isOptional: boolean;
  20341. /**
  20342. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20343. */
  20344. isExposedOnFrame: boolean;
  20345. /**
  20346. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20347. */
  20348. define: string;
  20349. /** @hidden */
  20350. _prioritizeVertex: boolean;
  20351. private _target;
  20352. /** Gets or sets the target of that connection point */
  20353. get target(): NodeMaterialBlockTargets;
  20354. set target(value: NodeMaterialBlockTargets);
  20355. /**
  20356. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20357. */
  20358. get isConnected(): boolean;
  20359. /**
  20360. * Gets a boolean indicating that the current point is connected to an input block
  20361. */
  20362. get isConnectedToInputBlock(): boolean;
  20363. /**
  20364. * Gets a the connected input block (if any)
  20365. */
  20366. get connectInputBlock(): Nullable<InputBlock>;
  20367. /** Get the other side of the connection (if any) */
  20368. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20369. /** Get the block that owns this connection point */
  20370. get ownerBlock(): NodeMaterialBlock;
  20371. /** Get the block connected on the other side of this connection (if any) */
  20372. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20373. /** Get the block connected on the endpoints of this connection (if any) */
  20374. get connectedBlocks(): Array<NodeMaterialBlock>;
  20375. /** Gets the list of connected endpoints */
  20376. get endpoints(): NodeMaterialConnectionPoint[];
  20377. /** Gets a boolean indicating if that output point is connected to at least one input */
  20378. get hasEndpoints(): boolean;
  20379. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20380. get isConnectedInVertexShader(): boolean;
  20381. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20382. get isConnectedInFragmentShader(): boolean;
  20383. /**
  20384. * Creates a block suitable to be used as an input for this input point.
  20385. * If null is returned, a block based on the point type will be created.
  20386. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20387. */
  20388. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20389. /**
  20390. * Creates a new connection point
  20391. * @param name defines the connection point name
  20392. * @param ownerBlock defines the block hosting this connection point
  20393. * @param direction defines the direction of the connection point
  20394. */
  20395. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20396. /**
  20397. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20398. * @returns the class name
  20399. */
  20400. getClassName(): string;
  20401. /**
  20402. * Gets a boolean indicating if the current point can be connected to another point
  20403. * @param connectionPoint defines the other connection point
  20404. * @returns a boolean
  20405. */
  20406. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20407. /**
  20408. * Gets a number indicating if the current point can be connected to another point
  20409. * @param connectionPoint defines the other connection point
  20410. * @returns a number defining the compatibility state
  20411. */
  20412. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20413. /**
  20414. * Connect this point to another connection point
  20415. * @param connectionPoint defines the other connection point
  20416. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20417. * @returns the current connection point
  20418. */
  20419. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20420. /**
  20421. * Disconnect this point from one of his endpoint
  20422. * @param endpoint defines the other connection point
  20423. * @returns the current connection point
  20424. */
  20425. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20426. /**
  20427. * Serializes this point in a JSON representation
  20428. * @param isInput defines if the connection point is an input (default is true)
  20429. * @returns the serialized point object
  20430. */
  20431. serialize(isInput?: boolean): any;
  20432. /**
  20433. * Release resources
  20434. */
  20435. dispose(): void;
  20436. }
  20437. }
  20438. declare module BABYLON {
  20439. /**
  20440. * Enum used to define the material modes
  20441. */
  20442. export enum NodeMaterialModes {
  20443. /** Regular material */
  20444. Material = 0,
  20445. /** For post process */
  20446. PostProcess = 1,
  20447. /** For particle system */
  20448. Particle = 2
  20449. }
  20450. }
  20451. declare module BABYLON {
  20452. /**
  20453. * Block used to read a texture from a sampler
  20454. */
  20455. export class TextureBlock extends NodeMaterialBlock {
  20456. private _defineName;
  20457. private _linearDefineName;
  20458. private _gammaDefineName;
  20459. private _tempTextureRead;
  20460. private _samplerName;
  20461. private _transformedUVName;
  20462. private _textureTransformName;
  20463. private _textureInfoName;
  20464. private _mainUVName;
  20465. private _mainUVDefineName;
  20466. private _fragmentOnly;
  20467. /**
  20468. * Gets or sets the texture associated with the node
  20469. */
  20470. texture: Nullable<Texture>;
  20471. /**
  20472. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20473. */
  20474. convertToGammaSpace: boolean;
  20475. /**
  20476. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20477. */
  20478. convertToLinearSpace: boolean;
  20479. /**
  20480. * Create a new TextureBlock
  20481. * @param name defines the block name
  20482. */
  20483. constructor(name: string, fragmentOnly?: boolean);
  20484. /**
  20485. * Gets the current class name
  20486. * @returns the class name
  20487. */
  20488. getClassName(): string;
  20489. /**
  20490. * Gets the uv input component
  20491. */
  20492. get uv(): NodeMaterialConnectionPoint;
  20493. /**
  20494. * Gets the rgba output component
  20495. */
  20496. get rgba(): NodeMaterialConnectionPoint;
  20497. /**
  20498. * Gets the rgb output component
  20499. */
  20500. get rgb(): NodeMaterialConnectionPoint;
  20501. /**
  20502. * Gets the r output component
  20503. */
  20504. get r(): NodeMaterialConnectionPoint;
  20505. /**
  20506. * Gets the g output component
  20507. */
  20508. get g(): NodeMaterialConnectionPoint;
  20509. /**
  20510. * Gets the b output component
  20511. */
  20512. get b(): NodeMaterialConnectionPoint;
  20513. /**
  20514. * Gets the a output component
  20515. */
  20516. get a(): NodeMaterialConnectionPoint;
  20517. get target(): NodeMaterialBlockTargets;
  20518. autoConfigure(material: NodeMaterial): void;
  20519. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20520. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20521. isReady(): boolean;
  20522. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20523. private get _isMixed();
  20524. private _injectVertexCode;
  20525. private _writeTextureRead;
  20526. private _writeOutput;
  20527. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20528. protected _dumpPropertiesCode(): string;
  20529. serialize(): any;
  20530. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20531. }
  20532. }
  20533. declare module BABYLON {
  20534. /** @hidden */
  20535. export var reflectionFunction: {
  20536. name: string;
  20537. shader: string;
  20538. };
  20539. }
  20540. declare module BABYLON {
  20541. /**
  20542. * Base block used to read a reflection texture from a sampler
  20543. */
  20544. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20545. /** @hidden */
  20546. _define3DName: string;
  20547. /** @hidden */
  20548. _defineCubicName: string;
  20549. /** @hidden */
  20550. _defineExplicitName: string;
  20551. /** @hidden */
  20552. _defineProjectionName: string;
  20553. /** @hidden */
  20554. _defineLocalCubicName: string;
  20555. /** @hidden */
  20556. _defineSphericalName: string;
  20557. /** @hidden */
  20558. _definePlanarName: string;
  20559. /** @hidden */
  20560. _defineEquirectangularName: string;
  20561. /** @hidden */
  20562. _defineMirroredEquirectangularFixedName: string;
  20563. /** @hidden */
  20564. _defineEquirectangularFixedName: string;
  20565. /** @hidden */
  20566. _defineSkyboxName: string;
  20567. /** @hidden */
  20568. _defineOppositeZ: string;
  20569. /** @hidden */
  20570. _cubeSamplerName: string;
  20571. /** @hidden */
  20572. _2DSamplerName: string;
  20573. protected _positionUVWName: string;
  20574. protected _directionWName: string;
  20575. protected _reflectionVectorName: string;
  20576. /** @hidden */
  20577. _reflectionCoordsName: string;
  20578. /** @hidden */
  20579. _reflectionMatrixName: string;
  20580. protected _reflectionColorName: string;
  20581. /**
  20582. * Gets or sets the texture associated with the node
  20583. */
  20584. texture: Nullable<BaseTexture>;
  20585. /**
  20586. * Create a new ReflectionTextureBaseBlock
  20587. * @param name defines the block name
  20588. */
  20589. constructor(name: string);
  20590. /**
  20591. * Gets the current class name
  20592. * @returns the class name
  20593. */
  20594. getClassName(): string;
  20595. /**
  20596. * Gets the world position input component
  20597. */
  20598. abstract get position(): NodeMaterialConnectionPoint;
  20599. /**
  20600. * Gets the world position input component
  20601. */
  20602. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20603. /**
  20604. * Gets the world normal input component
  20605. */
  20606. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20607. /**
  20608. * Gets the world input component
  20609. */
  20610. abstract get world(): NodeMaterialConnectionPoint;
  20611. /**
  20612. * Gets the camera (or eye) position component
  20613. */
  20614. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20615. /**
  20616. * Gets the view input component
  20617. */
  20618. abstract get view(): NodeMaterialConnectionPoint;
  20619. protected _getTexture(): Nullable<BaseTexture>;
  20620. autoConfigure(material: NodeMaterial): void;
  20621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20622. isReady(): boolean;
  20623. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20624. /**
  20625. * Gets the code to inject in the vertex shader
  20626. * @param state current state of the node material building
  20627. * @returns the shader code
  20628. */
  20629. handleVertexSide(state: NodeMaterialBuildState): string;
  20630. /**
  20631. * Handles the inits for the fragment code path
  20632. * @param state node material build state
  20633. */
  20634. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20635. /**
  20636. * Generates the reflection coords code for the fragment code path
  20637. * @param worldNormalVarName name of the world normal variable
  20638. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20639. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20640. * @returns the shader code
  20641. */
  20642. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20643. /**
  20644. * Generates the reflection color code for the fragment code path
  20645. * @param lodVarName name of the lod variable
  20646. * @param swizzleLookupTexture swizzle to use for the final color variable
  20647. * @returns the shader code
  20648. */
  20649. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20650. /**
  20651. * Generates the code corresponding to the connected output points
  20652. * @param state node material build state
  20653. * @param varName name of the variable to output
  20654. * @returns the shader code
  20655. */
  20656. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20657. protected _buildBlock(state: NodeMaterialBuildState): this;
  20658. protected _dumpPropertiesCode(): string;
  20659. serialize(): any;
  20660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20661. }
  20662. }
  20663. declare module BABYLON {
  20664. /**
  20665. * Defines a connection point to be used for points with a custom object type
  20666. */
  20667. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20668. private _blockType;
  20669. private _blockName;
  20670. private _nameForCheking?;
  20671. /**
  20672. * Creates a new connection point
  20673. * @param name defines the connection point name
  20674. * @param ownerBlock defines the block hosting this connection point
  20675. * @param direction defines the direction of the connection point
  20676. */
  20677. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20678. /**
  20679. * Gets a number indicating if the current point can be connected to another point
  20680. * @param connectionPoint defines the other connection point
  20681. * @returns a number defining the compatibility state
  20682. */
  20683. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20684. /**
  20685. * Creates a block suitable to be used as an input for this input point.
  20686. * If null is returned, a block based on the point type will be created.
  20687. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20688. */
  20689. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20690. }
  20691. }
  20692. declare module BABYLON {
  20693. /**
  20694. * Enum defining the type of properties that can be edited in the property pages in the NME
  20695. */
  20696. export enum PropertyTypeForEdition {
  20697. /** property is a boolean */
  20698. Boolean = 0,
  20699. /** property is a float */
  20700. Float = 1,
  20701. /** property is a Vector2 */
  20702. Vector2 = 2,
  20703. /** property is a list of values */
  20704. List = 3
  20705. }
  20706. /**
  20707. * Interface that defines an option in a variable of type list
  20708. */
  20709. export interface IEditablePropertyListOption {
  20710. /** label of the option */
  20711. "label": string;
  20712. /** value of the option */
  20713. "value": number;
  20714. }
  20715. /**
  20716. * Interface that defines the options available for an editable property
  20717. */
  20718. export interface IEditablePropertyOption {
  20719. /** min value */
  20720. "min"?: number;
  20721. /** max value */
  20722. "max"?: number;
  20723. /** notifiers: indicates which actions to take when the property is changed */
  20724. "notifiers"?: {
  20725. /** the material should be rebuilt */
  20726. "rebuild"?: boolean;
  20727. /** the preview should be updated */
  20728. "update"?: boolean;
  20729. };
  20730. /** list of the options for a variable of type list */
  20731. "options"?: IEditablePropertyListOption[];
  20732. }
  20733. /**
  20734. * Interface that describes an editable property
  20735. */
  20736. export interface IPropertyDescriptionForEdition {
  20737. /** name of the property */
  20738. "propertyName": string;
  20739. /** display name of the property */
  20740. "displayName": string;
  20741. /** type of the property */
  20742. "type": PropertyTypeForEdition;
  20743. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20744. "groupName": string;
  20745. /** options for the property */
  20746. "options": IEditablePropertyOption;
  20747. }
  20748. /**
  20749. * Decorator that flags a property in a node material block as being editable
  20750. */
  20751. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20752. }
  20753. declare module BABYLON {
  20754. /**
  20755. * Block used to implement the refraction part of the sub surface module of the PBR material
  20756. */
  20757. export class RefractionBlock extends NodeMaterialBlock {
  20758. /** @hidden */
  20759. _define3DName: string;
  20760. /** @hidden */
  20761. _refractionMatrixName: string;
  20762. /** @hidden */
  20763. _defineLODRefractionAlpha: string;
  20764. /** @hidden */
  20765. _defineLinearSpecularRefraction: string;
  20766. /** @hidden */
  20767. _defineOppositeZ: string;
  20768. /** @hidden */
  20769. _cubeSamplerName: string;
  20770. /** @hidden */
  20771. _2DSamplerName: string;
  20772. /** @hidden */
  20773. _vRefractionMicrosurfaceInfosName: string;
  20774. /** @hidden */
  20775. _vRefractionInfosName: string;
  20776. private _scene;
  20777. /**
  20778. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20779. * Materials half opaque for instance using refraction could benefit from this control.
  20780. */
  20781. linkRefractionWithTransparency: boolean;
  20782. /**
  20783. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20784. */
  20785. invertRefractionY: boolean;
  20786. /**
  20787. * Gets or sets the texture associated with the node
  20788. */
  20789. texture: Nullable<BaseTexture>;
  20790. /**
  20791. * Create a new RefractionBlock
  20792. * @param name defines the block name
  20793. */
  20794. constructor(name: string);
  20795. /**
  20796. * Gets the current class name
  20797. * @returns the class name
  20798. */
  20799. getClassName(): string;
  20800. /**
  20801. * Gets the intensity input component
  20802. */
  20803. get intensity(): NodeMaterialConnectionPoint;
  20804. /**
  20805. * Gets the index of refraction input component
  20806. */
  20807. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20808. /**
  20809. * Gets the tint at distance input component
  20810. */
  20811. get tintAtDistance(): NodeMaterialConnectionPoint;
  20812. /**
  20813. * Gets the view input component
  20814. */
  20815. get view(): NodeMaterialConnectionPoint;
  20816. /**
  20817. * Gets the refraction object output component
  20818. */
  20819. get refraction(): NodeMaterialConnectionPoint;
  20820. /**
  20821. * Returns true if the block has a texture
  20822. */
  20823. get hasTexture(): boolean;
  20824. protected _getTexture(): Nullable<BaseTexture>;
  20825. autoConfigure(material: NodeMaterial): void;
  20826. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20827. isReady(): boolean;
  20828. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20829. /**
  20830. * Gets the main code of the block (fragment side)
  20831. * @param state current state of the node material building
  20832. * @returns the shader code
  20833. */
  20834. getCode(state: NodeMaterialBuildState): string;
  20835. protected _buildBlock(state: NodeMaterialBuildState): this;
  20836. protected _dumpPropertiesCode(): string;
  20837. serialize(): any;
  20838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20839. }
  20840. }
  20841. declare module BABYLON {
  20842. /**
  20843. * Base block used as input for post process
  20844. */
  20845. export class CurrentScreenBlock extends NodeMaterialBlock {
  20846. private _samplerName;
  20847. private _linearDefineName;
  20848. private _gammaDefineName;
  20849. private _mainUVName;
  20850. private _tempTextureRead;
  20851. /**
  20852. * Gets or sets the texture associated with the node
  20853. */
  20854. texture: Nullable<BaseTexture>;
  20855. /**
  20856. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20857. */
  20858. convertToGammaSpace: boolean;
  20859. /**
  20860. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20861. */
  20862. convertToLinearSpace: boolean;
  20863. /**
  20864. * Create a new CurrentScreenBlock
  20865. * @param name defines the block name
  20866. */
  20867. constructor(name: string);
  20868. /**
  20869. * Gets the current class name
  20870. * @returns the class name
  20871. */
  20872. getClassName(): string;
  20873. /**
  20874. * Gets the uv input component
  20875. */
  20876. get uv(): NodeMaterialConnectionPoint;
  20877. /**
  20878. * Gets the rgba output component
  20879. */
  20880. get rgba(): NodeMaterialConnectionPoint;
  20881. /**
  20882. * Gets the rgb output component
  20883. */
  20884. get rgb(): NodeMaterialConnectionPoint;
  20885. /**
  20886. * Gets the r output component
  20887. */
  20888. get r(): NodeMaterialConnectionPoint;
  20889. /**
  20890. * Gets the g output component
  20891. */
  20892. get g(): NodeMaterialConnectionPoint;
  20893. /**
  20894. * Gets the b output component
  20895. */
  20896. get b(): NodeMaterialConnectionPoint;
  20897. /**
  20898. * Gets the a output component
  20899. */
  20900. get a(): NodeMaterialConnectionPoint;
  20901. /**
  20902. * Initialize the block and prepare the context for build
  20903. * @param state defines the state that will be used for the build
  20904. */
  20905. initialize(state: NodeMaterialBuildState): void;
  20906. get target(): NodeMaterialBlockTargets;
  20907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20908. isReady(): boolean;
  20909. private _injectVertexCode;
  20910. private _writeTextureRead;
  20911. private _writeOutput;
  20912. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20913. serialize(): any;
  20914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20915. }
  20916. }
  20917. declare module BABYLON {
  20918. /**
  20919. * Base block used for the particle texture
  20920. */
  20921. export class ParticleTextureBlock extends NodeMaterialBlock {
  20922. private _samplerName;
  20923. private _linearDefineName;
  20924. private _gammaDefineName;
  20925. private _tempTextureRead;
  20926. /**
  20927. * Gets or sets the texture associated with the node
  20928. */
  20929. texture: Nullable<BaseTexture>;
  20930. /**
  20931. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20932. */
  20933. convertToGammaSpace: boolean;
  20934. /**
  20935. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20936. */
  20937. convertToLinearSpace: boolean;
  20938. /**
  20939. * Create a new ParticleTextureBlock
  20940. * @param name defines the block name
  20941. */
  20942. constructor(name: string);
  20943. /**
  20944. * Gets the current class name
  20945. * @returns the class name
  20946. */
  20947. getClassName(): string;
  20948. /**
  20949. * Gets the uv input component
  20950. */
  20951. get uv(): NodeMaterialConnectionPoint;
  20952. /**
  20953. * Gets the rgba output component
  20954. */
  20955. get rgba(): NodeMaterialConnectionPoint;
  20956. /**
  20957. * Gets the rgb output component
  20958. */
  20959. get rgb(): NodeMaterialConnectionPoint;
  20960. /**
  20961. * Gets the r output component
  20962. */
  20963. get r(): NodeMaterialConnectionPoint;
  20964. /**
  20965. * Gets the g output component
  20966. */
  20967. get g(): NodeMaterialConnectionPoint;
  20968. /**
  20969. * Gets the b output component
  20970. */
  20971. get b(): NodeMaterialConnectionPoint;
  20972. /**
  20973. * Gets the a output component
  20974. */
  20975. get a(): NodeMaterialConnectionPoint;
  20976. /**
  20977. * Initialize the block and prepare the context for build
  20978. * @param state defines the state that will be used for the build
  20979. */
  20980. initialize(state: NodeMaterialBuildState): void;
  20981. autoConfigure(material: NodeMaterial): void;
  20982. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20983. isReady(): boolean;
  20984. private _writeOutput;
  20985. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20986. serialize(): any;
  20987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20988. }
  20989. }
  20990. declare module BABYLON {
  20991. /**
  20992. * Class used to store shared data between 2 NodeMaterialBuildState
  20993. */
  20994. export class NodeMaterialBuildStateSharedData {
  20995. /**
  20996. * Gets the list of emitted varyings
  20997. */
  20998. temps: string[];
  20999. /**
  21000. * Gets the list of emitted varyings
  21001. */
  21002. varyings: string[];
  21003. /**
  21004. * Gets the varying declaration string
  21005. */
  21006. varyingDeclaration: string;
  21007. /**
  21008. * Input blocks
  21009. */
  21010. inputBlocks: InputBlock[];
  21011. /**
  21012. * Input blocks
  21013. */
  21014. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21015. /**
  21016. * Bindable blocks (Blocks that need to set data to the effect)
  21017. */
  21018. bindableBlocks: NodeMaterialBlock[];
  21019. /**
  21020. * List of blocks that can provide a compilation fallback
  21021. */
  21022. blocksWithFallbacks: NodeMaterialBlock[];
  21023. /**
  21024. * List of blocks that can provide a define update
  21025. */
  21026. blocksWithDefines: NodeMaterialBlock[];
  21027. /**
  21028. * List of blocks that can provide a repeatable content
  21029. */
  21030. repeatableContentBlocks: NodeMaterialBlock[];
  21031. /**
  21032. * List of blocks that can provide a dynamic list of uniforms
  21033. */
  21034. dynamicUniformBlocks: NodeMaterialBlock[];
  21035. /**
  21036. * List of blocks that can block the isReady function for the material
  21037. */
  21038. blockingBlocks: NodeMaterialBlock[];
  21039. /**
  21040. * Gets the list of animated inputs
  21041. */
  21042. animatedInputs: InputBlock[];
  21043. /**
  21044. * Build Id used to avoid multiple recompilations
  21045. */
  21046. buildId: number;
  21047. /** List of emitted variables */
  21048. variableNames: {
  21049. [key: string]: number;
  21050. };
  21051. /** List of emitted defines */
  21052. defineNames: {
  21053. [key: string]: number;
  21054. };
  21055. /** Should emit comments? */
  21056. emitComments: boolean;
  21057. /** Emit build activity */
  21058. verbose: boolean;
  21059. /** Gets or sets the hosting scene */
  21060. scene: Scene;
  21061. /**
  21062. * Gets the compilation hints emitted at compilation time
  21063. */
  21064. hints: {
  21065. needWorldViewMatrix: boolean;
  21066. needWorldViewProjectionMatrix: boolean;
  21067. needAlphaBlending: boolean;
  21068. needAlphaTesting: boolean;
  21069. };
  21070. /**
  21071. * List of compilation checks
  21072. */
  21073. checks: {
  21074. emitVertex: boolean;
  21075. emitFragment: boolean;
  21076. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21077. };
  21078. /**
  21079. * Is vertex program allowed to be empty?
  21080. */
  21081. allowEmptyVertexProgram: boolean;
  21082. /** Creates a new shared data */
  21083. constructor();
  21084. /**
  21085. * Emits console errors and exceptions if there is a failing check
  21086. */
  21087. emitErrors(): void;
  21088. }
  21089. }
  21090. declare module BABYLON {
  21091. /**
  21092. * Class used to store node based material build state
  21093. */
  21094. export class NodeMaterialBuildState {
  21095. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21096. supportUniformBuffers: boolean;
  21097. /**
  21098. * Gets the list of emitted attributes
  21099. */
  21100. attributes: string[];
  21101. /**
  21102. * Gets the list of emitted uniforms
  21103. */
  21104. uniforms: string[];
  21105. /**
  21106. * Gets the list of emitted constants
  21107. */
  21108. constants: string[];
  21109. /**
  21110. * Gets the list of emitted samplers
  21111. */
  21112. samplers: string[];
  21113. /**
  21114. * Gets the list of emitted functions
  21115. */
  21116. functions: {
  21117. [key: string]: string;
  21118. };
  21119. /**
  21120. * Gets the list of emitted extensions
  21121. */
  21122. extensions: {
  21123. [key: string]: string;
  21124. };
  21125. /**
  21126. * Gets the target of the compilation state
  21127. */
  21128. target: NodeMaterialBlockTargets;
  21129. /**
  21130. * Gets the list of emitted counters
  21131. */
  21132. counters: {
  21133. [key: string]: number;
  21134. };
  21135. /**
  21136. * Shared data between multiple NodeMaterialBuildState instances
  21137. */
  21138. sharedData: NodeMaterialBuildStateSharedData;
  21139. /** @hidden */
  21140. _vertexState: NodeMaterialBuildState;
  21141. /** @hidden */
  21142. _attributeDeclaration: string;
  21143. /** @hidden */
  21144. _uniformDeclaration: string;
  21145. /** @hidden */
  21146. _constantDeclaration: string;
  21147. /** @hidden */
  21148. _samplerDeclaration: string;
  21149. /** @hidden */
  21150. _varyingTransfer: string;
  21151. /** @hidden */
  21152. _injectAtEnd: string;
  21153. private _repeatableContentAnchorIndex;
  21154. /** @hidden */
  21155. _builtCompilationString: string;
  21156. /**
  21157. * Gets the emitted compilation strings
  21158. */
  21159. compilationString: string;
  21160. /**
  21161. * Finalize the compilation strings
  21162. * @param state defines the current compilation state
  21163. */
  21164. finalize(state: NodeMaterialBuildState): void;
  21165. /** @hidden */
  21166. get _repeatableContentAnchor(): string;
  21167. /** @hidden */
  21168. _getFreeVariableName(prefix: string): string;
  21169. /** @hidden */
  21170. _getFreeDefineName(prefix: string): string;
  21171. /** @hidden */
  21172. _excludeVariableName(name: string): void;
  21173. /** @hidden */
  21174. _emit2DSampler(name: string): void;
  21175. /** @hidden */
  21176. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21177. /** @hidden */
  21178. _emitExtension(name: string, extension: string, define?: string): void;
  21179. /** @hidden */
  21180. _emitFunction(name: string, code: string, comments: string): void;
  21181. /** @hidden */
  21182. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21183. replaceStrings?: {
  21184. search: RegExp;
  21185. replace: string;
  21186. }[];
  21187. repeatKey?: string;
  21188. }): string;
  21189. /** @hidden */
  21190. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21191. repeatKey?: string;
  21192. removeAttributes?: boolean;
  21193. removeUniforms?: boolean;
  21194. removeVaryings?: boolean;
  21195. removeIfDef?: boolean;
  21196. replaceStrings?: {
  21197. search: RegExp;
  21198. replace: string;
  21199. }[];
  21200. }, storeKey?: string): void;
  21201. /** @hidden */
  21202. _registerTempVariable(name: string): boolean;
  21203. /** @hidden */
  21204. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21205. /** @hidden */
  21206. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21207. /** @hidden */
  21208. _emitFloat(value: number): string;
  21209. }
  21210. }
  21211. declare module BABYLON {
  21212. /**
  21213. * Helper class used to generate session unique ID
  21214. */
  21215. export class UniqueIdGenerator {
  21216. private static _UniqueIdCounter;
  21217. /**
  21218. * Gets an unique (relatively to the current scene) Id
  21219. */
  21220. static get UniqueId(): number;
  21221. }
  21222. }
  21223. declare module BABYLON {
  21224. /**
  21225. * Defines a block that can be used inside a node based material
  21226. */
  21227. export class NodeMaterialBlock {
  21228. private _buildId;
  21229. private _buildTarget;
  21230. private _target;
  21231. private _isFinalMerger;
  21232. private _isInput;
  21233. protected _isUnique: boolean;
  21234. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21235. inputsAreExclusive: boolean;
  21236. /** @hidden */
  21237. _codeVariableName: string;
  21238. /** @hidden */
  21239. _inputs: NodeMaterialConnectionPoint[];
  21240. /** @hidden */
  21241. _outputs: NodeMaterialConnectionPoint[];
  21242. /** @hidden */
  21243. _preparationId: number;
  21244. /**
  21245. * Gets or sets the name of the block
  21246. */
  21247. name: string;
  21248. /**
  21249. * Gets or sets the unique id of the node
  21250. */
  21251. uniqueId: number;
  21252. /**
  21253. * Gets or sets the comments associated with this block
  21254. */
  21255. comments: string;
  21256. /**
  21257. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21258. */
  21259. get isUnique(): boolean;
  21260. /**
  21261. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21262. */
  21263. get isFinalMerger(): boolean;
  21264. /**
  21265. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21266. */
  21267. get isInput(): boolean;
  21268. /**
  21269. * Gets or sets the build Id
  21270. */
  21271. get buildId(): number;
  21272. set buildId(value: number);
  21273. /**
  21274. * Gets or sets the target of the block
  21275. */
  21276. get target(): NodeMaterialBlockTargets;
  21277. set target(value: NodeMaterialBlockTargets);
  21278. /**
  21279. * Gets the list of input points
  21280. */
  21281. get inputs(): NodeMaterialConnectionPoint[];
  21282. /** Gets the list of output points */
  21283. get outputs(): NodeMaterialConnectionPoint[];
  21284. /**
  21285. * Find an input by its name
  21286. * @param name defines the name of the input to look for
  21287. * @returns the input or null if not found
  21288. */
  21289. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21290. /**
  21291. * Find an output by its name
  21292. * @param name defines the name of the outputto look for
  21293. * @returns the output or null if not found
  21294. */
  21295. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21296. /**
  21297. * Creates a new NodeMaterialBlock
  21298. * @param name defines the block name
  21299. * @param target defines the target of that block (Vertex by default)
  21300. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21301. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21302. */
  21303. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21304. /**
  21305. * Initialize the block and prepare the context for build
  21306. * @param state defines the state that will be used for the build
  21307. */
  21308. initialize(state: NodeMaterialBuildState): void;
  21309. /**
  21310. * Bind data to effect. Will only be called for blocks with isBindable === true
  21311. * @param effect defines the effect to bind data to
  21312. * @param nodeMaterial defines the hosting NodeMaterial
  21313. * @param mesh defines the mesh that will be rendered
  21314. * @param subMesh defines the submesh that will be rendered
  21315. */
  21316. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21317. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21318. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21319. protected _writeFloat(value: number): string;
  21320. /**
  21321. * Gets the current class name e.g. "NodeMaterialBlock"
  21322. * @returns the class name
  21323. */
  21324. getClassName(): string;
  21325. /**
  21326. * Register a new input. Must be called inside a block constructor
  21327. * @param name defines the connection point name
  21328. * @param type defines the connection point type
  21329. * @param isOptional defines a boolean indicating that this input can be omitted
  21330. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21331. * @param point an already created connection point. If not provided, create a new one
  21332. * @returns the current block
  21333. */
  21334. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21335. /**
  21336. * Register a new output. Must be called inside a block constructor
  21337. * @param name defines the connection point name
  21338. * @param type defines the connection point type
  21339. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21340. * @param point an already created connection point. If not provided, create a new one
  21341. * @returns the current block
  21342. */
  21343. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21344. /**
  21345. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21346. * @param forOutput defines an optional connection point to check compatibility with
  21347. * @returns the first available input or null
  21348. */
  21349. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21350. /**
  21351. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21352. * @param forBlock defines an optional block to check compatibility with
  21353. * @returns the first available input or null
  21354. */
  21355. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21356. /**
  21357. * Gets the sibling of the given output
  21358. * @param current defines the current output
  21359. * @returns the next output in the list or null
  21360. */
  21361. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21362. /**
  21363. * Connect current block with another block
  21364. * @param other defines the block to connect with
  21365. * @param options define the various options to help pick the right connections
  21366. * @returns the current block
  21367. */
  21368. connectTo(other: NodeMaterialBlock, options?: {
  21369. input?: string;
  21370. output?: string;
  21371. outputSwizzle?: string;
  21372. }): this | undefined;
  21373. protected _buildBlock(state: NodeMaterialBuildState): void;
  21374. /**
  21375. * Add uniforms, samplers and uniform buffers at compilation time
  21376. * @param state defines the state to update
  21377. * @param nodeMaterial defines the node material requesting the update
  21378. * @param defines defines the material defines to update
  21379. * @param uniformBuffers defines the list of uniform buffer names
  21380. */
  21381. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21382. /**
  21383. * Add potential fallbacks if shader compilation fails
  21384. * @param mesh defines the mesh to be rendered
  21385. * @param fallbacks defines the current prioritized list of fallbacks
  21386. */
  21387. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21388. /**
  21389. * Initialize defines for shader compilation
  21390. * @param mesh defines the mesh to be rendered
  21391. * @param nodeMaterial defines the node material requesting the update
  21392. * @param defines defines the material defines to update
  21393. * @param useInstances specifies that instances should be used
  21394. */
  21395. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21396. /**
  21397. * Update defines for shader compilation
  21398. * @param mesh defines the mesh to be rendered
  21399. * @param nodeMaterial defines the node material requesting the update
  21400. * @param defines defines the material defines to update
  21401. * @param useInstances specifies that instances should be used
  21402. * @param subMesh defines which submesh to render
  21403. */
  21404. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21405. /**
  21406. * Lets the block try to connect some inputs automatically
  21407. * @param material defines the hosting NodeMaterial
  21408. */
  21409. autoConfigure(material: NodeMaterial): void;
  21410. /**
  21411. * Function called when a block is declared as repeatable content generator
  21412. * @param vertexShaderState defines the current compilation state for the vertex shader
  21413. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21414. * @param mesh defines the mesh to be rendered
  21415. * @param defines defines the material defines to update
  21416. */
  21417. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21418. /**
  21419. * Checks if the block is ready
  21420. * @param mesh defines the mesh to be rendered
  21421. * @param nodeMaterial defines the node material requesting the update
  21422. * @param defines defines the material defines to update
  21423. * @param useInstances specifies that instances should be used
  21424. * @returns true if the block is ready
  21425. */
  21426. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21427. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21428. private _processBuild;
  21429. /**
  21430. * Compile the current node and generate the shader code
  21431. * @param state defines the current compilation state (uniforms, samplers, current string)
  21432. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21433. * @returns true if already built
  21434. */
  21435. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21436. protected _inputRename(name: string): string;
  21437. protected _outputRename(name: string): string;
  21438. protected _dumpPropertiesCode(): string;
  21439. /** @hidden */
  21440. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21441. /** @hidden */
  21442. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21443. /**
  21444. * Clone the current block to a new identical block
  21445. * @param scene defines the hosting scene
  21446. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21447. * @returns a copy of the current block
  21448. */
  21449. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21450. /**
  21451. * Serializes this block in a JSON representation
  21452. * @returns the serialized block object
  21453. */
  21454. serialize(): any;
  21455. /** @hidden */
  21456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21457. private _deserializePortDisplayNamesAndExposedOnFrame;
  21458. /**
  21459. * Release resources
  21460. */
  21461. dispose(): void;
  21462. }
  21463. }
  21464. declare module BABYLON {
  21465. /**
  21466. * Base class of materials working in push mode in babylon JS
  21467. * @hidden
  21468. */
  21469. export class PushMaterial extends Material {
  21470. protected _activeEffect: Effect;
  21471. protected _normalMatrix: Matrix;
  21472. constructor(name: string, scene: Scene);
  21473. getEffect(): Effect;
  21474. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21475. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21476. /**
  21477. * Binds the given world matrix to the active effect
  21478. *
  21479. * @param world the matrix to bind
  21480. */
  21481. bindOnlyWorldMatrix(world: Matrix): void;
  21482. /**
  21483. * Binds the given normal matrix to the active effect
  21484. *
  21485. * @param normalMatrix the matrix to bind
  21486. */
  21487. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21488. bind(world: Matrix, mesh?: Mesh): void;
  21489. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21490. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21491. }
  21492. }
  21493. declare module BABYLON {
  21494. /**
  21495. * Root class for all node material optimizers
  21496. */
  21497. export class NodeMaterialOptimizer {
  21498. /**
  21499. * Function used to optimize a NodeMaterial graph
  21500. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21501. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21502. */
  21503. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21504. }
  21505. }
  21506. declare module BABYLON {
  21507. /**
  21508. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21509. */
  21510. export class TransformBlock extends NodeMaterialBlock {
  21511. /**
  21512. * Defines the value to use to complement W value to transform it to a Vector4
  21513. */
  21514. complementW: number;
  21515. /**
  21516. * Defines the value to use to complement z value to transform it to a Vector4
  21517. */
  21518. complementZ: number;
  21519. /**
  21520. * Creates a new TransformBlock
  21521. * @param name defines the block name
  21522. */
  21523. constructor(name: string);
  21524. /**
  21525. * Gets the current class name
  21526. * @returns the class name
  21527. */
  21528. getClassName(): string;
  21529. /**
  21530. * Gets the vector input
  21531. */
  21532. get vector(): NodeMaterialConnectionPoint;
  21533. /**
  21534. * Gets the output component
  21535. */
  21536. get output(): NodeMaterialConnectionPoint;
  21537. /**
  21538. * Gets the xyz output component
  21539. */
  21540. get xyz(): NodeMaterialConnectionPoint;
  21541. /**
  21542. * Gets the matrix transform input
  21543. */
  21544. get transform(): NodeMaterialConnectionPoint;
  21545. protected _buildBlock(state: NodeMaterialBuildState): this;
  21546. /**
  21547. * Update defines for shader compilation
  21548. * @param mesh defines the mesh to be rendered
  21549. * @param nodeMaterial defines the node material requesting the update
  21550. * @param defines defines the material defines to update
  21551. * @param useInstances specifies that instances should be used
  21552. * @param subMesh defines which submesh to render
  21553. */
  21554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21555. serialize(): any;
  21556. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21557. protected _dumpPropertiesCode(): string;
  21558. }
  21559. }
  21560. declare module BABYLON {
  21561. /**
  21562. * Block used to output the vertex position
  21563. */
  21564. export class VertexOutputBlock extends NodeMaterialBlock {
  21565. /**
  21566. * Creates a new VertexOutputBlock
  21567. * @param name defines the block name
  21568. */
  21569. constructor(name: string);
  21570. /**
  21571. * Gets the current class name
  21572. * @returns the class name
  21573. */
  21574. getClassName(): string;
  21575. /**
  21576. * Gets the vector input component
  21577. */
  21578. get vector(): NodeMaterialConnectionPoint;
  21579. protected _buildBlock(state: NodeMaterialBuildState): this;
  21580. }
  21581. }
  21582. declare module BABYLON {
  21583. /**
  21584. * Block used to output the final color
  21585. */
  21586. export class FragmentOutputBlock extends NodeMaterialBlock {
  21587. /**
  21588. * Create a new FragmentOutputBlock
  21589. * @param name defines the block name
  21590. */
  21591. constructor(name: string);
  21592. /**
  21593. * Gets the current class name
  21594. * @returns the class name
  21595. */
  21596. getClassName(): string;
  21597. /**
  21598. * Gets the rgba input component
  21599. */
  21600. get rgba(): NodeMaterialConnectionPoint;
  21601. /**
  21602. * Gets the rgb input component
  21603. */
  21604. get rgb(): NodeMaterialConnectionPoint;
  21605. /**
  21606. * Gets the a input component
  21607. */
  21608. get a(): NodeMaterialConnectionPoint;
  21609. protected _buildBlock(state: NodeMaterialBuildState): this;
  21610. }
  21611. }
  21612. declare module BABYLON {
  21613. /**
  21614. * Block used for the particle ramp gradient section
  21615. */
  21616. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21617. /**
  21618. * Create a new ParticleRampGradientBlock
  21619. * @param name defines the block name
  21620. */
  21621. constructor(name: string);
  21622. /**
  21623. * Gets the current class name
  21624. * @returns the class name
  21625. */
  21626. getClassName(): string;
  21627. /**
  21628. * Gets the color input component
  21629. */
  21630. get color(): NodeMaterialConnectionPoint;
  21631. /**
  21632. * Gets the rampColor output component
  21633. */
  21634. get rampColor(): NodeMaterialConnectionPoint;
  21635. /**
  21636. * Initialize the block and prepare the context for build
  21637. * @param state defines the state that will be used for the build
  21638. */
  21639. initialize(state: NodeMaterialBuildState): void;
  21640. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21641. }
  21642. }
  21643. declare module BABYLON {
  21644. /**
  21645. * Block used for the particle blend multiply section
  21646. */
  21647. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21648. /**
  21649. * Create a new ParticleBlendMultiplyBlock
  21650. * @param name defines the block name
  21651. */
  21652. constructor(name: string);
  21653. /**
  21654. * Gets the current class name
  21655. * @returns the class name
  21656. */
  21657. getClassName(): string;
  21658. /**
  21659. * Gets the color input component
  21660. */
  21661. get color(): NodeMaterialConnectionPoint;
  21662. /**
  21663. * Gets the alphaTexture input component
  21664. */
  21665. get alphaTexture(): NodeMaterialConnectionPoint;
  21666. /**
  21667. * Gets the alphaColor input component
  21668. */
  21669. get alphaColor(): NodeMaterialConnectionPoint;
  21670. /**
  21671. * Gets the blendColor output component
  21672. */
  21673. get blendColor(): NodeMaterialConnectionPoint;
  21674. /**
  21675. * Initialize the block and prepare the context for build
  21676. * @param state defines the state that will be used for the build
  21677. */
  21678. initialize(state: NodeMaterialBuildState): void;
  21679. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21680. }
  21681. }
  21682. declare module BABYLON {
  21683. /**
  21684. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21685. */
  21686. export class VectorMergerBlock extends NodeMaterialBlock {
  21687. /**
  21688. * Create a new VectorMergerBlock
  21689. * @param name defines the block name
  21690. */
  21691. constructor(name: string);
  21692. /**
  21693. * Gets the current class name
  21694. * @returns the class name
  21695. */
  21696. getClassName(): string;
  21697. /**
  21698. * Gets the xyz component (input)
  21699. */
  21700. get xyzIn(): NodeMaterialConnectionPoint;
  21701. /**
  21702. * Gets the xy component (input)
  21703. */
  21704. get xyIn(): NodeMaterialConnectionPoint;
  21705. /**
  21706. * Gets the x component (input)
  21707. */
  21708. get x(): NodeMaterialConnectionPoint;
  21709. /**
  21710. * Gets the y component (input)
  21711. */
  21712. get y(): NodeMaterialConnectionPoint;
  21713. /**
  21714. * Gets the z component (input)
  21715. */
  21716. get z(): NodeMaterialConnectionPoint;
  21717. /**
  21718. * Gets the w component (input)
  21719. */
  21720. get w(): NodeMaterialConnectionPoint;
  21721. /**
  21722. * Gets the xyzw component (output)
  21723. */
  21724. get xyzw(): NodeMaterialConnectionPoint;
  21725. /**
  21726. * Gets the xyz component (output)
  21727. */
  21728. get xyzOut(): NodeMaterialConnectionPoint;
  21729. /**
  21730. * Gets the xy component (output)
  21731. */
  21732. get xyOut(): NodeMaterialConnectionPoint;
  21733. /**
  21734. * Gets the xy component (output)
  21735. * @deprecated Please use xyOut instead.
  21736. */
  21737. get xy(): NodeMaterialConnectionPoint;
  21738. /**
  21739. * Gets the xyz component (output)
  21740. * @deprecated Please use xyzOut instead.
  21741. */
  21742. get xyz(): NodeMaterialConnectionPoint;
  21743. protected _buildBlock(state: NodeMaterialBuildState): this;
  21744. }
  21745. }
  21746. declare module BABYLON {
  21747. /**
  21748. * Block used to remap a float from a range to a new one
  21749. */
  21750. export class RemapBlock extends NodeMaterialBlock {
  21751. /**
  21752. * Gets or sets the source range
  21753. */
  21754. sourceRange: Vector2;
  21755. /**
  21756. * Gets or sets the target range
  21757. */
  21758. targetRange: Vector2;
  21759. /**
  21760. * Creates a new RemapBlock
  21761. * @param name defines the block name
  21762. */
  21763. constructor(name: string);
  21764. /**
  21765. * Gets the current class name
  21766. * @returns the class name
  21767. */
  21768. getClassName(): string;
  21769. /**
  21770. * Gets the input component
  21771. */
  21772. get input(): NodeMaterialConnectionPoint;
  21773. /**
  21774. * Gets the source min input component
  21775. */
  21776. get sourceMin(): NodeMaterialConnectionPoint;
  21777. /**
  21778. * Gets the source max input component
  21779. */
  21780. get sourceMax(): NodeMaterialConnectionPoint;
  21781. /**
  21782. * Gets the target min input component
  21783. */
  21784. get targetMin(): NodeMaterialConnectionPoint;
  21785. /**
  21786. * Gets the target max input component
  21787. */
  21788. get targetMax(): NodeMaterialConnectionPoint;
  21789. /**
  21790. * Gets the output component
  21791. */
  21792. get output(): NodeMaterialConnectionPoint;
  21793. protected _buildBlock(state: NodeMaterialBuildState): this;
  21794. protected _dumpPropertiesCode(): string;
  21795. serialize(): any;
  21796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21797. }
  21798. }
  21799. declare module BABYLON {
  21800. /**
  21801. * Block used to multiply 2 values
  21802. */
  21803. export class MultiplyBlock extends NodeMaterialBlock {
  21804. /**
  21805. * Creates a new MultiplyBlock
  21806. * @param name defines the block name
  21807. */
  21808. constructor(name: string);
  21809. /**
  21810. * Gets the current class name
  21811. * @returns the class name
  21812. */
  21813. getClassName(): string;
  21814. /**
  21815. * Gets the left operand input component
  21816. */
  21817. get left(): NodeMaterialConnectionPoint;
  21818. /**
  21819. * Gets the right operand input component
  21820. */
  21821. get right(): NodeMaterialConnectionPoint;
  21822. /**
  21823. * Gets the output component
  21824. */
  21825. get output(): NodeMaterialConnectionPoint;
  21826. protected _buildBlock(state: NodeMaterialBuildState): this;
  21827. }
  21828. }
  21829. declare module BABYLON {
  21830. /**
  21831. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21832. */
  21833. export class ColorSplitterBlock extends NodeMaterialBlock {
  21834. /**
  21835. * Create a new ColorSplitterBlock
  21836. * @param name defines the block name
  21837. */
  21838. constructor(name: string);
  21839. /**
  21840. * Gets the current class name
  21841. * @returns the class name
  21842. */
  21843. getClassName(): string;
  21844. /**
  21845. * Gets the rgba component (input)
  21846. */
  21847. get rgba(): NodeMaterialConnectionPoint;
  21848. /**
  21849. * Gets the rgb component (input)
  21850. */
  21851. get rgbIn(): NodeMaterialConnectionPoint;
  21852. /**
  21853. * Gets the rgb component (output)
  21854. */
  21855. get rgbOut(): NodeMaterialConnectionPoint;
  21856. /**
  21857. * Gets the r component (output)
  21858. */
  21859. get r(): NodeMaterialConnectionPoint;
  21860. /**
  21861. * Gets the g component (output)
  21862. */
  21863. get g(): NodeMaterialConnectionPoint;
  21864. /**
  21865. * Gets the b component (output)
  21866. */
  21867. get b(): NodeMaterialConnectionPoint;
  21868. /**
  21869. * Gets the a component (output)
  21870. */
  21871. get a(): NodeMaterialConnectionPoint;
  21872. protected _inputRename(name: string): string;
  21873. protected _outputRename(name: string): string;
  21874. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21875. }
  21876. }
  21877. declare module BABYLON {
  21878. /**
  21879. * Interface used to configure the node material editor
  21880. */
  21881. export interface INodeMaterialEditorOptions {
  21882. /** Define the URl to load node editor script */
  21883. editorURL?: string;
  21884. }
  21885. /** @hidden */
  21886. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21887. NORMAL: boolean;
  21888. TANGENT: boolean;
  21889. UV1: boolean;
  21890. /** BONES */
  21891. NUM_BONE_INFLUENCERS: number;
  21892. BonesPerMesh: number;
  21893. BONETEXTURE: boolean;
  21894. /** MORPH TARGETS */
  21895. MORPHTARGETS: boolean;
  21896. MORPHTARGETS_NORMAL: boolean;
  21897. MORPHTARGETS_TANGENT: boolean;
  21898. MORPHTARGETS_UV: boolean;
  21899. NUM_MORPH_INFLUENCERS: number;
  21900. /** IMAGE PROCESSING */
  21901. IMAGEPROCESSING: boolean;
  21902. VIGNETTE: boolean;
  21903. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21904. VIGNETTEBLENDMODEOPAQUE: boolean;
  21905. TONEMAPPING: boolean;
  21906. TONEMAPPING_ACES: boolean;
  21907. CONTRAST: boolean;
  21908. EXPOSURE: boolean;
  21909. COLORCURVES: boolean;
  21910. COLORGRADING: boolean;
  21911. COLORGRADING3D: boolean;
  21912. SAMPLER3DGREENDEPTH: boolean;
  21913. SAMPLER3DBGRMAP: boolean;
  21914. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21915. /** MISC. */
  21916. BUMPDIRECTUV: number;
  21917. constructor();
  21918. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21919. }
  21920. /**
  21921. * Class used to configure NodeMaterial
  21922. */
  21923. export interface INodeMaterialOptions {
  21924. /**
  21925. * Defines if blocks should emit comments
  21926. */
  21927. emitComments: boolean;
  21928. }
  21929. /**
  21930. * Class used to create a node based material built by assembling shader blocks
  21931. */
  21932. export class NodeMaterial extends PushMaterial {
  21933. private static _BuildIdGenerator;
  21934. private _options;
  21935. private _vertexCompilationState;
  21936. private _fragmentCompilationState;
  21937. private _sharedData;
  21938. private _buildId;
  21939. private _buildWasSuccessful;
  21940. private _cachedWorldViewMatrix;
  21941. private _cachedWorldViewProjectionMatrix;
  21942. private _optimizers;
  21943. private _animationFrame;
  21944. /** Define the Url to load node editor script */
  21945. static EditorURL: string;
  21946. /** Define the Url to load snippets */
  21947. static SnippetUrl: string;
  21948. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  21949. static IgnoreTexturesAtLoadTime: boolean;
  21950. private BJSNODEMATERIALEDITOR;
  21951. /** Get the inspector from bundle or global */
  21952. private _getGlobalNodeMaterialEditor;
  21953. /**
  21954. * Snippet ID if the material was created from the snippet server
  21955. */
  21956. snippetId: string;
  21957. /**
  21958. * Gets or sets data used by visual editor
  21959. * @see https://nme.babylonjs.com
  21960. */
  21961. editorData: any;
  21962. /**
  21963. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  21964. */
  21965. ignoreAlpha: boolean;
  21966. /**
  21967. * Defines the maximum number of lights that can be used in the material
  21968. */
  21969. maxSimultaneousLights: number;
  21970. /**
  21971. * Observable raised when the material is built
  21972. */
  21973. onBuildObservable: Observable<NodeMaterial>;
  21974. /**
  21975. * Gets or sets the root nodes of the material vertex shader
  21976. */
  21977. _vertexOutputNodes: NodeMaterialBlock[];
  21978. /**
  21979. * Gets or sets the root nodes of the material fragment (pixel) shader
  21980. */
  21981. _fragmentOutputNodes: NodeMaterialBlock[];
  21982. /** Gets or sets options to control the node material overall behavior */
  21983. get options(): INodeMaterialOptions;
  21984. set options(options: INodeMaterialOptions);
  21985. /**
  21986. * Default configuration related to image processing available in the standard Material.
  21987. */
  21988. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21989. /**
  21990. * Gets the image processing configuration used either in this material.
  21991. */
  21992. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  21993. /**
  21994. * Sets the Default image processing configuration used either in the this material.
  21995. *
  21996. * If sets to null, the scene one is in use.
  21997. */
  21998. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  21999. /**
  22000. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22001. */
  22002. attachedBlocks: NodeMaterialBlock[];
  22003. /**
  22004. * Specifies the mode of the node material
  22005. * @hidden
  22006. */
  22007. _mode: NodeMaterialModes;
  22008. /**
  22009. * Gets the mode property
  22010. */
  22011. get mode(): NodeMaterialModes;
  22012. /**
  22013. * Create a new node based material
  22014. * @param name defines the material name
  22015. * @param scene defines the hosting scene
  22016. * @param options defines creation option
  22017. */
  22018. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22019. /**
  22020. * Gets the current class name of the material e.g. "NodeMaterial"
  22021. * @returns the class name
  22022. */
  22023. getClassName(): string;
  22024. /**
  22025. * Keep track of the image processing observer to allow dispose and replace.
  22026. */
  22027. private _imageProcessingObserver;
  22028. /**
  22029. * Attaches a new image processing configuration to the Standard Material.
  22030. * @param configuration
  22031. */
  22032. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22033. /**
  22034. * Get a block by its name
  22035. * @param name defines the name of the block to retrieve
  22036. * @returns the required block or null if not found
  22037. */
  22038. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22039. /**
  22040. * Get a block by its name
  22041. * @param predicate defines the predicate used to find the good candidate
  22042. * @returns the required block or null if not found
  22043. */
  22044. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22045. /**
  22046. * Get an input block by its name
  22047. * @param predicate defines the predicate used to find the good candidate
  22048. * @returns the required input block or null if not found
  22049. */
  22050. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22051. /**
  22052. * Gets the list of input blocks attached to this material
  22053. * @returns an array of InputBlocks
  22054. */
  22055. getInputBlocks(): InputBlock[];
  22056. /**
  22057. * Adds a new optimizer to the list of optimizers
  22058. * @param optimizer defines the optimizers to add
  22059. * @returns the current material
  22060. */
  22061. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22062. /**
  22063. * Remove an optimizer from the list of optimizers
  22064. * @param optimizer defines the optimizers to remove
  22065. * @returns the current material
  22066. */
  22067. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22068. /**
  22069. * Add a new block to the list of output nodes
  22070. * @param node defines the node to add
  22071. * @returns the current material
  22072. */
  22073. addOutputNode(node: NodeMaterialBlock): this;
  22074. /**
  22075. * Remove a block from the list of root nodes
  22076. * @param node defines the node to remove
  22077. * @returns the current material
  22078. */
  22079. removeOutputNode(node: NodeMaterialBlock): this;
  22080. private _addVertexOutputNode;
  22081. private _removeVertexOutputNode;
  22082. private _addFragmentOutputNode;
  22083. private _removeFragmentOutputNode;
  22084. /**
  22085. * Specifies if the material will require alpha blending
  22086. * @returns a boolean specifying if alpha blending is needed
  22087. */
  22088. needAlphaBlending(): boolean;
  22089. /**
  22090. * Specifies if this material should be rendered in alpha test mode
  22091. * @returns a boolean specifying if an alpha test is needed.
  22092. */
  22093. needAlphaTesting(): boolean;
  22094. private _initializeBlock;
  22095. private _resetDualBlocks;
  22096. /**
  22097. * Remove a block from the current node material
  22098. * @param block defines the block to remove
  22099. */
  22100. removeBlock(block: NodeMaterialBlock): void;
  22101. /**
  22102. * Build the material and generates the inner effect
  22103. * @param verbose defines if the build should log activity
  22104. */
  22105. build(verbose?: boolean): void;
  22106. /**
  22107. * Runs an otpimization phase to try to improve the shader code
  22108. */
  22109. optimize(): void;
  22110. private _prepareDefinesForAttributes;
  22111. /**
  22112. * Create a post process from the material
  22113. * @param camera The camera to apply the render pass to.
  22114. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22116. * @param engine The engine which the post process will be applied. (default: current engine)
  22117. * @param reusable If the post process can be reused on the same frame. (default: false)
  22118. * @param textureType Type of textures used when performing the post process. (default: 0)
  22119. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22120. * @returns the post process created
  22121. */
  22122. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22123. /**
  22124. * Create the post process effect from the material
  22125. * @param postProcess The post process to create the effect for
  22126. */
  22127. createEffectForPostProcess(postProcess: PostProcess): void;
  22128. private _createEffectOrPostProcess;
  22129. private _createEffectForParticles;
  22130. /**
  22131. * Create the effect to be used as the custom effect for a particle system
  22132. * @param particleSystem Particle system to create the effect for
  22133. * @param onCompiled defines a function to call when the effect creation is successful
  22134. * @param onError defines a function to call when the effect creation has failed
  22135. */
  22136. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22137. private _processDefines;
  22138. /**
  22139. * Get if the submesh is ready to be used and all its information available.
  22140. * Child classes can use it to update shaders
  22141. * @param mesh defines the mesh to check
  22142. * @param subMesh defines which submesh to check
  22143. * @param useInstances specifies that instances should be used
  22144. * @returns a boolean indicating that the submesh is ready or not
  22145. */
  22146. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22147. /**
  22148. * Get a string representing the shaders built by the current node graph
  22149. */
  22150. get compiledShaders(): string;
  22151. /**
  22152. * Binds the world matrix to the material
  22153. * @param world defines the world transformation matrix
  22154. */
  22155. bindOnlyWorldMatrix(world: Matrix): void;
  22156. /**
  22157. * Binds the submesh to this material by preparing the effect and shader to draw
  22158. * @param world defines the world transformation matrix
  22159. * @param mesh defines the mesh containing the submesh
  22160. * @param subMesh defines the submesh to bind the material to
  22161. */
  22162. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22163. /**
  22164. * Gets the active textures from the material
  22165. * @returns an array of textures
  22166. */
  22167. getActiveTextures(): BaseTexture[];
  22168. /**
  22169. * Gets the list of texture blocks
  22170. * @returns an array of texture blocks
  22171. */
  22172. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22173. /**
  22174. * Specifies if the material uses a texture
  22175. * @param texture defines the texture to check against the material
  22176. * @returns a boolean specifying if the material uses the texture
  22177. */
  22178. hasTexture(texture: BaseTexture): boolean;
  22179. /**
  22180. * Disposes the material
  22181. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22182. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22183. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22184. */
  22185. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22186. /** Creates the node editor window. */
  22187. private _createNodeEditor;
  22188. /**
  22189. * Launch the node material editor
  22190. * @param config Define the configuration of the editor
  22191. * @return a promise fulfilled when the node editor is visible
  22192. */
  22193. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22194. /**
  22195. * Clear the current material
  22196. */
  22197. clear(): void;
  22198. /**
  22199. * Clear the current material and set it to a default state
  22200. */
  22201. setToDefault(): void;
  22202. /**
  22203. * Clear the current material and set it to a default state for post process
  22204. */
  22205. setToDefaultPostProcess(): void;
  22206. /**
  22207. * Clear the current material and set it to a default state for particle
  22208. */
  22209. setToDefaultParticle(): void;
  22210. /**
  22211. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22212. * @param url defines the url to load from
  22213. * @returns a promise that will fullfil when the material is fully loaded
  22214. */
  22215. loadAsync(url: string): Promise<void>;
  22216. private _gatherBlocks;
  22217. /**
  22218. * Generate a string containing the code declaration required to create an equivalent of this material
  22219. * @returns a string
  22220. */
  22221. generateCode(): string;
  22222. /**
  22223. * Serializes this material in a JSON representation
  22224. * @returns the serialized material object
  22225. */
  22226. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22227. private _restoreConnections;
  22228. /**
  22229. * Clear the current graph and load a new one from a serialization object
  22230. * @param source defines the JSON representation of the material
  22231. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22232. * @param merge defines whether or not the source must be merged or replace the current content
  22233. */
  22234. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22235. /**
  22236. * Makes a duplicate of the current material.
  22237. * @param name - name to use for the new material.
  22238. */
  22239. clone(name: string): NodeMaterial;
  22240. /**
  22241. * Creates a node material from parsed material data
  22242. * @param source defines the JSON representation of the material
  22243. * @param scene defines the hosting scene
  22244. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22245. * @returns a new node material
  22246. */
  22247. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22248. /**
  22249. * Creates a node material from a snippet saved in a remote file
  22250. * @param name defines the name of the material to create
  22251. * @param url defines the url to load from
  22252. * @param scene defines the hosting scene
  22253. * @returns a promise that will resolve to the new node material
  22254. */
  22255. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22256. /**
  22257. * Creates a node material from a snippet saved by the node material editor
  22258. * @param snippetId defines the snippet to load
  22259. * @param scene defines the hosting scene
  22260. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22261. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22262. * @returns a promise that will resolve to the new node material
  22263. */
  22264. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22265. /**
  22266. * Creates a new node material set to default basic configuration
  22267. * @param name defines the name of the material
  22268. * @param scene defines the hosting scene
  22269. * @returns a new NodeMaterial
  22270. */
  22271. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22272. }
  22273. }
  22274. declare module BABYLON {
  22275. /**
  22276. * Size options for a post process
  22277. */
  22278. export type PostProcessOptions = {
  22279. width: number;
  22280. height: number;
  22281. };
  22282. /**
  22283. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22284. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22285. */
  22286. export class PostProcess {
  22287. /** Name of the PostProcess. */
  22288. name: string;
  22289. /**
  22290. * Gets or sets the unique id of the post process
  22291. */
  22292. uniqueId: number;
  22293. /**
  22294. * Width of the texture to apply the post process on
  22295. */
  22296. width: number;
  22297. /**
  22298. * Height of the texture to apply the post process on
  22299. */
  22300. height: number;
  22301. /**
  22302. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22303. */
  22304. nodeMaterialSource: Nullable<NodeMaterial>;
  22305. /**
  22306. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22307. * @hidden
  22308. */
  22309. _outputTexture: Nullable<InternalTexture>;
  22310. /**
  22311. * Sampling mode used by the shader
  22312. * See https://doc.babylonjs.com/classes/3.1/texture
  22313. */
  22314. renderTargetSamplingMode: number;
  22315. /**
  22316. * Clear color to use when screen clearing
  22317. */
  22318. clearColor: Color4;
  22319. /**
  22320. * If the buffer needs to be cleared before applying the post process. (default: true)
  22321. * Should be set to false if shader will overwrite all previous pixels.
  22322. */
  22323. autoClear: boolean;
  22324. /**
  22325. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22326. */
  22327. alphaMode: number;
  22328. /**
  22329. * Sets the setAlphaBlendConstants of the babylon engine
  22330. */
  22331. alphaConstants: Color4;
  22332. /**
  22333. * Animations to be used for the post processing
  22334. */
  22335. animations: Animation[];
  22336. /**
  22337. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22338. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22339. */
  22340. enablePixelPerfectMode: boolean;
  22341. /**
  22342. * Force the postprocess to be applied without taking in account viewport
  22343. */
  22344. forceFullscreenViewport: boolean;
  22345. /**
  22346. * List of inspectable custom properties (used by the Inspector)
  22347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22348. */
  22349. inspectableCustomProperties: IInspectable[];
  22350. /**
  22351. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22352. *
  22353. * | Value | Type | Description |
  22354. * | ----- | ----------------------------------- | ----------- |
  22355. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22356. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22357. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22358. *
  22359. */
  22360. scaleMode: number;
  22361. /**
  22362. * Force textures to be a power of two (default: false)
  22363. */
  22364. alwaysForcePOT: boolean;
  22365. private _samples;
  22366. /**
  22367. * Number of sample textures (default: 1)
  22368. */
  22369. get samples(): number;
  22370. set samples(n: number);
  22371. /**
  22372. * Modify the scale of the post process to be the same as the viewport (default: false)
  22373. */
  22374. adaptScaleToCurrentViewport: boolean;
  22375. private _camera;
  22376. private _scene;
  22377. private _engine;
  22378. private _options;
  22379. private _reusable;
  22380. private _textureType;
  22381. private _textureFormat;
  22382. /**
  22383. * Smart array of input and output textures for the post process.
  22384. * @hidden
  22385. */
  22386. _textures: SmartArray<InternalTexture>;
  22387. /**
  22388. * The index in _textures that corresponds to the output texture.
  22389. * @hidden
  22390. */
  22391. _currentRenderTextureInd: number;
  22392. private _effect;
  22393. private _samplers;
  22394. private _fragmentUrl;
  22395. private _vertexUrl;
  22396. private _parameters;
  22397. private _scaleRatio;
  22398. protected _indexParameters: any;
  22399. private _shareOutputWithPostProcess;
  22400. private _texelSize;
  22401. private _forcedOutputTexture;
  22402. /**
  22403. * Returns the fragment url or shader name used in the post process.
  22404. * @returns the fragment url or name in the shader store.
  22405. */
  22406. getEffectName(): string;
  22407. /**
  22408. * An event triggered when the postprocess is activated.
  22409. */
  22410. onActivateObservable: Observable<Camera>;
  22411. private _onActivateObserver;
  22412. /**
  22413. * A function that is added to the onActivateObservable
  22414. */
  22415. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22416. /**
  22417. * An event triggered when the postprocess changes its size.
  22418. */
  22419. onSizeChangedObservable: Observable<PostProcess>;
  22420. private _onSizeChangedObserver;
  22421. /**
  22422. * A function that is added to the onSizeChangedObservable
  22423. */
  22424. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22425. /**
  22426. * An event triggered when the postprocess applies its effect.
  22427. */
  22428. onApplyObservable: Observable<Effect>;
  22429. private _onApplyObserver;
  22430. /**
  22431. * A function that is added to the onApplyObservable
  22432. */
  22433. set onApply(callback: (effect: Effect) => void);
  22434. /**
  22435. * An event triggered before rendering the postprocess
  22436. */
  22437. onBeforeRenderObservable: Observable<Effect>;
  22438. private _onBeforeRenderObserver;
  22439. /**
  22440. * A function that is added to the onBeforeRenderObservable
  22441. */
  22442. set onBeforeRender(callback: (effect: Effect) => void);
  22443. /**
  22444. * An event triggered after rendering the postprocess
  22445. */
  22446. onAfterRenderObservable: Observable<Effect>;
  22447. private _onAfterRenderObserver;
  22448. /**
  22449. * A function that is added to the onAfterRenderObservable
  22450. */
  22451. set onAfterRender(callback: (efect: Effect) => void);
  22452. /**
  22453. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  22454. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22455. */
  22456. get inputTexture(): InternalTexture;
  22457. set inputTexture(value: InternalTexture);
  22458. /**
  22459. * Gets the camera which post process is applied to.
  22460. * @returns The camera the post process is applied to.
  22461. */
  22462. getCamera(): Camera;
  22463. /**
  22464. * Gets the texel size of the postprocess.
  22465. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22466. */
  22467. get texelSize(): Vector2;
  22468. /**
  22469. * Creates a new instance PostProcess
  22470. * @param name The name of the PostProcess.
  22471. * @param fragmentUrl The url of the fragment shader to be used.
  22472. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22473. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22474. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22475. * @param camera The camera to apply the render pass to.
  22476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22477. * @param engine The engine which the post process will be applied. (default: current engine)
  22478. * @param reusable If the post process can be reused on the same frame. (default: false)
  22479. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22480. * @param textureType Type of textures used when performing the post process. (default: 0)
  22481. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22482. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  22483. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22484. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22485. */
  22486. constructor(
  22487. /** Name of the PostProcess. */
  22488. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  22489. /**
  22490. * Gets a string idenfifying the name of the class
  22491. * @returns "PostProcess" string
  22492. */
  22493. getClassName(): string;
  22494. /**
  22495. * Gets the engine which this post process belongs to.
  22496. * @returns The engine the post process was enabled with.
  22497. */
  22498. getEngine(): Engine;
  22499. /**
  22500. * The effect that is created when initializing the post process.
  22501. * @returns The created effect corresponding the the postprocess.
  22502. */
  22503. getEffect(): Effect;
  22504. /**
  22505. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22506. * @param postProcess The post process to share the output with.
  22507. * @returns This post process.
  22508. */
  22509. shareOutputWith(postProcess: PostProcess): PostProcess;
  22510. /**
  22511. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22512. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22513. */
  22514. useOwnOutput(): void;
  22515. /**
  22516. * Updates the effect with the current post process compile time values and recompiles the shader.
  22517. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22518. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22519. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22520. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  22521. * @param onCompiled Called when the shader has been compiled.
  22522. * @param onError Called if there is an error when compiling a shader.
  22523. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22524. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22525. */
  22526. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  22527. /**
  22528. * The post process is reusable if it can be used multiple times within one frame.
  22529. * @returns If the post process is reusable
  22530. */
  22531. isReusable(): boolean;
  22532. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22533. markTextureDirty(): void;
  22534. /**
  22535. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22536. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  22537. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22538. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22539. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22540. * @returns The target texture that was bound to be written to.
  22541. */
  22542. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22543. /**
  22544. * If the post process is supported.
  22545. */
  22546. get isSupported(): boolean;
  22547. /**
  22548. * The aspect ratio of the output texture.
  22549. */
  22550. get aspectRatio(): number;
  22551. /**
  22552. * Get a value indicating if the post-process is ready to be used
  22553. * @returns true if the post-process is ready (shader is compiled)
  22554. */
  22555. isReady(): boolean;
  22556. /**
  22557. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22558. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22559. */
  22560. apply(): Nullable<Effect>;
  22561. private _disposeTextures;
  22562. /**
  22563. * Disposes the post process.
  22564. * @param camera The camera to dispose the post process on.
  22565. */
  22566. dispose(camera?: Camera): void;
  22567. }
  22568. }
  22569. declare module BABYLON {
  22570. /** @hidden */
  22571. export var kernelBlurVaryingDeclaration: {
  22572. name: string;
  22573. shader: string;
  22574. };
  22575. }
  22576. declare module BABYLON {
  22577. /** @hidden */
  22578. export var kernelBlurFragment: {
  22579. name: string;
  22580. shader: string;
  22581. };
  22582. }
  22583. declare module BABYLON {
  22584. /** @hidden */
  22585. export var kernelBlurFragment2: {
  22586. name: string;
  22587. shader: string;
  22588. };
  22589. }
  22590. declare module BABYLON {
  22591. /** @hidden */
  22592. export var kernelBlurPixelShader: {
  22593. name: string;
  22594. shader: string;
  22595. };
  22596. }
  22597. declare module BABYLON {
  22598. /** @hidden */
  22599. export var kernelBlurVertex: {
  22600. name: string;
  22601. shader: string;
  22602. };
  22603. }
  22604. declare module BABYLON {
  22605. /** @hidden */
  22606. export var kernelBlurVertexShader: {
  22607. name: string;
  22608. shader: string;
  22609. };
  22610. }
  22611. declare module BABYLON {
  22612. /**
  22613. * The Blur Post Process which blurs an image based on a kernel and direction.
  22614. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22615. */
  22616. export class BlurPostProcess extends PostProcess {
  22617. /** The direction in which to blur the image. */
  22618. direction: Vector2;
  22619. private blockCompilation;
  22620. protected _kernel: number;
  22621. protected _idealKernel: number;
  22622. protected _packedFloat: boolean;
  22623. private _staticDefines;
  22624. /**
  22625. * Sets the length in pixels of the blur sample region
  22626. */
  22627. set kernel(v: number);
  22628. /**
  22629. * Gets the length in pixels of the blur sample region
  22630. */
  22631. get kernel(): number;
  22632. /**
  22633. * Sets wether or not the blur needs to unpack/repack floats
  22634. */
  22635. set packedFloat(v: boolean);
  22636. /**
  22637. * Gets wether or not the blur is unpacking/repacking floats
  22638. */
  22639. get packedFloat(): boolean;
  22640. /**
  22641. * Creates a new instance BlurPostProcess
  22642. * @param name The name of the effect.
  22643. * @param direction The direction in which to blur the image.
  22644. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  22645. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22646. * @param camera The camera to apply the render pass to.
  22647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22648. * @param engine The engine which the post process will be applied. (default: current engine)
  22649. * @param reusable If the post process can be reused on the same frame. (default: false)
  22650. * @param textureType Type of textures used when performing the post process. (default: 0)
  22651. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  22652. */
  22653. constructor(name: string,
  22654. /** The direction in which to blur the image. */
  22655. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22656. /**
  22657. * Updates the effect with the current post process compile time values and recompiles the shader.
  22658. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22659. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22660. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22661. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  22662. * @param onCompiled Called when the shader has been compiled.
  22663. * @param onError Called if there is an error when compiling a shader.
  22664. */
  22665. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22666. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22667. /**
  22668. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22669. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22670. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22671. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22672. * The gaps between physical kernels are compensated for in the weighting of the samples
  22673. * @param idealKernel Ideal blur kernel.
  22674. * @return Nearest best kernel.
  22675. */
  22676. protected _nearestBestKernel(idealKernel: number): number;
  22677. /**
  22678. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22679. * @param x The point on the Gaussian distribution to sample.
  22680. * @return the value of the Gaussian function at x.
  22681. */
  22682. protected _gaussianWeight(x: number): number;
  22683. /**
  22684. * Generates a string that can be used as a floating point number in GLSL.
  22685. * @param x Value to print.
  22686. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22687. * @return GLSL float string.
  22688. */
  22689. protected _glslFloat(x: number, decimalFigures?: number): string;
  22690. }
  22691. }
  22692. declare module BABYLON {
  22693. /**
  22694. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22695. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22696. * You can then easily use it as a reflectionTexture on a flat surface.
  22697. * In case the surface is not a plane, please consider relying on reflection probes.
  22698. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22699. */
  22700. export class MirrorTexture extends RenderTargetTexture {
  22701. private scene;
  22702. /**
  22703. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22704. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  22705. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22706. */
  22707. mirrorPlane: Plane;
  22708. /**
  22709. * Define the blur ratio used to blur the reflection if needed.
  22710. */
  22711. set blurRatio(value: number);
  22712. get blurRatio(): number;
  22713. /**
  22714. * Define the adaptive blur kernel used to blur the reflection if needed.
  22715. * This will autocompute the closest best match for the `blurKernel`
  22716. */
  22717. set adaptiveBlurKernel(value: number);
  22718. /**
  22719. * Define the blur kernel used to blur the reflection if needed.
  22720. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22721. */
  22722. set blurKernel(value: number);
  22723. /**
  22724. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22725. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22726. */
  22727. set blurKernelX(value: number);
  22728. get blurKernelX(): number;
  22729. /**
  22730. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22731. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22732. */
  22733. set blurKernelY(value: number);
  22734. get blurKernelY(): number;
  22735. private _autoComputeBlurKernel;
  22736. protected _onRatioRescale(): void;
  22737. private _updateGammaSpace;
  22738. private _imageProcessingConfigChangeObserver;
  22739. private _transformMatrix;
  22740. private _mirrorMatrix;
  22741. private _savedViewMatrix;
  22742. private _blurX;
  22743. private _blurY;
  22744. private _adaptiveBlurKernel;
  22745. private _blurKernelX;
  22746. private _blurKernelY;
  22747. private _blurRatio;
  22748. /**
  22749. * Instantiates a Mirror Texture.
  22750. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22751. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22752. * You can then easily use it as a reflectionTexture on a flat surface.
  22753. * In case the surface is not a plane, please consider relying on reflection probes.
  22754. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22755. * @param name
  22756. * @param size
  22757. * @param scene
  22758. * @param generateMipMaps
  22759. * @param type
  22760. * @param samplingMode
  22761. * @param generateDepthBuffer
  22762. */
  22763. constructor(name: string, size: number | {
  22764. width: number;
  22765. height: number;
  22766. } | {
  22767. ratio: number;
  22768. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22769. private _preparePostProcesses;
  22770. /**
  22771. * Clone the mirror texture.
  22772. * @returns the cloned texture
  22773. */
  22774. clone(): MirrorTexture;
  22775. /**
  22776. * Serialize the texture to a JSON representation you could use in Parse later on
  22777. * @returns the serialized JSON representation
  22778. */
  22779. serialize(): any;
  22780. /**
  22781. * Dispose the texture and release its associated resources.
  22782. */
  22783. dispose(): void;
  22784. }
  22785. }
  22786. declare module BABYLON {
  22787. /**
  22788. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22789. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22790. */
  22791. export class Texture extends BaseTexture {
  22792. /**
  22793. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22794. */
  22795. static SerializeBuffers: boolean;
  22796. /** @hidden */
  22797. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22798. /** @hidden */
  22799. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22800. /** @hidden */
  22801. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22802. /** nearest is mag = nearest and min = nearest and mip = linear */
  22803. static readonly NEAREST_SAMPLINGMODE: number;
  22804. /** nearest is mag = nearest and min = nearest and mip = linear */
  22805. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22806. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22807. static readonly BILINEAR_SAMPLINGMODE: number;
  22808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22809. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22810. /** Trilinear is mag = linear and min = linear and mip = linear */
  22811. static readonly TRILINEAR_SAMPLINGMODE: number;
  22812. /** Trilinear is mag = linear and min = linear and mip = linear */
  22813. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22814. /** mag = nearest and min = nearest and mip = nearest */
  22815. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22816. /** mag = nearest and min = linear and mip = nearest */
  22817. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22818. /** mag = nearest and min = linear and mip = linear */
  22819. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22820. /** mag = nearest and min = linear and mip = none */
  22821. static readonly NEAREST_LINEAR: number;
  22822. /** mag = nearest and min = nearest and mip = none */
  22823. static readonly NEAREST_NEAREST: number;
  22824. /** mag = linear and min = nearest and mip = nearest */
  22825. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22826. /** mag = linear and min = nearest and mip = linear */
  22827. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22828. /** mag = linear and min = linear and mip = none */
  22829. static readonly LINEAR_LINEAR: number;
  22830. /** mag = linear and min = nearest and mip = none */
  22831. static readonly LINEAR_NEAREST: number;
  22832. /** Explicit coordinates mode */
  22833. static readonly EXPLICIT_MODE: number;
  22834. /** Spherical coordinates mode */
  22835. static readonly SPHERICAL_MODE: number;
  22836. /** Planar coordinates mode */
  22837. static readonly PLANAR_MODE: number;
  22838. /** Cubic coordinates mode */
  22839. static readonly CUBIC_MODE: number;
  22840. /** Projection coordinates mode */
  22841. static readonly PROJECTION_MODE: number;
  22842. /** Inverse Cubic coordinates mode */
  22843. static readonly SKYBOX_MODE: number;
  22844. /** Inverse Cubic coordinates mode */
  22845. static readonly INVCUBIC_MODE: number;
  22846. /** Equirectangular coordinates mode */
  22847. static readonly EQUIRECTANGULAR_MODE: number;
  22848. /** Equirectangular Fixed coordinates mode */
  22849. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22850. /** Equirectangular Fixed Mirrored coordinates mode */
  22851. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22852. /** Texture is not repeating outside of 0..1 UVs */
  22853. static readonly CLAMP_ADDRESSMODE: number;
  22854. /** Texture is repeating outside of 0..1 UVs */
  22855. static readonly WRAP_ADDRESSMODE: number;
  22856. /** Texture is repeating and mirrored */
  22857. static readonly MIRROR_ADDRESSMODE: number;
  22858. /**
  22859. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  22860. */
  22861. static UseSerializedUrlIfAny: boolean;
  22862. /**
  22863. * Define the url of the texture.
  22864. */
  22865. url: Nullable<string>;
  22866. /**
  22867. * Define an offset on the texture to offset the u coordinates of the UVs
  22868. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22869. */
  22870. uOffset: number;
  22871. /**
  22872. * Define an offset on the texture to offset the v coordinates of the UVs
  22873. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22874. */
  22875. vOffset: number;
  22876. /**
  22877. * Define an offset on the texture to scale the u coordinates of the UVs
  22878. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22879. */
  22880. uScale: number;
  22881. /**
  22882. * Define an offset on the texture to scale the v coordinates of the UVs
  22883. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22884. */
  22885. vScale: number;
  22886. /**
  22887. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22888. * @see http://doc.babylonjs.com/how_to/more_materials
  22889. */
  22890. uAng: number;
  22891. /**
  22892. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22893. * @see http://doc.babylonjs.com/how_to/more_materials
  22894. */
  22895. vAng: number;
  22896. /**
  22897. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22898. * @see http://doc.babylonjs.com/how_to/more_materials
  22899. */
  22900. wAng: number;
  22901. /**
  22902. * Defines the center of rotation (U)
  22903. */
  22904. uRotationCenter: number;
  22905. /**
  22906. * Defines the center of rotation (V)
  22907. */
  22908. vRotationCenter: number;
  22909. /**
  22910. * Defines the center of rotation (W)
  22911. */
  22912. wRotationCenter: number;
  22913. /**
  22914. * Are mip maps generated for this texture or not.
  22915. */
  22916. get noMipmap(): boolean;
  22917. /**
  22918. * List of inspectable custom properties (used by the Inspector)
  22919. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22920. */
  22921. inspectableCustomProperties: Nullable<IInspectable[]>;
  22922. private _noMipmap;
  22923. /** @hidden */
  22924. _invertY: boolean;
  22925. private _rowGenerationMatrix;
  22926. private _cachedTextureMatrix;
  22927. private _projectionModeMatrix;
  22928. private _t0;
  22929. private _t1;
  22930. private _t2;
  22931. private _cachedUOffset;
  22932. private _cachedVOffset;
  22933. private _cachedUScale;
  22934. private _cachedVScale;
  22935. private _cachedUAng;
  22936. private _cachedVAng;
  22937. private _cachedWAng;
  22938. private _cachedProjectionMatrixId;
  22939. private _cachedCoordinatesMode;
  22940. /** @hidden */
  22941. protected _initialSamplingMode: number;
  22942. /** @hidden */
  22943. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  22944. private _deleteBuffer;
  22945. protected _format: Nullable<number>;
  22946. private _delayedOnLoad;
  22947. private _delayedOnError;
  22948. private _mimeType?;
  22949. /**
  22950. * Observable triggered once the texture has been loaded.
  22951. */
  22952. onLoadObservable: Observable<Texture>;
  22953. protected _isBlocking: boolean;
  22954. /**
  22955. * Is the texture preventing material to render while loading.
  22956. * If false, a default texture will be used instead of the loading one during the preparation step.
  22957. */
  22958. set isBlocking(value: boolean);
  22959. get isBlocking(): boolean;
  22960. /**
  22961. * Get the current sampling mode associated with the texture.
  22962. */
  22963. get samplingMode(): number;
  22964. /**
  22965. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  22966. */
  22967. get invertY(): boolean;
  22968. /**
  22969. * Instantiates a new texture.
  22970. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22971. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22972. * @param url defines the url of the picture to load as a texture
  22973. * @param sceneOrEngine defines the scene or engine the texture will belong to
  22974. * @param noMipmap defines if the texture will require mip maps or not
  22975. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  22976. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  22977. * @param onLoad defines a callback triggered when the texture has been loaded
  22978. * @param onError defines a callback triggered when an error occurred during the loading session
  22979. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  22980. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  22981. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  22982. * @param mimeType defines an optional mime type information
  22983. */
  22984. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  22985. /**
  22986. * Update the url (and optional buffer) of this texture if url was null during construction.
  22987. * @param url the url of the texture
  22988. * @param buffer the buffer of the texture (defaults to null)
  22989. * @param onLoad callback called when the texture is loaded (defaults to null)
  22990. */
  22991. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  22992. /**
  22993. * Finish the loading sequence of a texture flagged as delayed load.
  22994. * @hidden
  22995. */
  22996. delayLoad(): void;
  22997. private _prepareRowForTextureGeneration;
  22998. /**
  22999. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23000. * @returns the transform matrix of the texture.
  23001. */
  23002. getTextureMatrix(uBase?: number): Matrix;
  23003. /**
  23004. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23005. * @returns The reflection texture transform
  23006. */
  23007. getReflectionTextureMatrix(): Matrix;
  23008. /**
  23009. * Clones the texture.
  23010. * @returns the cloned texture
  23011. */
  23012. clone(): Texture;
  23013. /**
  23014. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23015. * @returns The JSON representation of the texture
  23016. */
  23017. serialize(): any;
  23018. /**
  23019. * Get the current class name of the texture useful for serialization or dynamic coding.
  23020. * @returns "Texture"
  23021. */
  23022. getClassName(): string;
  23023. /**
  23024. * Dispose the texture and release its associated resources.
  23025. */
  23026. dispose(): void;
  23027. /**
  23028. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23029. * @param parsedTexture Define the JSON representation of the texture
  23030. * @param scene Define the scene the parsed texture should be instantiated in
  23031. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23032. * @returns The parsed texture if successful
  23033. */
  23034. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23035. /**
  23036. * Creates a texture from its base 64 representation.
  23037. * @param data Define the base64 payload without the data: prefix
  23038. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23039. * @param scene Define the scene the texture should belong to
  23040. * @param noMipmap Forces the texture to not create mip map information if true
  23041. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23042. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23043. * @param onLoad define a callback triggered when the texture has been loaded
  23044. * @param onError define a callback triggered when an error occurred during the loading session
  23045. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23046. * @returns the created texture
  23047. */
  23048. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23049. /**
  23050. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23051. * @param data Define the base64 payload without the data: prefix
  23052. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23053. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23054. * @param scene Define the scene the texture should belong to
  23055. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23056. * @param noMipmap Forces the texture to not create mip map information if true
  23057. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23058. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23059. * @param onLoad define a callback triggered when the texture has been loaded
  23060. * @param onError define a callback triggered when an error occurred during the loading session
  23061. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23062. * @returns the created texture
  23063. */
  23064. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  23065. }
  23066. }
  23067. declare module BABYLON {
  23068. /**
  23069. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23070. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23071. */
  23072. export class PostProcessManager {
  23073. private _scene;
  23074. private _indexBuffer;
  23075. private _vertexBuffers;
  23076. /**
  23077. * Creates a new instance PostProcess
  23078. * @param scene The scene that the post process is associated with.
  23079. */
  23080. constructor(scene: Scene);
  23081. private _prepareBuffers;
  23082. private _buildIndexBuffer;
  23083. /**
  23084. * Rebuilds the vertex buffers of the manager.
  23085. * @hidden
  23086. */
  23087. _rebuild(): void;
  23088. /**
  23089. * Prepares a frame to be run through a post process.
  23090. * @param sourceTexture The input texture to the post procesess. (default: null)
  23091. * @param postProcesses An array of post processes to be run. (default: null)
  23092. * @returns True if the post processes were able to be run.
  23093. * @hidden
  23094. */
  23095. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23096. /**
  23097. * Manually render a set of post processes to a texture.
  23098. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23099. * @param postProcesses An array of post processes to be run.
  23100. * @param targetTexture The target texture to render to.
  23101. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23102. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23103. * @param lodLevel defines which lod of the texture to render to
  23104. */
  23105. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23106. /**
  23107. * Finalize the result of the output of the postprocesses.
  23108. * @param doNotPresent If true the result will not be displayed to the screen.
  23109. * @param targetTexture The target texture to render to.
  23110. * @param faceIndex The index of the face to bind the target texture to.
  23111. * @param postProcesses The array of post processes to render.
  23112. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23113. * @hidden
  23114. */
  23115. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23116. /**
  23117. * Disposes of the post process manager.
  23118. */
  23119. dispose(): void;
  23120. }
  23121. }
  23122. declare module BABYLON {
  23123. /**
  23124. * This Helps creating a texture that will be created from a camera in your scene.
  23125. * It is basically a dynamic texture that could be used to create special effects for instance.
  23126. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23127. */
  23128. export class RenderTargetTexture extends Texture {
  23129. isCube: boolean;
  23130. /**
  23131. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23132. */
  23133. static readonly REFRESHRATE_RENDER_ONCE: number;
  23134. /**
  23135. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23136. */
  23137. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23138. /**
  23139. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23140. * the central point of your effect and can save a lot of performances.
  23141. */
  23142. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23143. /**
  23144. * Use this predicate to dynamically define the list of mesh you want to render.
  23145. * If set, the renderList property will be overwritten.
  23146. */
  23147. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23148. private _renderList;
  23149. /**
  23150. * Use this list to define the list of mesh you want to render.
  23151. */
  23152. get renderList(): Nullable<Array<AbstractMesh>>;
  23153. set renderList(value: Nullable<Array<AbstractMesh>>);
  23154. /**
  23155. * Use this function to overload the renderList array at rendering time.
  23156. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23157. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23158. * the cube (if the RTT is a cube, else layerOrFace=0).
  23159. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23160. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23161. * hold dummy elements!
  23162. */
  23163. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23164. private _hookArray;
  23165. /**
  23166. * Define if particles should be rendered in your texture.
  23167. */
  23168. renderParticles: boolean;
  23169. /**
  23170. * Define if sprites should be rendered in your texture.
  23171. */
  23172. renderSprites: boolean;
  23173. /**
  23174. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23175. */
  23176. coordinatesMode: number;
  23177. /**
  23178. * Define the camera used to render the texture.
  23179. */
  23180. activeCamera: Nullable<Camera>;
  23181. /**
  23182. * Override the mesh isReady function with your own one.
  23183. */
  23184. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23185. /**
  23186. * Override the render function of the texture with your own one.
  23187. */
  23188. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23189. /**
  23190. * Define if camera post processes should be use while rendering the texture.
  23191. */
  23192. useCameraPostProcesses: boolean;
  23193. /**
  23194. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23195. */
  23196. ignoreCameraViewport: boolean;
  23197. private _postProcessManager;
  23198. private _postProcesses;
  23199. private _resizeObserver;
  23200. /**
  23201. * An event triggered when the texture is unbind.
  23202. */
  23203. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23204. /**
  23205. * An event triggered when the texture is unbind.
  23206. */
  23207. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23208. private _onAfterUnbindObserver;
  23209. /**
  23210. * Set a after unbind callback in the texture.
  23211. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23212. */
  23213. set onAfterUnbind(callback: () => void);
  23214. /**
  23215. * An event triggered before rendering the texture
  23216. */
  23217. onBeforeRenderObservable: Observable<number>;
  23218. private _onBeforeRenderObserver;
  23219. /**
  23220. * Set a before render callback in the texture.
  23221. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23222. */
  23223. set onBeforeRender(callback: (faceIndex: number) => void);
  23224. /**
  23225. * An event triggered after rendering the texture
  23226. */
  23227. onAfterRenderObservable: Observable<number>;
  23228. private _onAfterRenderObserver;
  23229. /**
  23230. * Set a after render callback in the texture.
  23231. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23232. */
  23233. set onAfterRender(callback: (faceIndex: number) => void);
  23234. /**
  23235. * An event triggered after the texture clear
  23236. */
  23237. onClearObservable: Observable<Engine>;
  23238. private _onClearObserver;
  23239. /**
  23240. * Set a clear callback in the texture.
  23241. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23242. */
  23243. set onClear(callback: (Engine: Engine) => void);
  23244. /**
  23245. * An event triggered when the texture is resized.
  23246. */
  23247. onResizeObservable: Observable<RenderTargetTexture>;
  23248. /**
  23249. * Define the clear color of the Render Target if it should be different from the scene.
  23250. */
  23251. clearColor: Color4;
  23252. protected _size: number | {
  23253. width: number;
  23254. height: number;
  23255. layers?: number;
  23256. };
  23257. protected _initialSizeParameter: number | {
  23258. width: number;
  23259. height: number;
  23260. } | {
  23261. ratio: number;
  23262. };
  23263. protected _sizeRatio: Nullable<number>;
  23264. /** @hidden */
  23265. _generateMipMaps: boolean;
  23266. protected _renderingManager: RenderingManager;
  23267. /** @hidden */
  23268. _waitingRenderList: string[];
  23269. protected _doNotChangeAspectRatio: boolean;
  23270. protected _currentRefreshId: number;
  23271. protected _refreshRate: number;
  23272. protected _textureMatrix: Matrix;
  23273. protected _samples: number;
  23274. protected _renderTargetOptions: RenderTargetCreationOptions;
  23275. /**
  23276. * Gets render target creation options that were used.
  23277. */
  23278. get renderTargetOptions(): RenderTargetCreationOptions;
  23279. protected _onRatioRescale(): void;
  23280. /**
  23281. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23282. * It must define where the camera used to render the texture is set
  23283. */
  23284. boundingBoxPosition: Vector3;
  23285. private _boundingBoxSize;
  23286. /**
  23287. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23288. * When defined, the cubemap will switch to local mode
  23289. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23290. * @example https://www.babylonjs-playground.com/#RNASML
  23291. */
  23292. set boundingBoxSize(value: Vector3);
  23293. get boundingBoxSize(): Vector3;
  23294. /**
  23295. * In case the RTT has been created with a depth texture, get the associated
  23296. * depth texture.
  23297. * Otherwise, return null.
  23298. */
  23299. get depthStencilTexture(): Nullable<InternalTexture>;
  23300. /**
  23301. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23302. * or used a shadow, depth texture...
  23303. * @param name The friendly name of the texture
  23304. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  23305. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23306. * @param generateMipMaps True if mip maps need to be generated after render.
  23307. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23308. * @param type The type of the buffer in the RTT (int, half float, float...)
  23309. * @param isCube True if a cube texture needs to be created
  23310. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23311. * @param generateDepthBuffer True to generate a depth buffer
  23312. * @param generateStencilBuffer True to generate a stencil buffer
  23313. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23314. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23315. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23316. */
  23317. constructor(name: string, size: number | {
  23318. width: number;
  23319. height: number;
  23320. layers?: number;
  23321. } | {
  23322. ratio: number;
  23323. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23324. /**
  23325. * Creates a depth stencil texture.
  23326. * This is only available in WebGL 2 or with the depth texture extension available.
  23327. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23328. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23329. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23330. */
  23331. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23332. private _processSizeParameter;
  23333. /**
  23334. * Define the number of samples to use in case of MSAA.
  23335. * It defaults to one meaning no MSAA has been enabled.
  23336. */
  23337. get samples(): number;
  23338. set samples(value: number);
  23339. /**
  23340. * Resets the refresh counter of the texture and start bak from scratch.
  23341. * Could be useful to regenerate the texture if it is setup to render only once.
  23342. */
  23343. resetRefreshCounter(): void;
  23344. /**
  23345. * Define the refresh rate of the texture or the rendering frequency.
  23346. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23347. */
  23348. get refreshRate(): number;
  23349. set refreshRate(value: number);
  23350. /**
  23351. * Adds a post process to the render target rendering passes.
  23352. * @param postProcess define the post process to add
  23353. */
  23354. addPostProcess(postProcess: PostProcess): void;
  23355. /**
  23356. * Clear all the post processes attached to the render target
  23357. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23358. */
  23359. clearPostProcesses(dispose?: boolean): void;
  23360. /**
  23361. * Remove one of the post process from the list of attached post processes to the texture
  23362. * @param postProcess define the post process to remove from the list
  23363. */
  23364. removePostProcess(postProcess: PostProcess): void;
  23365. /** @hidden */
  23366. _shouldRender(): boolean;
  23367. /**
  23368. * Gets the actual render size of the texture.
  23369. * @returns the width of the render size
  23370. */
  23371. getRenderSize(): number;
  23372. /**
  23373. * Gets the actual render width of the texture.
  23374. * @returns the width of the render size
  23375. */
  23376. getRenderWidth(): number;
  23377. /**
  23378. * Gets the actual render height of the texture.
  23379. * @returns the height of the render size
  23380. */
  23381. getRenderHeight(): number;
  23382. /**
  23383. * Gets the actual number of layers of the texture.
  23384. * @returns the number of layers
  23385. */
  23386. getRenderLayers(): number;
  23387. /**
  23388. * Get if the texture can be rescaled or not.
  23389. */
  23390. get canRescale(): boolean;
  23391. /**
  23392. * Resize the texture using a ratio.
  23393. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23394. */
  23395. scale(ratio: number): void;
  23396. /**
  23397. * Get the texture reflection matrix used to rotate/transform the reflection.
  23398. * @returns the reflection matrix
  23399. */
  23400. getReflectionTextureMatrix(): Matrix;
  23401. /**
  23402. * Resize the texture to a new desired size.
  23403. * Be carrefull as it will recreate all the data in the new texture.
  23404. * @param size Define the new size. It can be:
  23405. * - a number for squared texture,
  23406. * - an object containing { width: number, height: number }
  23407. * - or an object containing a ratio { ratio: number }
  23408. */
  23409. resize(size: number | {
  23410. width: number;
  23411. height: number;
  23412. } | {
  23413. ratio: number;
  23414. }): void;
  23415. private _defaultRenderListPrepared;
  23416. /**
  23417. * Renders all the objects from the render list into the texture.
  23418. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23419. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23420. */
  23421. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23422. private _bestReflectionRenderTargetDimension;
  23423. private _prepareRenderingManager;
  23424. /**
  23425. * @hidden
  23426. * @param faceIndex face index to bind to if this is a cubetexture
  23427. * @param layer defines the index of the texture to bind in the array
  23428. */
  23429. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23430. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23431. private renderToTarget;
  23432. /**
  23433. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23434. * This allowed control for front to back rendering or reversly depending of the special needs.
  23435. *
  23436. * @param renderingGroupId The rendering group id corresponding to its index
  23437. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23438. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23439. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23440. */
  23441. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  23442. /**
  23443. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23444. *
  23445. * @param renderingGroupId The rendering group id corresponding to its index
  23446. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23447. */
  23448. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23449. /**
  23450. * Clones the texture.
  23451. * @returns the cloned texture
  23452. */
  23453. clone(): RenderTargetTexture;
  23454. /**
  23455. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23456. * @returns The JSON representation of the texture
  23457. */
  23458. serialize(): any;
  23459. /**
  23460. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23461. */
  23462. disposeFramebufferObjects(): void;
  23463. /**
  23464. * Dispose the texture and release its associated resources.
  23465. */
  23466. dispose(): void;
  23467. /** @hidden */
  23468. _rebuild(): void;
  23469. /**
  23470. * Clear the info related to rendering groups preventing retention point in material dispose.
  23471. */
  23472. freeRenderingGroups(): void;
  23473. /**
  23474. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23475. * @returns the view count
  23476. */
  23477. getViewCount(): number;
  23478. }
  23479. }
  23480. declare module BABYLON {
  23481. /**
  23482. * Class used to manipulate GUIDs
  23483. */
  23484. export class GUID {
  23485. /**
  23486. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23487. * Be aware Math.random() could cause collisions, but:
  23488. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  23489. * @returns a pseudo random id
  23490. */
  23491. static RandomId(): string;
  23492. }
  23493. }
  23494. declare module BABYLON {
  23495. /**
  23496. * Options to be used when creating a shadow depth material
  23497. */
  23498. export interface IIOptionShadowDepthMaterial {
  23499. /** Variables in the vertex shader code that need to have their names remapped.
  23500. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23501. * "var_name" should be either: worldPos or vNormalW
  23502. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23503. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23504. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23505. */
  23506. remappedVariables?: string[];
  23507. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23508. standalone?: boolean;
  23509. }
  23510. /**
  23511. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23512. */
  23513. export class ShadowDepthWrapper {
  23514. private _scene;
  23515. private _options?;
  23516. private _baseMaterial;
  23517. private _onEffectCreatedObserver;
  23518. private _subMeshToEffect;
  23519. private _subMeshToDepthEffect;
  23520. private _meshes;
  23521. /** @hidden */
  23522. _matriceNames: any;
  23523. /** Gets the standalone status of the wrapper */
  23524. get standalone(): boolean;
  23525. /** Gets the base material the wrapper is built upon */
  23526. get baseMaterial(): Material;
  23527. /**
  23528. * Instantiate a new shadow depth wrapper.
  23529. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23530. * generate the shadow depth map. For more information, please refer to the documentation:
  23531. * https://doc.babylonjs.com/babylon101/shadows
  23532. * @param baseMaterial Material to wrap
  23533. * @param scene Define the scene the material belongs to
  23534. * @param options Options used to create the wrapper
  23535. */
  23536. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23537. /**
  23538. * Gets the effect to use to generate the depth map
  23539. * @param subMesh subMesh to get the effect for
  23540. * @param shadowGenerator shadow generator to get the effect for
  23541. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23542. */
  23543. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23544. /**
  23545. * Specifies that the submesh is ready to be used for depth rendering
  23546. * @param subMesh submesh to check
  23547. * @param defines the list of defines to take into account when checking the effect
  23548. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23549. * @param useInstances specifies that instances should be used
  23550. * @returns a boolean indicating that the submesh is ready or not
  23551. */
  23552. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23553. /**
  23554. * Disposes the resources
  23555. */
  23556. dispose(): void;
  23557. private _makeEffect;
  23558. }
  23559. }
  23560. declare module BABYLON {
  23561. /**
  23562. * Options for compiling materials.
  23563. */
  23564. export interface IMaterialCompilationOptions {
  23565. /**
  23566. * Defines whether clip planes are enabled.
  23567. */
  23568. clipPlane: boolean;
  23569. /**
  23570. * Defines whether instances are enabled.
  23571. */
  23572. useInstances: boolean;
  23573. }
  23574. /**
  23575. * Options passed when calling customShaderNameResolve
  23576. */
  23577. export interface ICustomShaderNameResolveOptions {
  23578. /**
  23579. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  23580. */
  23581. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23582. }
  23583. /**
  23584. * Base class for the main features of a material in Babylon.js
  23585. */
  23586. export class Material implements IAnimatable {
  23587. /**
  23588. * Returns the triangle fill mode
  23589. */
  23590. static readonly TriangleFillMode: number;
  23591. /**
  23592. * Returns the wireframe mode
  23593. */
  23594. static readonly WireFrameFillMode: number;
  23595. /**
  23596. * Returns the point fill mode
  23597. */
  23598. static readonly PointFillMode: number;
  23599. /**
  23600. * Returns the point list draw mode
  23601. */
  23602. static readonly PointListDrawMode: number;
  23603. /**
  23604. * Returns the line list draw mode
  23605. */
  23606. static readonly LineListDrawMode: number;
  23607. /**
  23608. * Returns the line loop draw mode
  23609. */
  23610. static readonly LineLoopDrawMode: number;
  23611. /**
  23612. * Returns the line strip draw mode
  23613. */
  23614. static readonly LineStripDrawMode: number;
  23615. /**
  23616. * Returns the triangle strip draw mode
  23617. */
  23618. static readonly TriangleStripDrawMode: number;
  23619. /**
  23620. * Returns the triangle fan draw mode
  23621. */
  23622. static readonly TriangleFanDrawMode: number;
  23623. /**
  23624. * Stores the clock-wise side orientation
  23625. */
  23626. static readonly ClockWiseSideOrientation: number;
  23627. /**
  23628. * Stores the counter clock-wise side orientation
  23629. */
  23630. static readonly CounterClockWiseSideOrientation: number;
  23631. /**
  23632. * The dirty texture flag value
  23633. */
  23634. static readonly TextureDirtyFlag: number;
  23635. /**
  23636. * The dirty light flag value
  23637. */
  23638. static readonly LightDirtyFlag: number;
  23639. /**
  23640. * The dirty fresnel flag value
  23641. */
  23642. static readonly FresnelDirtyFlag: number;
  23643. /**
  23644. * The dirty attribute flag value
  23645. */
  23646. static readonly AttributesDirtyFlag: number;
  23647. /**
  23648. * The dirty misc flag value
  23649. */
  23650. static readonly MiscDirtyFlag: number;
  23651. /**
  23652. * The all dirty flag value
  23653. */
  23654. static readonly AllDirtyFlag: number;
  23655. /**
  23656. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23657. */
  23658. static readonly MATERIAL_OPAQUE: number;
  23659. /**
  23660. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23661. */
  23662. static readonly MATERIAL_ALPHATEST: number;
  23663. /**
  23664. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23665. */
  23666. static readonly MATERIAL_ALPHABLEND: number;
  23667. /**
  23668. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23669. * They are also discarded below the alpha cutoff threshold to improve performances.
  23670. */
  23671. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23672. /**
  23673. * The Whiteout method is used to blend normals.
  23674. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23675. */
  23676. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  23677. /**
  23678. * The Reoriented Normal Mapping method is used to blend normals.
  23679. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23680. */
  23681. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  23682. /**
  23683. * Custom callback helping to override the default shader used in the material.
  23684. */
  23685. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23686. /**
  23687. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23688. */
  23689. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23690. /**
  23691. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23692. * This means that the material can keep using a previous shader while a new one is being compiled.
  23693. * This is mostly used when shader parallel compilation is supported (true by default)
  23694. */
  23695. allowShaderHotSwapping: boolean;
  23696. /**
  23697. * The ID of the material
  23698. */
  23699. id: string;
  23700. /**
  23701. * Gets or sets the unique id of the material
  23702. */
  23703. uniqueId: number;
  23704. /**
  23705. * The name of the material
  23706. */
  23707. name: string;
  23708. /**
  23709. * Gets or sets user defined metadata
  23710. */
  23711. metadata: any;
  23712. /**
  23713. * For internal use only. Please do not use.
  23714. */
  23715. reservedDataStore: any;
  23716. /**
  23717. * Specifies if the ready state should be checked on each call
  23718. */
  23719. checkReadyOnEveryCall: boolean;
  23720. /**
  23721. * Specifies if the ready state should be checked once
  23722. */
  23723. checkReadyOnlyOnce: boolean;
  23724. /**
  23725. * The state of the material
  23726. */
  23727. state: string;
  23728. /**
  23729. * The alpha value of the material
  23730. */
  23731. protected _alpha: number;
  23732. /**
  23733. * List of inspectable custom properties (used by the Inspector)
  23734. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23735. */
  23736. inspectableCustomProperties: IInspectable[];
  23737. /**
  23738. * Sets the alpha value of the material
  23739. */
  23740. set alpha(value: number);
  23741. /**
  23742. * Gets the alpha value of the material
  23743. */
  23744. get alpha(): number;
  23745. /**
  23746. * Specifies if back face culling is enabled
  23747. */
  23748. protected _backFaceCulling: boolean;
  23749. /**
  23750. * Sets the back-face culling state
  23751. */
  23752. set backFaceCulling(value: boolean);
  23753. /**
  23754. * Gets the back-face culling state
  23755. */
  23756. get backFaceCulling(): boolean;
  23757. /**
  23758. * Stores the value for side orientation
  23759. */
  23760. sideOrientation: number;
  23761. /**
  23762. * Callback triggered when the material is compiled
  23763. */
  23764. onCompiled: Nullable<(effect: Effect) => void>;
  23765. /**
  23766. * Callback triggered when an error occurs
  23767. */
  23768. onError: Nullable<(effect: Effect, errors: string) => void>;
  23769. /**
  23770. * Callback triggered to get the render target textures
  23771. */
  23772. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23773. /**
  23774. * Gets a boolean indicating that current material needs to register RTT
  23775. */
  23776. get hasRenderTargetTextures(): boolean;
  23777. /**
  23778. * Specifies if the material should be serialized
  23779. */
  23780. doNotSerialize: boolean;
  23781. /**
  23782. * @hidden
  23783. */
  23784. _storeEffectOnSubMeshes: boolean;
  23785. /**
  23786. * Stores the animations for the material
  23787. */
  23788. animations: Nullable<Array<Animation>>;
  23789. /**
  23790. * An event triggered when the material is disposed
  23791. */
  23792. onDisposeObservable: Observable<Material>;
  23793. /**
  23794. * An observer which watches for dispose events
  23795. */
  23796. private _onDisposeObserver;
  23797. private _onUnBindObservable;
  23798. /**
  23799. * Called during a dispose event
  23800. */
  23801. set onDispose(callback: () => void);
  23802. private _onBindObservable;
  23803. /**
  23804. * An event triggered when the material is bound
  23805. */
  23806. get onBindObservable(): Observable<AbstractMesh>;
  23807. /**
  23808. * An observer which watches for bind events
  23809. */
  23810. private _onBindObserver;
  23811. /**
  23812. * Called during a bind event
  23813. */
  23814. set onBind(callback: (Mesh: AbstractMesh) => void);
  23815. /**
  23816. * An event triggered when the material is unbound
  23817. */
  23818. get onUnBindObservable(): Observable<Material>;
  23819. protected _onEffectCreatedObservable: Nullable<Observable<{
  23820. effect: Effect;
  23821. subMesh: Nullable<SubMesh>;
  23822. }>>;
  23823. /**
  23824. * An event triggered when the effect is (re)created
  23825. */
  23826. get onEffectCreatedObservable(): Observable<{
  23827. effect: Effect;
  23828. subMesh: Nullable<SubMesh>;
  23829. }>;
  23830. /**
  23831. * Stores the value of the alpha mode
  23832. */
  23833. private _alphaMode;
  23834. /**
  23835. * Sets the value of the alpha mode.
  23836. *
  23837. * | Value | Type | Description |
  23838. * | --- | --- | --- |
  23839. * | 0 | ALPHA_DISABLE | |
  23840. * | 1 | ALPHA_ADD | |
  23841. * | 2 | ALPHA_COMBINE | |
  23842. * | 3 | ALPHA_SUBTRACT | |
  23843. * | 4 | ALPHA_MULTIPLY | |
  23844. * | 5 | ALPHA_MAXIMIZED | |
  23845. * | 6 | ALPHA_ONEONE | |
  23846. * | 7 | ALPHA_PREMULTIPLIED | |
  23847. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23848. * | 9 | ALPHA_INTERPOLATE | |
  23849. * | 10 | ALPHA_SCREENMODE | |
  23850. *
  23851. */
  23852. set alphaMode(value: number);
  23853. /**
  23854. * Gets the value of the alpha mode
  23855. */
  23856. get alphaMode(): number;
  23857. /**
  23858. * Stores the state of the need depth pre-pass value
  23859. */
  23860. private _needDepthPrePass;
  23861. /**
  23862. * Sets the need depth pre-pass value
  23863. */
  23864. set needDepthPrePass(value: boolean);
  23865. /**
  23866. * Gets the depth pre-pass value
  23867. */
  23868. get needDepthPrePass(): boolean;
  23869. /**
  23870. * Specifies if depth writing should be disabled
  23871. */
  23872. disableDepthWrite: boolean;
  23873. /**
  23874. * Specifies if color writing should be disabled
  23875. */
  23876. disableColorWrite: boolean;
  23877. /**
  23878. * Specifies if depth writing should be forced
  23879. */
  23880. forceDepthWrite: boolean;
  23881. /**
  23882. * Specifies the depth function that should be used. 0 means the default engine function
  23883. */
  23884. depthFunction: number;
  23885. /**
  23886. * Specifies if there should be a separate pass for culling
  23887. */
  23888. separateCullingPass: boolean;
  23889. /**
  23890. * Stores the state specifing if fog should be enabled
  23891. */
  23892. private _fogEnabled;
  23893. /**
  23894. * Sets the state for enabling fog
  23895. */
  23896. set fogEnabled(value: boolean);
  23897. /**
  23898. * Gets the value of the fog enabled state
  23899. */
  23900. get fogEnabled(): boolean;
  23901. /**
  23902. * Stores the size of points
  23903. */
  23904. pointSize: number;
  23905. /**
  23906. * Stores the z offset value
  23907. */
  23908. zOffset: number;
  23909. get wireframe(): boolean;
  23910. /**
  23911. * Sets the state of wireframe mode
  23912. */
  23913. set wireframe(value: boolean);
  23914. /**
  23915. * Gets the value specifying if point clouds are enabled
  23916. */
  23917. get pointsCloud(): boolean;
  23918. /**
  23919. * Sets the state of point cloud mode
  23920. */
  23921. set pointsCloud(value: boolean);
  23922. /**
  23923. * Gets the material fill mode
  23924. */
  23925. get fillMode(): number;
  23926. /**
  23927. * Sets the material fill mode
  23928. */
  23929. set fillMode(value: number);
  23930. /**
  23931. * @hidden
  23932. * Stores the effects for the material
  23933. */
  23934. _effect: Nullable<Effect>;
  23935. /**
  23936. * Specifies if uniform buffers should be used
  23937. */
  23938. private _useUBO;
  23939. /**
  23940. * Stores a reference to the scene
  23941. */
  23942. private _scene;
  23943. /**
  23944. * Stores the fill mode state
  23945. */
  23946. private _fillMode;
  23947. /**
  23948. * Specifies if the depth write state should be cached
  23949. */
  23950. private _cachedDepthWriteState;
  23951. /**
  23952. * Specifies if the color write state should be cached
  23953. */
  23954. private _cachedColorWriteState;
  23955. /**
  23956. * Specifies if the depth function state should be cached
  23957. */
  23958. private _cachedDepthFunctionState;
  23959. /**
  23960. * Stores the uniform buffer
  23961. */
  23962. protected _uniformBuffer: UniformBuffer;
  23963. /** @hidden */
  23964. _indexInSceneMaterialArray: number;
  23965. /** @hidden */
  23966. meshMap: Nullable<{
  23967. [id: string]: AbstractMesh | undefined;
  23968. }>;
  23969. /**
  23970. * Creates a material instance
  23971. * @param name defines the name of the material
  23972. * @param scene defines the scene to reference
  23973. * @param doNotAdd specifies if the material should be added to the scene
  23974. */
  23975. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23976. /**
  23977. * Returns a string representation of the current material
  23978. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23979. * @returns a string with material information
  23980. */
  23981. toString(fullDetails?: boolean): string;
  23982. /**
  23983. * Gets the class name of the material
  23984. * @returns a string with the class name of the material
  23985. */
  23986. getClassName(): string;
  23987. /**
  23988. * Specifies if updates for the material been locked
  23989. */
  23990. get isFrozen(): boolean;
  23991. /**
  23992. * Locks updates for the material
  23993. */
  23994. freeze(): void;
  23995. /**
  23996. * Unlocks updates for the material
  23997. */
  23998. unfreeze(): void;
  23999. /**
  24000. * Specifies if the material is ready to be used
  24001. * @param mesh defines the mesh to check
  24002. * @param useInstances specifies if instances should be used
  24003. * @returns a boolean indicating if the material is ready to be used
  24004. */
  24005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24006. /**
  24007. * Specifies that the submesh is ready to be used
  24008. * @param mesh defines the mesh to check
  24009. * @param subMesh defines which submesh to check
  24010. * @param useInstances specifies that instances should be used
  24011. * @returns a boolean indicating that the submesh is ready or not
  24012. */
  24013. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24014. /**
  24015. * Returns the material effect
  24016. * @returns the effect associated with the material
  24017. */
  24018. getEffect(): Nullable<Effect>;
  24019. /**
  24020. * Returns the current scene
  24021. * @returns a Scene
  24022. */
  24023. getScene(): Scene;
  24024. /**
  24025. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24026. */
  24027. protected _forceAlphaTest: boolean;
  24028. /**
  24029. * The transparency mode of the material.
  24030. */
  24031. protected _transparencyMode: Nullable<number>;
  24032. /**
  24033. * Gets the current transparency mode.
  24034. */
  24035. get transparencyMode(): Nullable<number>;
  24036. /**
  24037. * Sets the transparency mode of the material.
  24038. *
  24039. * | Value | Type | Description |
  24040. * | ----- | ----------------------------------- | ----------- |
  24041. * | 0 | OPAQUE | |
  24042. * | 1 | ALPHATEST | |
  24043. * | 2 | ALPHABLEND | |
  24044. * | 3 | ALPHATESTANDBLEND | |
  24045. *
  24046. */
  24047. set transparencyMode(value: Nullable<number>);
  24048. /**
  24049. * Returns true if alpha blending should be disabled.
  24050. */
  24051. protected get _disableAlphaBlending(): boolean;
  24052. /**
  24053. * Specifies whether or not this material should be rendered in alpha blend mode.
  24054. * @returns a boolean specifying if alpha blending is needed
  24055. */
  24056. needAlphaBlending(): boolean;
  24057. /**
  24058. * Specifies if the mesh will require alpha blending
  24059. * @param mesh defines the mesh to check
  24060. * @returns a boolean specifying if alpha blending is needed for the mesh
  24061. */
  24062. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24063. /**
  24064. * Specifies whether or not this material should be rendered in alpha test mode.
  24065. * @returns a boolean specifying if an alpha test is needed.
  24066. */
  24067. needAlphaTesting(): boolean;
  24068. /**
  24069. * Specifies if material alpha testing should be turned on for the mesh
  24070. * @param mesh defines the mesh to check
  24071. */
  24072. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24073. /**
  24074. * Gets the texture used for the alpha test
  24075. * @returns the texture to use for alpha testing
  24076. */
  24077. getAlphaTestTexture(): Nullable<BaseTexture>;
  24078. /**
  24079. * Marks the material to indicate that it needs to be re-calculated
  24080. */
  24081. markDirty(): void;
  24082. /** @hidden */
  24083. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24084. /**
  24085. * Binds the material to the mesh
  24086. * @param world defines the world transformation matrix
  24087. * @param mesh defines the mesh to bind the material to
  24088. */
  24089. bind(world: Matrix, mesh?: Mesh): void;
  24090. /**
  24091. * Binds the submesh to the material
  24092. * @param world defines the world transformation matrix
  24093. * @param mesh defines the mesh containing the submesh
  24094. * @param subMesh defines the submesh to bind the material to
  24095. */
  24096. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24097. /**
  24098. * Binds the world matrix to the material
  24099. * @param world defines the world transformation matrix
  24100. */
  24101. bindOnlyWorldMatrix(world: Matrix): void;
  24102. /**
  24103. * Binds the scene's uniform buffer to the effect.
  24104. * @param effect defines the effect to bind to the scene uniform buffer
  24105. * @param sceneUbo defines the uniform buffer storing scene data
  24106. */
  24107. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24108. /**
  24109. * Binds the view matrix to the effect
  24110. * @param effect defines the effect to bind the view matrix to
  24111. */
  24112. bindView(effect: Effect): void;
  24113. /**
  24114. * Binds the view projection matrix to the effect
  24115. * @param effect defines the effect to bind the view projection matrix to
  24116. */
  24117. bindViewProjection(effect: Effect): void;
  24118. /**
  24119. * Processes to execute after binding the material to a mesh
  24120. * @param mesh defines the rendered mesh
  24121. */
  24122. protected _afterBind(mesh?: Mesh): void;
  24123. /**
  24124. * Unbinds the material from the mesh
  24125. */
  24126. unbind(): void;
  24127. /**
  24128. * Gets the active textures from the material
  24129. * @returns an array of textures
  24130. */
  24131. getActiveTextures(): BaseTexture[];
  24132. /**
  24133. * Specifies if the material uses a texture
  24134. * @param texture defines the texture to check against the material
  24135. * @returns a boolean specifying if the material uses the texture
  24136. */
  24137. hasTexture(texture: BaseTexture): boolean;
  24138. /**
  24139. * Makes a duplicate of the material, and gives it a new name
  24140. * @param name defines the new name for the duplicated material
  24141. * @returns the cloned material
  24142. */
  24143. clone(name: string): Nullable<Material>;
  24144. /**
  24145. * Gets the meshes bound to the material
  24146. * @returns an array of meshes bound to the material
  24147. */
  24148. getBindedMeshes(): AbstractMesh[];
  24149. /**
  24150. * Force shader compilation
  24151. * @param mesh defines the mesh associated with this material
  24152. * @param onCompiled defines a function to execute once the material is compiled
  24153. * @param options defines the options to configure the compilation
  24154. * @param onError defines a function to execute if the material fails compiling
  24155. */
  24156. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24157. /**
  24158. * Force shader compilation
  24159. * @param mesh defines the mesh that will use this material
  24160. * @param options defines additional options for compiling the shaders
  24161. * @returns a promise that resolves when the compilation completes
  24162. */
  24163. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24164. private static readonly _AllDirtyCallBack;
  24165. private static readonly _ImageProcessingDirtyCallBack;
  24166. private static readonly _TextureDirtyCallBack;
  24167. private static readonly _FresnelDirtyCallBack;
  24168. private static readonly _MiscDirtyCallBack;
  24169. private static readonly _LightsDirtyCallBack;
  24170. private static readonly _AttributeDirtyCallBack;
  24171. private static _FresnelAndMiscDirtyCallBack;
  24172. private static _TextureAndMiscDirtyCallBack;
  24173. private static readonly _DirtyCallbackArray;
  24174. private static readonly _RunDirtyCallBacks;
  24175. /**
  24176. * Marks a define in the material to indicate that it needs to be re-computed
  24177. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24178. */
  24179. markAsDirty(flag: number): void;
  24180. /**
  24181. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24182. * @param func defines a function which checks material defines against the submeshes
  24183. */
  24184. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24185. /**
  24186. * Indicates that we need to re-calculated for all submeshes
  24187. */
  24188. protected _markAllSubMeshesAsAllDirty(): void;
  24189. /**
  24190. * Indicates that image processing needs to be re-calculated for all submeshes
  24191. */
  24192. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24193. /**
  24194. * Indicates that textures need to be re-calculated for all submeshes
  24195. */
  24196. protected _markAllSubMeshesAsTexturesDirty(): void;
  24197. /**
  24198. * Indicates that fresnel needs to be re-calculated for all submeshes
  24199. */
  24200. protected _markAllSubMeshesAsFresnelDirty(): void;
  24201. /**
  24202. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24203. */
  24204. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24205. /**
  24206. * Indicates that lights need to be re-calculated for all submeshes
  24207. */
  24208. protected _markAllSubMeshesAsLightsDirty(): void;
  24209. /**
  24210. * Indicates that attributes need to be re-calculated for all submeshes
  24211. */
  24212. protected _markAllSubMeshesAsAttributesDirty(): void;
  24213. /**
  24214. * Indicates that misc needs to be re-calculated for all submeshes
  24215. */
  24216. protected _markAllSubMeshesAsMiscDirty(): void;
  24217. /**
  24218. * Indicates that textures and misc need to be re-calculated for all submeshes
  24219. */
  24220. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24221. /**
  24222. * Disposes the material
  24223. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24224. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24225. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24226. */
  24227. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24228. /** @hidden */
  24229. private releaseVertexArrayObject;
  24230. /**
  24231. * Serializes this material
  24232. * @returns the serialized material object
  24233. */
  24234. serialize(): any;
  24235. /**
  24236. * Creates a material from parsed material data
  24237. * @param parsedMaterial defines parsed material data
  24238. * @param scene defines the hosting scene
  24239. * @param rootUrl defines the root URL to use to load textures
  24240. * @returns a new material
  24241. */
  24242. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24243. }
  24244. }
  24245. declare module BABYLON {
  24246. /**
  24247. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24248. * separate meshes. This can be use to improve performances.
  24249. * @see http://doc.babylonjs.com/how_to/multi_materials
  24250. */
  24251. export class MultiMaterial extends Material {
  24252. private _subMaterials;
  24253. /**
  24254. * Gets or Sets the list of Materials used within the multi material.
  24255. * They need to be ordered according to the submeshes order in the associated mesh
  24256. */
  24257. get subMaterials(): Nullable<Material>[];
  24258. set subMaterials(value: Nullable<Material>[]);
  24259. /**
  24260. * Function used to align with Node.getChildren()
  24261. * @returns the list of Materials used within the multi material
  24262. */
  24263. getChildren(): Nullable<Material>[];
  24264. /**
  24265. * Instantiates a new Multi Material
  24266. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24267. * separate meshes. This can be use to improve performances.
  24268. * @see http://doc.babylonjs.com/how_to/multi_materials
  24269. * @param name Define the name in the scene
  24270. * @param scene Define the scene the material belongs to
  24271. */
  24272. constructor(name: string, scene: Scene);
  24273. private _hookArray;
  24274. /**
  24275. * Get one of the submaterial by its index in the submaterials array
  24276. * @param index The index to look the sub material at
  24277. * @returns The Material if the index has been defined
  24278. */
  24279. getSubMaterial(index: number): Nullable<Material>;
  24280. /**
  24281. * Get the list of active textures for the whole sub materials list.
  24282. * @returns All the textures that will be used during the rendering
  24283. */
  24284. getActiveTextures(): BaseTexture[];
  24285. /**
  24286. * Gets the current class name of the material e.g. "MultiMaterial"
  24287. * Mainly use in serialization.
  24288. * @returns the class name
  24289. */
  24290. getClassName(): string;
  24291. /**
  24292. * Checks if the material is ready to render the requested sub mesh
  24293. * @param mesh Define the mesh the submesh belongs to
  24294. * @param subMesh Define the sub mesh to look readyness for
  24295. * @param useInstances Define whether or not the material is used with instances
  24296. * @returns true if ready, otherwise false
  24297. */
  24298. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24299. /**
  24300. * Clones the current material and its related sub materials
  24301. * @param name Define the name of the newly cloned material
  24302. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24303. * @returns the cloned material
  24304. */
  24305. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24306. /**
  24307. * Serializes the materials into a JSON representation.
  24308. * @returns the JSON representation
  24309. */
  24310. serialize(): any;
  24311. /**
  24312. * Dispose the material and release its associated resources
  24313. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  24314. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  24315. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  24316. */
  24317. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24318. /**
  24319. * Creates a MultiMaterial from parsed MultiMaterial data.
  24320. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24321. * @param scene defines the hosting scene
  24322. * @returns a new MultiMaterial
  24323. */
  24324. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24325. }
  24326. }
  24327. declare module BABYLON {
  24328. /**
  24329. * Defines a subdivision inside a mesh
  24330. */
  24331. export class SubMesh implements ICullable {
  24332. /** the material index to use */
  24333. materialIndex: number;
  24334. /** vertex index start */
  24335. verticesStart: number;
  24336. /** vertices count */
  24337. verticesCount: number;
  24338. /** index start */
  24339. indexStart: number;
  24340. /** indices count */
  24341. indexCount: number;
  24342. /** @hidden */
  24343. _materialDefines: Nullable<MaterialDefines>;
  24344. /** @hidden */
  24345. _materialEffect: Nullable<Effect>;
  24346. /** @hidden */
  24347. _effectOverride: Nullable<Effect>;
  24348. /**
  24349. * Gets material defines used by the effect associated to the sub mesh
  24350. */
  24351. get materialDefines(): Nullable<MaterialDefines>;
  24352. /**
  24353. * Sets material defines used by the effect associated to the sub mesh
  24354. */
  24355. set materialDefines(defines: Nullable<MaterialDefines>);
  24356. /**
  24357. * Gets associated effect
  24358. */
  24359. get effect(): Nullable<Effect>;
  24360. /**
  24361. * Sets associated effect (effect used to render this submesh)
  24362. * @param effect defines the effect to associate with
  24363. * @param defines defines the set of defines used to compile this effect
  24364. */
  24365. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24366. /** @hidden */
  24367. _linesIndexCount: number;
  24368. private _mesh;
  24369. private _renderingMesh;
  24370. private _boundingInfo;
  24371. private _linesIndexBuffer;
  24372. /** @hidden */
  24373. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24374. /** @hidden */
  24375. _trianglePlanes: Plane[];
  24376. /** @hidden */
  24377. _lastColliderTransformMatrix: Nullable<Matrix>;
  24378. /** @hidden */
  24379. _renderId: number;
  24380. /** @hidden */
  24381. _alphaIndex: number;
  24382. /** @hidden */
  24383. _distanceToCamera: number;
  24384. /** @hidden */
  24385. _id: number;
  24386. private _currentMaterial;
  24387. /**
  24388. * Add a new submesh to a mesh
  24389. * @param materialIndex defines the material index to use
  24390. * @param verticesStart defines vertex index start
  24391. * @param verticesCount defines vertices count
  24392. * @param indexStart defines index start
  24393. * @param indexCount defines indices count
  24394. * @param mesh defines the parent mesh
  24395. * @param renderingMesh defines an optional rendering mesh
  24396. * @param createBoundingBox defines if bounding box should be created for this submesh
  24397. * @returns the new submesh
  24398. */
  24399. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24400. /**
  24401. * Creates a new submesh
  24402. * @param materialIndex defines the material index to use
  24403. * @param verticesStart defines vertex index start
  24404. * @param verticesCount defines vertices count
  24405. * @param indexStart defines index start
  24406. * @param indexCount defines indices count
  24407. * @param mesh defines the parent mesh
  24408. * @param renderingMesh defines an optional rendering mesh
  24409. * @param createBoundingBox defines if bounding box should be created for this submesh
  24410. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24411. */
  24412. constructor(
  24413. /** the material index to use */
  24414. materialIndex: number,
  24415. /** vertex index start */
  24416. verticesStart: number,
  24417. /** vertices count */
  24418. verticesCount: number,
  24419. /** index start */
  24420. indexStart: number,
  24421. /** indices count */
  24422. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24423. /**
  24424. * Returns true if this submesh covers the entire parent mesh
  24425. * @ignorenaming
  24426. */
  24427. get IsGlobal(): boolean;
  24428. /**
  24429. * Returns the submesh BoudingInfo object
  24430. * @returns current bounding info (or mesh's one if the submesh is global)
  24431. */
  24432. getBoundingInfo(): BoundingInfo;
  24433. /**
  24434. * Sets the submesh BoundingInfo
  24435. * @param boundingInfo defines the new bounding info to use
  24436. * @returns the SubMesh
  24437. */
  24438. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24439. /**
  24440. * Returns the mesh of the current submesh
  24441. * @return the parent mesh
  24442. */
  24443. getMesh(): AbstractMesh;
  24444. /**
  24445. * Returns the rendering mesh of the submesh
  24446. * @returns the rendering mesh (could be different from parent mesh)
  24447. */
  24448. getRenderingMesh(): Mesh;
  24449. /**
  24450. * Returns the replacement mesh of the submesh
  24451. * @returns the replacement mesh (could be different from parent mesh)
  24452. */
  24453. getReplacementMesh(): Nullable<AbstractMesh>;
  24454. /**
  24455. * Returns the effective mesh of the submesh
  24456. * @returns the effective mesh (could be different from parent mesh)
  24457. */
  24458. getEffectiveMesh(): AbstractMesh;
  24459. /**
  24460. * Returns the submesh material
  24461. * @returns null or the current material
  24462. */
  24463. getMaterial(): Nullable<Material>;
  24464. private _IsMultiMaterial;
  24465. /**
  24466. * Sets a new updated BoundingInfo object to the submesh
  24467. * @param data defines an optional position array to use to determine the bounding info
  24468. * @returns the SubMesh
  24469. */
  24470. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24471. /** @hidden */
  24472. _checkCollision(collider: Collider): boolean;
  24473. /**
  24474. * Updates the submesh BoundingInfo
  24475. * @param world defines the world matrix to use to update the bounding info
  24476. * @returns the submesh
  24477. */
  24478. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24479. /**
  24480. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24481. * @param frustumPlanes defines the frustum planes
  24482. * @returns true if the submesh is intersecting with the frustum
  24483. */
  24484. isInFrustum(frustumPlanes: Plane[]): boolean;
  24485. /**
  24486. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24487. * @param frustumPlanes defines the frustum planes
  24488. * @returns true if the submesh is inside the frustum
  24489. */
  24490. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24491. /**
  24492. * Renders the submesh
  24493. * @param enableAlphaMode defines if alpha needs to be used
  24494. * @returns the submesh
  24495. */
  24496. render(enableAlphaMode: boolean): SubMesh;
  24497. /**
  24498. * @hidden
  24499. */
  24500. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24501. /**
  24502. * Checks if the submesh intersects with a ray
  24503. * @param ray defines the ray to test
  24504. * @returns true is the passed ray intersects the submesh bounding box
  24505. */
  24506. canIntersects(ray: Ray): boolean;
  24507. /**
  24508. * Intersects current submesh with a ray
  24509. * @param ray defines the ray to test
  24510. * @param positions defines mesh's positions array
  24511. * @param indices defines mesh's indices array
  24512. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24513. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24514. * @returns intersection info or null if no intersection
  24515. */
  24516. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24517. /** @hidden */
  24518. private _intersectLines;
  24519. /** @hidden */
  24520. private _intersectUnIndexedLines;
  24521. /** @hidden */
  24522. private _intersectTriangles;
  24523. /** @hidden */
  24524. private _intersectUnIndexedTriangles;
  24525. /** @hidden */
  24526. _rebuild(): void;
  24527. /**
  24528. * Creates a new submesh from the passed mesh
  24529. * @param newMesh defines the new hosting mesh
  24530. * @param newRenderingMesh defines an optional rendering mesh
  24531. * @returns the new submesh
  24532. */
  24533. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24534. /**
  24535. * Release associated resources
  24536. */
  24537. dispose(): void;
  24538. /**
  24539. * Gets the class name
  24540. * @returns the string "SubMesh".
  24541. */
  24542. getClassName(): string;
  24543. /**
  24544. * Creates a new submesh from indices data
  24545. * @param materialIndex the index of the main mesh material
  24546. * @param startIndex the index where to start the copy in the mesh indices array
  24547. * @param indexCount the number of indices to copy then from the startIndex
  24548. * @param mesh the main mesh to create the submesh from
  24549. * @param renderingMesh the optional rendering mesh
  24550. * @returns a new submesh
  24551. */
  24552. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24553. }
  24554. }
  24555. declare module BABYLON {
  24556. /**
  24557. * Class used to represent data loading progression
  24558. */
  24559. export class SceneLoaderFlags {
  24560. private static _ForceFullSceneLoadingForIncremental;
  24561. private static _ShowLoadingScreen;
  24562. private static _CleanBoneMatrixWeights;
  24563. private static _loggingLevel;
  24564. /**
  24565. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24566. */
  24567. static get ForceFullSceneLoadingForIncremental(): boolean;
  24568. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24569. /**
  24570. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24571. */
  24572. static get ShowLoadingScreen(): boolean;
  24573. static set ShowLoadingScreen(value: boolean);
  24574. /**
  24575. * Defines the current logging level (while loading the scene)
  24576. * @ignorenaming
  24577. */
  24578. static get loggingLevel(): number;
  24579. static set loggingLevel(value: number);
  24580. /**
  24581. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24582. */
  24583. static get CleanBoneMatrixWeights(): boolean;
  24584. static set CleanBoneMatrixWeights(value: boolean);
  24585. }
  24586. }
  24587. declare module BABYLON {
  24588. /**
  24589. * Class used to store geometry data (vertex buffers + index buffer)
  24590. */
  24591. export class Geometry implements IGetSetVerticesData {
  24592. /**
  24593. * Gets or sets the ID of the geometry
  24594. */
  24595. id: string;
  24596. /**
  24597. * Gets or sets the unique ID of the geometry
  24598. */
  24599. uniqueId: number;
  24600. /**
  24601. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24602. */
  24603. delayLoadState: number;
  24604. /**
  24605. * Gets the file containing the data to load when running in delay load state
  24606. */
  24607. delayLoadingFile: Nullable<string>;
  24608. /**
  24609. * Callback called when the geometry is updated
  24610. */
  24611. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24612. private _scene;
  24613. private _engine;
  24614. private _meshes;
  24615. private _totalVertices;
  24616. /** @hidden */
  24617. _indices: IndicesArray;
  24618. /** @hidden */
  24619. _vertexBuffers: {
  24620. [key: string]: VertexBuffer;
  24621. };
  24622. private _isDisposed;
  24623. private _extend;
  24624. private _boundingBias;
  24625. /** @hidden */
  24626. _delayInfo: Array<string>;
  24627. private _indexBuffer;
  24628. private _indexBufferIsUpdatable;
  24629. /** @hidden */
  24630. _boundingInfo: Nullable<BoundingInfo>;
  24631. /** @hidden */
  24632. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24633. /** @hidden */
  24634. _softwareSkinningFrameId: number;
  24635. private _vertexArrayObjects;
  24636. private _updatable;
  24637. /** @hidden */
  24638. _positions: Nullable<Vector3[]>;
  24639. /**
  24640. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  24641. */
  24642. get boundingBias(): Vector2;
  24643. /**
  24644. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  24645. */
  24646. set boundingBias(value: Vector2);
  24647. /**
  24648. * Static function used to attach a new empty geometry to a mesh
  24649. * @param mesh defines the mesh to attach the geometry to
  24650. * @returns the new Geometry
  24651. */
  24652. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24653. /** Get the list of meshes using this geometry */
  24654. get meshes(): Mesh[];
  24655. /**
  24656. * Creates a new geometry
  24657. * @param id defines the unique ID
  24658. * @param scene defines the hosting scene
  24659. * @param vertexData defines the VertexData used to get geometry data
  24660. * @param updatable defines if geometry must be updatable (false by default)
  24661. * @param mesh defines the mesh that will be associated with the geometry
  24662. */
  24663. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24664. /**
  24665. * Gets the current extend of the geometry
  24666. */
  24667. get extend(): {
  24668. minimum: Vector3;
  24669. maximum: Vector3;
  24670. };
  24671. /**
  24672. * Gets the hosting scene
  24673. * @returns the hosting Scene
  24674. */
  24675. getScene(): Scene;
  24676. /**
  24677. * Gets the hosting engine
  24678. * @returns the hosting Engine
  24679. */
  24680. getEngine(): Engine;
  24681. /**
  24682. * Defines if the geometry is ready to use
  24683. * @returns true if the geometry is ready to be used
  24684. */
  24685. isReady(): boolean;
  24686. /**
  24687. * Gets a value indicating that the geometry should not be serialized
  24688. */
  24689. get doNotSerialize(): boolean;
  24690. /** @hidden */
  24691. _rebuild(): void;
  24692. /**
  24693. * Affects all geometry data in one call
  24694. * @param vertexData defines the geometry data
  24695. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24696. */
  24697. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24698. /**
  24699. * Set specific vertex data
  24700. * @param kind defines the data kind (Position, normal, etc...)
  24701. * @param data defines the vertex data to use
  24702. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24703. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24704. */
  24705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24706. /**
  24707. * Removes a specific vertex data
  24708. * @param kind defines the data kind (Position, normal, etc...)
  24709. */
  24710. removeVerticesData(kind: string): void;
  24711. /**
  24712. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24713. * @param buffer defines the vertex buffer to use
  24714. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24715. */
  24716. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24717. /**
  24718. * Update a specific vertex buffer
  24719. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24720. * It will do nothing if the buffer is not updatable
  24721. * @param kind defines the data kind (Position, normal, etc...)
  24722. * @param data defines the data to use
  24723. * @param offset defines the offset in the target buffer where to store the data
  24724. * @param useBytes set to true if the offset is in bytes
  24725. */
  24726. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24727. /**
  24728. * Update a specific vertex buffer
  24729. * This function will create a new buffer if the current one is not updatable
  24730. * @param kind defines the data kind (Position, normal, etc...)
  24731. * @param data defines the data to use
  24732. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24733. */
  24734. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24735. private _updateBoundingInfo;
  24736. /** @hidden */
  24737. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24738. /**
  24739. * Gets total number of vertices
  24740. * @returns the total number of vertices
  24741. */
  24742. getTotalVertices(): number;
  24743. /**
  24744. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24745. * @param kind defines the data kind (Position, normal, etc...)
  24746. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24748. * @returns a float array containing vertex data
  24749. */
  24750. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24751. /**
  24752. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24753. * @param kind defines the data kind (Position, normal, etc...)
  24754. * @returns true if the vertex buffer with the specified kind is updatable
  24755. */
  24756. isVertexBufferUpdatable(kind: string): boolean;
  24757. /**
  24758. * Gets a specific vertex buffer
  24759. * @param kind defines the data kind (Position, normal, etc...)
  24760. * @returns a VertexBuffer
  24761. */
  24762. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24763. /**
  24764. * Returns all vertex buffers
  24765. * @return an object holding all vertex buffers indexed by kind
  24766. */
  24767. getVertexBuffers(): Nullable<{
  24768. [key: string]: VertexBuffer;
  24769. }>;
  24770. /**
  24771. * Gets a boolean indicating if specific vertex buffer is present
  24772. * @param kind defines the data kind (Position, normal, etc...)
  24773. * @returns true if data is present
  24774. */
  24775. isVerticesDataPresent(kind: string): boolean;
  24776. /**
  24777. * Gets a list of all attached data kinds (Position, normal, etc...)
  24778. * @returns a list of string containing all kinds
  24779. */
  24780. getVerticesDataKinds(): string[];
  24781. /**
  24782. * Update index buffer
  24783. * @param indices defines the indices to store in the index buffer
  24784. * @param offset defines the offset in the target buffer where to store the data
  24785. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24786. */
  24787. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24788. /**
  24789. * Creates a new index buffer
  24790. * @param indices defines the indices to store in the index buffer
  24791. * @param totalVertices defines the total number of vertices (could be null)
  24792. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24793. */
  24794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24795. /**
  24796. * Return the total number of indices
  24797. * @returns the total number of indices
  24798. */
  24799. getTotalIndices(): number;
  24800. /**
  24801. * Gets the index buffer array
  24802. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24803. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24804. * @returns the index buffer array
  24805. */
  24806. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24807. /**
  24808. * Gets the index buffer
  24809. * @return the index buffer
  24810. */
  24811. getIndexBuffer(): Nullable<DataBuffer>;
  24812. /** @hidden */
  24813. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24814. /**
  24815. * Release the associated resources for a specific mesh
  24816. * @param mesh defines the source mesh
  24817. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24818. */
  24819. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24820. /**
  24821. * Apply current geometry to a given mesh
  24822. * @param mesh defines the mesh to apply geometry to
  24823. */
  24824. applyToMesh(mesh: Mesh): void;
  24825. private _updateExtend;
  24826. private _applyToMesh;
  24827. private notifyUpdate;
  24828. /**
  24829. * Load the geometry if it was flagged as delay loaded
  24830. * @param scene defines the hosting scene
  24831. * @param onLoaded defines a callback called when the geometry is loaded
  24832. */
  24833. load(scene: Scene, onLoaded?: () => void): void;
  24834. private _queueLoad;
  24835. /**
  24836. * Invert the geometry to move from a right handed system to a left handed one.
  24837. */
  24838. toLeftHanded(): void;
  24839. /** @hidden */
  24840. _resetPointsArrayCache(): void;
  24841. /** @hidden */
  24842. _generatePointsArray(): boolean;
  24843. /**
  24844. * Gets a value indicating if the geometry is disposed
  24845. * @returns true if the geometry was disposed
  24846. */
  24847. isDisposed(): boolean;
  24848. private _disposeVertexArrayObjects;
  24849. /**
  24850. * Free all associated resources
  24851. */
  24852. dispose(): void;
  24853. /**
  24854. * Clone the current geometry into a new geometry
  24855. * @param id defines the unique ID of the new geometry
  24856. * @returns a new geometry object
  24857. */
  24858. copy(id: string): Geometry;
  24859. /**
  24860. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24861. * @return a JSON representation of the current geometry data (without the vertices data)
  24862. */
  24863. serialize(): any;
  24864. private toNumberArray;
  24865. /**
  24866. * Serialize all vertices data into a JSON oject
  24867. * @returns a JSON representation of the current geometry data
  24868. */
  24869. serializeVerticeData(): any;
  24870. /**
  24871. * Extracts a clone of a mesh geometry
  24872. * @param mesh defines the source mesh
  24873. * @param id defines the unique ID of the new geometry object
  24874. * @returns the new geometry object
  24875. */
  24876. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24877. /**
  24878. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24879. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24880. * Be aware Math.random() could cause collisions, but:
  24881. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  24882. * @returns a string containing a new GUID
  24883. */
  24884. static RandomId(): string;
  24885. /** @hidden */
  24886. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24887. private static _CleanMatricesWeights;
  24888. /**
  24889. * Create a new geometry from persisted data (Using .babylon file format)
  24890. * @param parsedVertexData defines the persisted data
  24891. * @param scene defines the hosting scene
  24892. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24893. * @returns the new geometry object
  24894. */
  24895. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24896. }
  24897. }
  24898. declare module BABYLON {
  24899. /**
  24900. * Define an interface for all classes that will get and set the data on vertices
  24901. */
  24902. export interface IGetSetVerticesData {
  24903. /**
  24904. * Gets a boolean indicating if specific vertex data is present
  24905. * @param kind defines the vertex data kind to use
  24906. * @returns true is data kind is present
  24907. */
  24908. isVerticesDataPresent(kind: string): boolean;
  24909. /**
  24910. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24911. * @param kind defines the data kind (Position, normal, etc...)
  24912. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24913. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24914. * @returns a float array containing vertex data
  24915. */
  24916. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24917. /**
  24918. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24919. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24920. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24921. * @returns the indices array or an empty array if the mesh has no geometry
  24922. */
  24923. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24924. /**
  24925. * Set specific vertex data
  24926. * @param kind defines the data kind (Position, normal, etc...)
  24927. * @param data defines the vertex data to use
  24928. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24929. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24930. */
  24931. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24932. /**
  24933. * Update a specific associated vertex buffer
  24934. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24935. * - VertexBuffer.PositionKind
  24936. * - VertexBuffer.UVKind
  24937. * - VertexBuffer.UV2Kind
  24938. * - VertexBuffer.UV3Kind
  24939. * - VertexBuffer.UV4Kind
  24940. * - VertexBuffer.UV5Kind
  24941. * - VertexBuffer.UV6Kind
  24942. * - VertexBuffer.ColorKind
  24943. * - VertexBuffer.MatricesIndicesKind
  24944. * - VertexBuffer.MatricesIndicesExtraKind
  24945. * - VertexBuffer.MatricesWeightsKind
  24946. * - VertexBuffer.MatricesWeightsExtraKind
  24947. * @param data defines the data source
  24948. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24949. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  24950. */
  24951. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24952. /**
  24953. * Creates a new index buffer
  24954. * @param indices defines the indices to store in the index buffer
  24955. * @param totalVertices defines the total number of vertices (could be null)
  24956. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24957. */
  24958. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24959. }
  24960. /**
  24961. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24962. */
  24963. export class VertexData {
  24964. /**
  24965. * Mesh side orientation : usually the external or front surface
  24966. */
  24967. static readonly FRONTSIDE: number;
  24968. /**
  24969. * Mesh side orientation : usually the internal or back surface
  24970. */
  24971. static readonly BACKSIDE: number;
  24972. /**
  24973. * Mesh side orientation : both internal and external or front and back surfaces
  24974. */
  24975. static readonly DOUBLESIDE: number;
  24976. /**
  24977. * Mesh side orientation : by default, `FRONTSIDE`
  24978. */
  24979. static readonly DEFAULTSIDE: number;
  24980. /**
  24981. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  24982. */
  24983. positions: Nullable<FloatArray>;
  24984. /**
  24985. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  24986. */
  24987. normals: Nullable<FloatArray>;
  24988. /**
  24989. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  24990. */
  24991. tangents: Nullable<FloatArray>;
  24992. /**
  24993. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24994. */
  24995. uvs: Nullable<FloatArray>;
  24996. /**
  24997. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24998. */
  24999. uvs2: Nullable<FloatArray>;
  25000. /**
  25001. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25002. */
  25003. uvs3: Nullable<FloatArray>;
  25004. /**
  25005. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25006. */
  25007. uvs4: Nullable<FloatArray>;
  25008. /**
  25009. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25010. */
  25011. uvs5: Nullable<FloatArray>;
  25012. /**
  25013. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25014. */
  25015. uvs6: Nullable<FloatArray>;
  25016. /**
  25017. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25018. */
  25019. colors: Nullable<FloatArray>;
  25020. /**
  25021. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  25022. */
  25023. matricesIndices: Nullable<FloatArray>;
  25024. /**
  25025. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25026. */
  25027. matricesWeights: Nullable<FloatArray>;
  25028. /**
  25029. * An array extending the number of possible indices
  25030. */
  25031. matricesIndicesExtra: Nullable<FloatArray>;
  25032. /**
  25033. * An array extending the number of possible weights when the number of indices is extended
  25034. */
  25035. matricesWeightsExtra: Nullable<FloatArray>;
  25036. /**
  25037. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25038. */
  25039. indices: Nullable<IndicesArray>;
  25040. /**
  25041. * Uses the passed data array to set the set the values for the specified kind of data
  25042. * @param data a linear array of floating numbers
  25043. * @param kind the type of data that is being set, eg positions, colors etc
  25044. */
  25045. set(data: FloatArray, kind: string): void;
  25046. /**
  25047. * Associates the vertexData to the passed Mesh.
  25048. * Sets it as updatable or not (default `false`)
  25049. * @param mesh the mesh the vertexData is applied to
  25050. * @param updatable when used and having the value true allows new data to update the vertexData
  25051. * @returns the VertexData
  25052. */
  25053. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25054. /**
  25055. * Associates the vertexData to the passed Geometry.
  25056. * Sets it as updatable or not (default `false`)
  25057. * @param geometry the geometry the vertexData is applied to
  25058. * @param updatable when used and having the value true allows new data to update the vertexData
  25059. * @returns VertexData
  25060. */
  25061. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25062. /**
  25063. * Updates the associated mesh
  25064. * @param mesh the mesh to be updated
  25065. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25066. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  25067. * @returns VertexData
  25068. */
  25069. updateMesh(mesh: Mesh): VertexData;
  25070. /**
  25071. * Updates the associated geometry
  25072. * @param geometry the geometry to be updated
  25073. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25074. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  25075. * @returns VertexData.
  25076. */
  25077. updateGeometry(geometry: Geometry): VertexData;
  25078. private _applyTo;
  25079. private _update;
  25080. /**
  25081. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25082. * @param matrix the transforming matrix
  25083. * @returns the VertexData
  25084. */
  25085. transform(matrix: Matrix): VertexData;
  25086. /**
  25087. * Merges the passed VertexData into the current one
  25088. * @param other the VertexData to be merged into the current one
  25089. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25090. * @returns the modified VertexData
  25091. */
  25092. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25093. private _mergeElement;
  25094. private _validate;
  25095. /**
  25096. * Serializes the VertexData
  25097. * @returns a serialized object
  25098. */
  25099. serialize(): any;
  25100. /**
  25101. * Extracts the vertexData from a mesh
  25102. * @param mesh the mesh from which to extract the VertexData
  25103. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25104. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25105. * @returns the object VertexData associated to the passed mesh
  25106. */
  25107. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25108. /**
  25109. * Extracts the vertexData from the geometry
  25110. * @param geometry the geometry from which to extract the VertexData
  25111. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25112. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25113. * @returns the object VertexData associated to the passed mesh
  25114. */
  25115. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25116. private static _ExtractFrom;
  25117. /**
  25118. * Creates the VertexData for a Ribbon
  25119. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25120. * * pathArray array of paths, each of which an array of successive Vector3
  25121. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25122. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25123. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  25124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25125. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25126. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25127. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25128. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25129. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25130. * @returns the VertexData of the ribbon
  25131. */
  25132. static CreateRibbon(options: {
  25133. pathArray: Vector3[][];
  25134. closeArray?: boolean;
  25135. closePath?: boolean;
  25136. offset?: number;
  25137. sideOrientation?: number;
  25138. frontUVs?: Vector4;
  25139. backUVs?: Vector4;
  25140. invertUV?: boolean;
  25141. uvs?: Vector2[];
  25142. colors?: Color4[];
  25143. }): VertexData;
  25144. /**
  25145. * Creates the VertexData for a box
  25146. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25147. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25148. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25149. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25150. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25151. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25152. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25154. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25155. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25156. * @returns the VertexData of the box
  25157. */
  25158. static CreateBox(options: {
  25159. size?: number;
  25160. width?: number;
  25161. height?: number;
  25162. depth?: number;
  25163. faceUV?: Vector4[];
  25164. faceColors?: Color4[];
  25165. sideOrientation?: number;
  25166. frontUVs?: Vector4;
  25167. backUVs?: Vector4;
  25168. }): VertexData;
  25169. /**
  25170. * Creates the VertexData for a tiled box
  25171. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25172. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25173. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25174. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25176. * @returns the VertexData of the box
  25177. */
  25178. static CreateTiledBox(options: {
  25179. pattern?: number;
  25180. width?: number;
  25181. height?: number;
  25182. depth?: number;
  25183. tileSize?: number;
  25184. tileWidth?: number;
  25185. tileHeight?: number;
  25186. alignHorizontal?: number;
  25187. alignVertical?: number;
  25188. faceUV?: Vector4[];
  25189. faceColors?: Color4[];
  25190. sideOrientation?: number;
  25191. }): VertexData;
  25192. /**
  25193. * Creates the VertexData for a tiled plane
  25194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25195. * * pattern a limited pattern arrangement depending on the number
  25196. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25197. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25198. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25200. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25201. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25202. * @returns the VertexData of the tiled plane
  25203. */
  25204. static CreateTiledPlane(options: {
  25205. pattern?: number;
  25206. tileSize?: number;
  25207. tileWidth?: number;
  25208. tileHeight?: number;
  25209. size?: number;
  25210. width?: number;
  25211. height?: number;
  25212. alignHorizontal?: number;
  25213. alignVertical?: number;
  25214. sideOrientation?: number;
  25215. frontUVs?: Vector4;
  25216. backUVs?: Vector4;
  25217. }): VertexData;
  25218. /**
  25219. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25220. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25221. * * segments sets the number of horizontal strips optional, default 32
  25222. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25223. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25224. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25225. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25226. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  25227. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  25228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25229. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25230. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25231. * @returns the VertexData of the ellipsoid
  25232. */
  25233. static CreateSphere(options: {
  25234. segments?: number;
  25235. diameter?: number;
  25236. diameterX?: number;
  25237. diameterY?: number;
  25238. diameterZ?: number;
  25239. arc?: number;
  25240. slice?: number;
  25241. sideOrientation?: number;
  25242. frontUVs?: Vector4;
  25243. backUVs?: Vector4;
  25244. }): VertexData;
  25245. /**
  25246. * Creates the VertexData for a cylinder, cone or prism
  25247. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25248. * * height sets the height (y direction) of the cylinder, optional, default 2
  25249. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25250. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25251. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25252. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25253. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25254. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  25255. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25256. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25257. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25258. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25260. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25261. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25262. * @returns the VertexData of the cylinder, cone or prism
  25263. */
  25264. static CreateCylinder(options: {
  25265. height?: number;
  25266. diameterTop?: number;
  25267. diameterBottom?: number;
  25268. diameter?: number;
  25269. tessellation?: number;
  25270. subdivisions?: number;
  25271. arc?: number;
  25272. faceColors?: Color4[];
  25273. faceUV?: Vector4[];
  25274. hasRings?: boolean;
  25275. enclose?: boolean;
  25276. sideOrientation?: number;
  25277. frontUVs?: Vector4;
  25278. backUVs?: Vector4;
  25279. }): VertexData;
  25280. /**
  25281. * Creates the VertexData for a torus
  25282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25283. * * diameter the diameter of the torus, optional default 1
  25284. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25285. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25287. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25288. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25289. * @returns the VertexData of the torus
  25290. */
  25291. static CreateTorus(options: {
  25292. diameter?: number;
  25293. thickness?: number;
  25294. tessellation?: number;
  25295. sideOrientation?: number;
  25296. frontUVs?: Vector4;
  25297. backUVs?: Vector4;
  25298. }): VertexData;
  25299. /**
  25300. * Creates the VertexData of the LineSystem
  25301. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25302. * - lines an array of lines, each line being an array of successive Vector3
  25303. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25304. * @returns the VertexData of the LineSystem
  25305. */
  25306. static CreateLineSystem(options: {
  25307. lines: Vector3[][];
  25308. colors?: Nullable<Color4[][]>;
  25309. }): VertexData;
  25310. /**
  25311. * Create the VertexData for a DashedLines
  25312. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25313. * - points an array successive Vector3
  25314. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25315. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25316. * - dashNb the intended total number of dashes, optional, default 200
  25317. * @returns the VertexData for the DashedLines
  25318. */
  25319. static CreateDashedLines(options: {
  25320. points: Vector3[];
  25321. dashSize?: number;
  25322. gapSize?: number;
  25323. dashNb?: number;
  25324. }): VertexData;
  25325. /**
  25326. * Creates the VertexData for a Ground
  25327. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25328. * - width the width (x direction) of the ground, optional, default 1
  25329. * - height the height (z direction) of the ground, optional, default 1
  25330. * - subdivisions the number of subdivisions per side, optional, default 1
  25331. * @returns the VertexData of the Ground
  25332. */
  25333. static CreateGround(options: {
  25334. width?: number;
  25335. height?: number;
  25336. subdivisions?: number;
  25337. subdivisionsX?: number;
  25338. subdivisionsY?: number;
  25339. }): VertexData;
  25340. /**
  25341. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25343. * * xmin the ground minimum X coordinate, optional, default -1
  25344. * * zmin the ground minimum Z coordinate, optional, default -1
  25345. * * xmax the ground maximum X coordinate, optional, default 1
  25346. * * zmax the ground maximum Z coordinate, optional, default 1
  25347. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  25348. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  25349. * @returns the VertexData of the TiledGround
  25350. */
  25351. static CreateTiledGround(options: {
  25352. xmin: number;
  25353. zmin: number;
  25354. xmax: number;
  25355. zmax: number;
  25356. subdivisions?: {
  25357. w: number;
  25358. h: number;
  25359. };
  25360. precision?: {
  25361. w: number;
  25362. h: number;
  25363. };
  25364. }): VertexData;
  25365. /**
  25366. * Creates the VertexData of the Ground designed from a heightmap
  25367. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25368. * * width the width (x direction) of the ground
  25369. * * height the height (z direction) of the ground
  25370. * * subdivisions the number of subdivisions per side
  25371. * * minHeight the minimum altitude on the ground, optional, default 0
  25372. * * maxHeight the maximum altitude on the ground, optional default 1
  25373. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25374. * * buffer the array holding the image color data
  25375. * * bufferWidth the width of image
  25376. * * bufferHeight the height of image
  25377. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25378. * @returns the VertexData of the Ground designed from a heightmap
  25379. */
  25380. static CreateGroundFromHeightMap(options: {
  25381. width: number;
  25382. height: number;
  25383. subdivisions: number;
  25384. minHeight: number;
  25385. maxHeight: number;
  25386. colorFilter: Color3;
  25387. buffer: Uint8Array;
  25388. bufferWidth: number;
  25389. bufferHeight: number;
  25390. alphaFilter: number;
  25391. }): VertexData;
  25392. /**
  25393. * Creates the VertexData for a Plane
  25394. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25395. * * size sets the width and height of the plane to the value of size, optional default 1
  25396. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25397. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25399. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25400. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25401. * @returns the VertexData of the box
  25402. */
  25403. static CreatePlane(options: {
  25404. size?: number;
  25405. width?: number;
  25406. height?: number;
  25407. sideOrientation?: number;
  25408. frontUVs?: Vector4;
  25409. backUVs?: Vector4;
  25410. }): VertexData;
  25411. /**
  25412. * Creates the VertexData of the Disc or regular Polygon
  25413. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25414. * * radius the radius of the disc, optional default 0.5
  25415. * * tessellation the number of polygon sides, optional, default 64
  25416. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  25417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25418. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25419. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25420. * @returns the VertexData of the box
  25421. */
  25422. static CreateDisc(options: {
  25423. radius?: number;
  25424. tessellation?: number;
  25425. arc?: number;
  25426. sideOrientation?: number;
  25427. frontUVs?: Vector4;
  25428. backUVs?: Vector4;
  25429. }): VertexData;
  25430. /**
  25431. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25432. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25433. * @param polygon a mesh built from polygonTriangulation.build()
  25434. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25435. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25436. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25437. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25438. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25439. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25440. * @returns the VertexData of the Polygon
  25441. */
  25442. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25443. /**
  25444. * Creates the VertexData of the IcoSphere
  25445. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25446. * * radius the radius of the IcoSphere, optional default 1
  25447. * * radiusX allows stretching in the x direction, optional, default radius
  25448. * * radiusY allows stretching in the y direction, optional, default radius
  25449. * * radiusZ allows stretching in the z direction, optional, default radius
  25450. * * flat when true creates a flat shaded mesh, optional, default true
  25451. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25453. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25454. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25455. * @returns the VertexData of the IcoSphere
  25456. */
  25457. static CreateIcoSphere(options: {
  25458. radius?: number;
  25459. radiusX?: number;
  25460. radiusY?: number;
  25461. radiusZ?: number;
  25462. flat?: boolean;
  25463. subdivisions?: number;
  25464. sideOrientation?: number;
  25465. frontUVs?: Vector4;
  25466. backUVs?: Vector4;
  25467. }): VertexData;
  25468. /**
  25469. * Creates the VertexData for a Polyhedron
  25470. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25471. * * type provided types are:
  25472. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25473. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  25474. * * size the size of the IcoSphere, optional default 1
  25475. * * sizeX allows stretching in the x direction, optional, default size
  25476. * * sizeY allows stretching in the y direction, optional, default size
  25477. * * sizeZ allows stretching in the z direction, optional, default size
  25478. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  25479. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25480. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25481. * * flat when true creates a flat shaded mesh, optional, default true
  25482. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25484. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25485. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25486. * @returns the VertexData of the Polyhedron
  25487. */
  25488. static CreatePolyhedron(options: {
  25489. type?: number;
  25490. size?: number;
  25491. sizeX?: number;
  25492. sizeY?: number;
  25493. sizeZ?: number;
  25494. custom?: any;
  25495. faceUV?: Vector4[];
  25496. faceColors?: Color4[];
  25497. flat?: boolean;
  25498. sideOrientation?: number;
  25499. frontUVs?: Vector4;
  25500. backUVs?: Vector4;
  25501. }): VertexData;
  25502. /**
  25503. * Creates the VertexData for a TorusKnot
  25504. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25505. * * radius the radius of the torus knot, optional, default 2
  25506. * * tube the thickness of the tube, optional, default 0.5
  25507. * * radialSegments the number of sides on each tube segments, optional, default 32
  25508. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25509. * * p the number of windings around the z axis, optional, default 2
  25510. * * q the number of windings around the x axis, optional, default 3
  25511. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25512. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  25513. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  25514. * @returns the VertexData of the Torus Knot
  25515. */
  25516. static CreateTorusKnot(options: {
  25517. radius?: number;
  25518. tube?: number;
  25519. radialSegments?: number;
  25520. tubularSegments?: number;
  25521. p?: number;
  25522. q?: number;
  25523. sideOrientation?: number;
  25524. frontUVs?: Vector4;
  25525. backUVs?: Vector4;
  25526. }): VertexData;
  25527. /**
  25528. * Compute normals for given positions and indices
  25529. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25530. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25531. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25532. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25533. * * facetNormals : optional array of facet normals (vector3)
  25534. * * facetPositions : optional array of facet positions (vector3)
  25535. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25536. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25537. * * bInfo : optional bounding info, required for facetPartitioning computation
  25538. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25539. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25540. * * useRightHandedSystem: optional boolean to for right handed system computation
  25541. * * depthSort : optional boolean to enable the facet depth sort computation
  25542. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25543. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25544. */
  25545. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25546. facetNormals?: any;
  25547. facetPositions?: any;
  25548. facetPartitioning?: any;
  25549. ratio?: number;
  25550. bInfo?: any;
  25551. bbSize?: Vector3;
  25552. subDiv?: any;
  25553. useRightHandedSystem?: boolean;
  25554. depthSort?: boolean;
  25555. distanceTo?: Vector3;
  25556. depthSortedFacets?: any;
  25557. }): void;
  25558. /** @hidden */
  25559. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25560. /**
  25561. * Applies VertexData created from the imported parameters to the geometry
  25562. * @param parsedVertexData the parsed data from an imported file
  25563. * @param geometry the geometry to apply the VertexData to
  25564. */
  25565. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25566. }
  25567. }
  25568. declare module BABYLON {
  25569. /**
  25570. * Defines a target to use with MorphTargetManager
  25571. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25572. */
  25573. export class MorphTarget implements IAnimatable {
  25574. /** defines the name of the target */
  25575. name: string;
  25576. /**
  25577. * Gets or sets the list of animations
  25578. */
  25579. animations: Animation[];
  25580. private _scene;
  25581. private _positions;
  25582. private _normals;
  25583. private _tangents;
  25584. private _uvs;
  25585. private _influence;
  25586. private _uniqueId;
  25587. /**
  25588. * Observable raised when the influence changes
  25589. */
  25590. onInfluenceChanged: Observable<boolean>;
  25591. /** @hidden */
  25592. _onDataLayoutChanged: Observable<void>;
  25593. /**
  25594. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25595. */
  25596. get influence(): number;
  25597. set influence(influence: number);
  25598. /**
  25599. * Gets or sets the id of the morph Target
  25600. */
  25601. id: string;
  25602. private _animationPropertiesOverride;
  25603. /**
  25604. * Gets or sets the animation properties override
  25605. */
  25606. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25607. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25608. /**
  25609. * Creates a new MorphTarget
  25610. * @param name defines the name of the target
  25611. * @param influence defines the influence to use
  25612. * @param scene defines the scene the morphtarget belongs to
  25613. */
  25614. constructor(
  25615. /** defines the name of the target */
  25616. name: string, influence?: number, scene?: Nullable<Scene>);
  25617. /**
  25618. * Gets the unique ID of this manager
  25619. */
  25620. get uniqueId(): number;
  25621. /**
  25622. * Gets a boolean defining if the target contains position data
  25623. */
  25624. get hasPositions(): boolean;
  25625. /**
  25626. * Gets a boolean defining if the target contains normal data
  25627. */
  25628. get hasNormals(): boolean;
  25629. /**
  25630. * Gets a boolean defining if the target contains tangent data
  25631. */
  25632. get hasTangents(): boolean;
  25633. /**
  25634. * Gets a boolean defining if the target contains texture coordinates data
  25635. */
  25636. get hasUVs(): boolean;
  25637. /**
  25638. * Affects position data to this target
  25639. * @param data defines the position data to use
  25640. */
  25641. setPositions(data: Nullable<FloatArray>): void;
  25642. /**
  25643. * Gets the position data stored in this target
  25644. * @returns a FloatArray containing the position data (or null if not present)
  25645. */
  25646. getPositions(): Nullable<FloatArray>;
  25647. /**
  25648. * Affects normal data to this target
  25649. * @param data defines the normal data to use
  25650. */
  25651. setNormals(data: Nullable<FloatArray>): void;
  25652. /**
  25653. * Gets the normal data stored in this target
  25654. * @returns a FloatArray containing the normal data (or null if not present)
  25655. */
  25656. getNormals(): Nullable<FloatArray>;
  25657. /**
  25658. * Affects tangent data to this target
  25659. * @param data defines the tangent data to use
  25660. */
  25661. setTangents(data: Nullable<FloatArray>): void;
  25662. /**
  25663. * Gets the tangent data stored in this target
  25664. * @returns a FloatArray containing the tangent data (or null if not present)
  25665. */
  25666. getTangents(): Nullable<FloatArray>;
  25667. /**
  25668. * Affects texture coordinates data to this target
  25669. * @param data defines the texture coordinates data to use
  25670. */
  25671. setUVs(data: Nullable<FloatArray>): void;
  25672. /**
  25673. * Gets the texture coordinates data stored in this target
  25674. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25675. */
  25676. getUVs(): Nullable<FloatArray>;
  25677. /**
  25678. * Clone the current target
  25679. * @returns a new MorphTarget
  25680. */
  25681. clone(): MorphTarget;
  25682. /**
  25683. * Serializes the current target into a Serialization object
  25684. * @returns the serialized object
  25685. */
  25686. serialize(): any;
  25687. /**
  25688. * Returns the string "MorphTarget"
  25689. * @returns "MorphTarget"
  25690. */
  25691. getClassName(): string;
  25692. /**
  25693. * Creates a new target from serialized data
  25694. * @param serializationObject defines the serialized data to use
  25695. * @returns a new MorphTarget
  25696. */
  25697. static Parse(serializationObject: any): MorphTarget;
  25698. /**
  25699. * Creates a MorphTarget from mesh data
  25700. * @param mesh defines the source mesh
  25701. * @param name defines the name to use for the new target
  25702. * @param influence defines the influence to attach to the target
  25703. * @returns a new MorphTarget
  25704. */
  25705. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25706. }
  25707. }
  25708. declare module BABYLON {
  25709. /**
  25710. * This class is used to deform meshes using morphing between different targets
  25711. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25712. */
  25713. export class MorphTargetManager {
  25714. private _targets;
  25715. private _targetInfluenceChangedObservers;
  25716. private _targetDataLayoutChangedObservers;
  25717. private _activeTargets;
  25718. private _scene;
  25719. private _influences;
  25720. private _supportsNormals;
  25721. private _supportsTangents;
  25722. private _supportsUVs;
  25723. private _vertexCount;
  25724. private _uniqueId;
  25725. private _tempInfluences;
  25726. /**
  25727. * Gets or sets a boolean indicating if normals must be morphed
  25728. */
  25729. enableNormalMorphing: boolean;
  25730. /**
  25731. * Gets or sets a boolean indicating if tangents must be morphed
  25732. */
  25733. enableTangentMorphing: boolean;
  25734. /**
  25735. * Gets or sets a boolean indicating if UV must be morphed
  25736. */
  25737. enableUVMorphing: boolean;
  25738. /**
  25739. * Creates a new MorphTargetManager
  25740. * @param scene defines the current scene
  25741. */
  25742. constructor(scene?: Nullable<Scene>);
  25743. /**
  25744. * Gets the unique ID of this manager
  25745. */
  25746. get uniqueId(): number;
  25747. /**
  25748. * Gets the number of vertices handled by this manager
  25749. */
  25750. get vertexCount(): number;
  25751. /**
  25752. * Gets a boolean indicating if this manager supports morphing of normals
  25753. */
  25754. get supportsNormals(): boolean;
  25755. /**
  25756. * Gets a boolean indicating if this manager supports morphing of tangents
  25757. */
  25758. get supportsTangents(): boolean;
  25759. /**
  25760. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25761. */
  25762. get supportsUVs(): boolean;
  25763. /**
  25764. * Gets the number of targets stored in this manager
  25765. */
  25766. get numTargets(): number;
  25767. /**
  25768. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25769. */
  25770. get numInfluencers(): number;
  25771. /**
  25772. * Gets the list of influences (one per target)
  25773. */
  25774. get influences(): Float32Array;
  25775. /**
  25776. * Gets the active target at specified index. An active target is a target with an influence > 0
  25777. * @param index defines the index to check
  25778. * @returns the requested target
  25779. */
  25780. getActiveTarget(index: number): MorphTarget;
  25781. /**
  25782. * Gets the target at specified index
  25783. * @param index defines the index to check
  25784. * @returns the requested target
  25785. */
  25786. getTarget(index: number): MorphTarget;
  25787. /**
  25788. * Add a new target to this manager
  25789. * @param target defines the target to add
  25790. */
  25791. addTarget(target: MorphTarget): void;
  25792. /**
  25793. * Removes a target from the manager
  25794. * @param target defines the target to remove
  25795. */
  25796. removeTarget(target: MorphTarget): void;
  25797. /**
  25798. * Clone the current manager
  25799. * @returns a new MorphTargetManager
  25800. */
  25801. clone(): MorphTargetManager;
  25802. /**
  25803. * Serializes the current manager into a Serialization object
  25804. * @returns the serialized object
  25805. */
  25806. serialize(): any;
  25807. private _syncActiveTargets;
  25808. /**
  25809. * Syncrhonize the targets with all the meshes using this morph target manager
  25810. */
  25811. synchronize(): void;
  25812. /**
  25813. * Creates a new MorphTargetManager from serialized data
  25814. * @param serializationObject defines the serialized data
  25815. * @param scene defines the hosting scene
  25816. * @returns the new MorphTargetManager
  25817. */
  25818. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25819. }
  25820. }
  25821. declare module BABYLON {
  25822. /**
  25823. * Class used to represent a specific level of detail of a mesh
  25824. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25825. */
  25826. export class MeshLODLevel {
  25827. /** Defines the distance where this level should start being displayed */
  25828. distance: number;
  25829. /** Defines the mesh to use to render this level */
  25830. mesh: Nullable<Mesh>;
  25831. /**
  25832. * Creates a new LOD level
  25833. * @param distance defines the distance where this level should star being displayed
  25834. * @param mesh defines the mesh to use to render this level
  25835. */
  25836. constructor(
  25837. /** Defines the distance where this level should start being displayed */
  25838. distance: number,
  25839. /** Defines the mesh to use to render this level */
  25840. mesh: Nullable<Mesh>);
  25841. }
  25842. }
  25843. declare module BABYLON {
  25844. /**
  25845. * Helper class used to generate a canvas to manipulate images
  25846. */
  25847. export class CanvasGenerator {
  25848. /**
  25849. * Create a new canvas (or offscreen canvas depending on the context)
  25850. * @param width defines the expected width
  25851. * @param height defines the expected height
  25852. * @return a new canvas or offscreen canvas
  25853. */
  25854. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  25855. }
  25856. }
  25857. declare module BABYLON {
  25858. /**
  25859. * Mesh representing the gorund
  25860. */
  25861. export class GroundMesh extends Mesh {
  25862. /** If octree should be generated */
  25863. generateOctree: boolean;
  25864. private _heightQuads;
  25865. /** @hidden */
  25866. _subdivisionsX: number;
  25867. /** @hidden */
  25868. _subdivisionsY: number;
  25869. /** @hidden */
  25870. _width: number;
  25871. /** @hidden */
  25872. _height: number;
  25873. /** @hidden */
  25874. _minX: number;
  25875. /** @hidden */
  25876. _maxX: number;
  25877. /** @hidden */
  25878. _minZ: number;
  25879. /** @hidden */
  25880. _maxZ: number;
  25881. constructor(name: string, scene: Scene);
  25882. /**
  25883. * "GroundMesh"
  25884. * @returns "GroundMesh"
  25885. */
  25886. getClassName(): string;
  25887. /**
  25888. * The minimum of x and y subdivisions
  25889. */
  25890. get subdivisions(): number;
  25891. /**
  25892. * X subdivisions
  25893. */
  25894. get subdivisionsX(): number;
  25895. /**
  25896. * Y subdivisions
  25897. */
  25898. get subdivisionsY(): number;
  25899. /**
  25900. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25901. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25902. * @param chunksCount the number of subdivisions for x and y
  25903. * @param octreeBlocksSize (Default: 32)
  25904. */
  25905. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25906. /**
  25907. * Returns a height (y) value in the Worl system :
  25908. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25909. * @param x x coordinate
  25910. * @param z z coordinate
  25911. * @returns the ground y position if (x, z) are outside the ground surface.
  25912. */
  25913. getHeightAtCoordinates(x: number, z: number): number;
  25914. /**
  25915. * Returns a normalized vector (Vector3) orthogonal to the ground
  25916. * at the ground coordinates (x, z) expressed in the World system.
  25917. * @param x x coordinate
  25918. * @param z z coordinate
  25919. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25920. */
  25921. getNormalAtCoordinates(x: number, z: number): Vector3;
  25922. /**
  25923. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25924. * at the ground coordinates (x, z) expressed in the World system.
  25925. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25926. * @param x x coordinate
  25927. * @param z z coordinate
  25928. * @param ref vector to store the result
  25929. * @returns the GroundMesh.
  25930. */
  25931. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25932. /**
  25933. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25934. * if the ground has been updated.
  25935. * This can be used in the render loop.
  25936. * @returns the GroundMesh.
  25937. */
  25938. updateCoordinateHeights(): GroundMesh;
  25939. private _getFacetAt;
  25940. private _initHeightQuads;
  25941. private _computeHeightQuads;
  25942. /**
  25943. * Serializes this ground mesh
  25944. * @param serializationObject object to write serialization to
  25945. */
  25946. serialize(serializationObject: any): void;
  25947. /**
  25948. * Parses a serialized ground mesh
  25949. * @param parsedMesh the serialized mesh
  25950. * @param scene the scene to create the ground mesh in
  25951. * @returns the created ground mesh
  25952. */
  25953. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25954. }
  25955. }
  25956. declare module BABYLON {
  25957. /**
  25958. * Interface for Physics-Joint data
  25959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25960. */
  25961. export interface PhysicsJointData {
  25962. /**
  25963. * The main pivot of the joint
  25964. */
  25965. mainPivot?: Vector3;
  25966. /**
  25967. * The connected pivot of the joint
  25968. */
  25969. connectedPivot?: Vector3;
  25970. /**
  25971. * The main axis of the joint
  25972. */
  25973. mainAxis?: Vector3;
  25974. /**
  25975. * The connected axis of the joint
  25976. */
  25977. connectedAxis?: Vector3;
  25978. /**
  25979. * The collision of the joint
  25980. */
  25981. collision?: boolean;
  25982. /**
  25983. * Native Oimo/Cannon/Energy data
  25984. */
  25985. nativeParams?: any;
  25986. }
  25987. /**
  25988. * This is a holder class for the physics joint created by the physics plugin
  25989. * It holds a set of functions to control the underlying joint
  25990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25991. */
  25992. export class PhysicsJoint {
  25993. /**
  25994. * The type of the physics joint
  25995. */
  25996. type: number;
  25997. /**
  25998. * The data for the physics joint
  25999. */
  26000. jointData: PhysicsJointData;
  26001. private _physicsJoint;
  26002. protected _physicsPlugin: IPhysicsEnginePlugin;
  26003. /**
  26004. * Initializes the physics joint
  26005. * @param type The type of the physics joint
  26006. * @param jointData The data for the physics joint
  26007. */
  26008. constructor(
  26009. /**
  26010. * The type of the physics joint
  26011. */
  26012. type: number,
  26013. /**
  26014. * The data for the physics joint
  26015. */
  26016. jointData: PhysicsJointData);
  26017. /**
  26018. * Gets the physics joint
  26019. */
  26020. get physicsJoint(): any;
  26021. /**
  26022. * Sets the physics joint
  26023. */
  26024. set physicsJoint(newJoint: any);
  26025. /**
  26026. * Sets the physics plugin
  26027. */
  26028. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26029. /**
  26030. * Execute a function that is physics-plugin specific.
  26031. * @param {Function} func the function that will be executed.
  26032. * It accepts two parameters: the physics world and the physics joint
  26033. */
  26034. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26035. /**
  26036. * Distance-Joint type
  26037. */
  26038. static DistanceJoint: number;
  26039. /**
  26040. * Hinge-Joint type
  26041. */
  26042. static HingeJoint: number;
  26043. /**
  26044. * Ball-and-Socket joint type
  26045. */
  26046. static BallAndSocketJoint: number;
  26047. /**
  26048. * Wheel-Joint type
  26049. */
  26050. static WheelJoint: number;
  26051. /**
  26052. * Slider-Joint type
  26053. */
  26054. static SliderJoint: number;
  26055. /**
  26056. * Prismatic-Joint type
  26057. */
  26058. static PrismaticJoint: number;
  26059. /**
  26060. * Universal-Joint type
  26061. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26062. */
  26063. static UniversalJoint: number;
  26064. /**
  26065. * Hinge-Joint 2 type
  26066. */
  26067. static Hinge2Joint: number;
  26068. /**
  26069. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26070. */
  26071. static PointToPointJoint: number;
  26072. /**
  26073. * Spring-Joint type
  26074. */
  26075. static SpringJoint: number;
  26076. /**
  26077. * Lock-Joint type
  26078. */
  26079. static LockJoint: number;
  26080. }
  26081. /**
  26082. * A class representing a physics distance joint
  26083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26084. */
  26085. export class DistanceJoint extends PhysicsJoint {
  26086. /**
  26087. *
  26088. * @param jointData The data for the Distance-Joint
  26089. */
  26090. constructor(jointData: DistanceJointData);
  26091. /**
  26092. * Update the predefined distance.
  26093. * @param maxDistance The maximum preferred distance
  26094. * @param minDistance The minimum preferred distance
  26095. */
  26096. updateDistance(maxDistance: number, minDistance?: number): void;
  26097. }
  26098. /**
  26099. * Represents a Motor-Enabled Joint
  26100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26101. */
  26102. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26103. /**
  26104. * Initializes the Motor-Enabled Joint
  26105. * @param type The type of the joint
  26106. * @param jointData The physica joint data for the joint
  26107. */
  26108. constructor(type: number, jointData: PhysicsJointData);
  26109. /**
  26110. * Set the motor values.
  26111. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26112. * @param force the force to apply
  26113. * @param maxForce max force for this motor.
  26114. */
  26115. setMotor(force?: number, maxForce?: number): void;
  26116. /**
  26117. * Set the motor's limits.
  26118. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26119. * @param upperLimit The upper limit of the motor
  26120. * @param lowerLimit The lower limit of the motor
  26121. */
  26122. setLimit(upperLimit: number, lowerLimit?: number): void;
  26123. }
  26124. /**
  26125. * This class represents a single physics Hinge-Joint
  26126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26127. */
  26128. export class HingeJoint extends MotorEnabledJoint {
  26129. /**
  26130. * Initializes the Hinge-Joint
  26131. * @param jointData The joint data for the Hinge-Joint
  26132. */
  26133. constructor(jointData: PhysicsJointData);
  26134. /**
  26135. * Set the motor values.
  26136. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26137. * @param {number} force the force to apply
  26138. * @param {number} maxForce max force for this motor.
  26139. */
  26140. setMotor(force?: number, maxForce?: number): void;
  26141. /**
  26142. * Set the motor's limits.
  26143. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26144. * @param upperLimit The upper limit of the motor
  26145. * @param lowerLimit The lower limit of the motor
  26146. */
  26147. setLimit(upperLimit: number, lowerLimit?: number): void;
  26148. }
  26149. /**
  26150. * This class represents a dual hinge physics joint (same as wheel joint)
  26151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26152. */
  26153. export class Hinge2Joint extends MotorEnabledJoint {
  26154. /**
  26155. * Initializes the Hinge2-Joint
  26156. * @param jointData The joint data for the Hinge2-Joint
  26157. */
  26158. constructor(jointData: PhysicsJointData);
  26159. /**
  26160. * Set the motor values.
  26161. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26162. * @param {number} targetSpeed the speed the motor is to reach
  26163. * @param {number} maxForce max force for this motor.
  26164. * @param {motorIndex} the motor's index, 0 or 1.
  26165. */
  26166. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26167. /**
  26168. * Set the motor limits.
  26169. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26170. * @param {number} upperLimit the upper limit
  26171. * @param {number} lowerLimit lower limit
  26172. * @param {motorIndex} the motor's index, 0 or 1.
  26173. */
  26174. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26175. }
  26176. /**
  26177. * Interface for a motor enabled joint
  26178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26179. */
  26180. export interface IMotorEnabledJoint {
  26181. /**
  26182. * Physics joint
  26183. */
  26184. physicsJoint: any;
  26185. /**
  26186. * Sets the motor of the motor-enabled joint
  26187. * @param force The force of the motor
  26188. * @param maxForce The maximum force of the motor
  26189. * @param motorIndex The index of the motor
  26190. */
  26191. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26192. /**
  26193. * Sets the limit of the motor
  26194. * @param upperLimit The upper limit of the motor
  26195. * @param lowerLimit The lower limit of the motor
  26196. * @param motorIndex The index of the motor
  26197. */
  26198. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26199. }
  26200. /**
  26201. * Joint data for a Distance-Joint
  26202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26203. */
  26204. export interface DistanceJointData extends PhysicsJointData {
  26205. /**
  26206. * Max distance the 2 joint objects can be apart
  26207. */
  26208. maxDistance: number;
  26209. }
  26210. /**
  26211. * Joint data from a spring joint
  26212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26213. */
  26214. export interface SpringJointData extends PhysicsJointData {
  26215. /**
  26216. * Length of the spring
  26217. */
  26218. length: number;
  26219. /**
  26220. * Stiffness of the spring
  26221. */
  26222. stiffness: number;
  26223. /**
  26224. * Damping of the spring
  26225. */
  26226. damping: number;
  26227. /** this callback will be called when applying the force to the impostors. */
  26228. forceApplicationCallback: () => void;
  26229. }
  26230. }
  26231. declare module BABYLON {
  26232. /**
  26233. * Holds the data for the raycast result
  26234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26235. */
  26236. export class PhysicsRaycastResult {
  26237. private _hasHit;
  26238. private _hitDistance;
  26239. private _hitNormalWorld;
  26240. private _hitPointWorld;
  26241. private _rayFromWorld;
  26242. private _rayToWorld;
  26243. /**
  26244. * Gets if there was a hit
  26245. */
  26246. get hasHit(): boolean;
  26247. /**
  26248. * Gets the distance from the hit
  26249. */
  26250. get hitDistance(): number;
  26251. /**
  26252. * Gets the hit normal/direction in the world
  26253. */
  26254. get hitNormalWorld(): Vector3;
  26255. /**
  26256. * Gets the hit point in the world
  26257. */
  26258. get hitPointWorld(): Vector3;
  26259. /**
  26260. * Gets the ray "start point" of the ray in the world
  26261. */
  26262. get rayFromWorld(): Vector3;
  26263. /**
  26264. * Gets the ray "end point" of the ray in the world
  26265. */
  26266. get rayToWorld(): Vector3;
  26267. /**
  26268. * Sets the hit data (normal & point in world space)
  26269. * @param hitNormalWorld defines the normal in world space
  26270. * @param hitPointWorld defines the point in world space
  26271. */
  26272. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26273. /**
  26274. * Sets the distance from the start point to the hit point
  26275. * @param distance
  26276. */
  26277. setHitDistance(distance: number): void;
  26278. /**
  26279. * Calculates the distance manually
  26280. */
  26281. calculateHitDistance(): void;
  26282. /**
  26283. * Resets all the values to default
  26284. * @param from The from point on world space
  26285. * @param to The to point on world space
  26286. */
  26287. reset(from?: Vector3, to?: Vector3): void;
  26288. }
  26289. /**
  26290. * Interface for the size containing width and height
  26291. */
  26292. interface IXYZ {
  26293. /**
  26294. * X
  26295. */
  26296. x: number;
  26297. /**
  26298. * Y
  26299. */
  26300. y: number;
  26301. /**
  26302. * Z
  26303. */
  26304. z: number;
  26305. }
  26306. }
  26307. declare module BABYLON {
  26308. /**
  26309. * Interface used to describe a physics joint
  26310. */
  26311. export interface PhysicsImpostorJoint {
  26312. /** Defines the main impostor to which the joint is linked */
  26313. mainImpostor: PhysicsImpostor;
  26314. /** Defines the impostor that is connected to the main impostor using this joint */
  26315. connectedImpostor: PhysicsImpostor;
  26316. /** Defines the joint itself */
  26317. joint: PhysicsJoint;
  26318. }
  26319. /** @hidden */
  26320. export interface IPhysicsEnginePlugin {
  26321. world: any;
  26322. name: string;
  26323. setGravity(gravity: Vector3): void;
  26324. setTimeStep(timeStep: number): void;
  26325. getTimeStep(): number;
  26326. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26327. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26328. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26329. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26330. removePhysicsBody(impostor: PhysicsImpostor): void;
  26331. generateJoint(joint: PhysicsImpostorJoint): void;
  26332. removeJoint(joint: PhysicsImpostorJoint): void;
  26333. isSupported(): boolean;
  26334. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26335. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26336. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26337. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26338. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26339. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26340. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26341. getBodyMass(impostor: PhysicsImpostor): number;
  26342. getBodyFriction(impostor: PhysicsImpostor): number;
  26343. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26344. getBodyRestitution(impostor: PhysicsImpostor): number;
  26345. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26346. getBodyPressure?(impostor: PhysicsImpostor): number;
  26347. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26348. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26349. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26350. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26351. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26352. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26353. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26354. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26355. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26356. sleepBody(impostor: PhysicsImpostor): void;
  26357. wakeUpBody(impostor: PhysicsImpostor): void;
  26358. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26359. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26360. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26361. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26362. getRadius(impostor: PhysicsImpostor): number;
  26363. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26364. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26365. dispose(): void;
  26366. }
  26367. /**
  26368. * Interface used to define a physics engine
  26369. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26370. */
  26371. export interface IPhysicsEngine {
  26372. /**
  26373. * Gets the gravity vector used by the simulation
  26374. */
  26375. gravity: Vector3;
  26376. /**
  26377. * Sets the gravity vector used by the simulation
  26378. * @param gravity defines the gravity vector to use
  26379. */
  26380. setGravity(gravity: Vector3): void;
  26381. /**
  26382. * Set the time step of the physics engine.
  26383. * Default is 1/60.
  26384. * To slow it down, enter 1/600 for example.
  26385. * To speed it up, 1/30
  26386. * @param newTimeStep the new timestep to apply to this world.
  26387. */
  26388. setTimeStep(newTimeStep: number): void;
  26389. /**
  26390. * Get the time step of the physics engine.
  26391. * @returns the current time step
  26392. */
  26393. getTimeStep(): number;
  26394. /**
  26395. * Set the sub time step of the physics engine.
  26396. * Default is 0 meaning there is no sub steps
  26397. * To increase physics resolution precision, set a small value (like 1 ms)
  26398. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26399. */
  26400. setSubTimeStep(subTimeStep: number): void;
  26401. /**
  26402. * Get the sub time step of the physics engine.
  26403. * @returns the current sub time step
  26404. */
  26405. getSubTimeStep(): number;
  26406. /**
  26407. * Release all resources
  26408. */
  26409. dispose(): void;
  26410. /**
  26411. * Gets the name of the current physics plugin
  26412. * @returns the name of the plugin
  26413. */
  26414. getPhysicsPluginName(): string;
  26415. /**
  26416. * Adding a new impostor for the impostor tracking.
  26417. * This will be done by the impostor itself.
  26418. * @param impostor the impostor to add
  26419. */
  26420. addImpostor(impostor: PhysicsImpostor): void;
  26421. /**
  26422. * Remove an impostor from the engine.
  26423. * This impostor and its mesh will not longer be updated by the physics engine.
  26424. * @param impostor the impostor to remove
  26425. */
  26426. removeImpostor(impostor: PhysicsImpostor): void;
  26427. /**
  26428. * Add a joint to the physics engine
  26429. * @param mainImpostor defines the main impostor to which the joint is added.
  26430. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26431. * @param joint defines the joint that will connect both impostors.
  26432. */
  26433. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26434. /**
  26435. * Removes a joint from the simulation
  26436. * @param mainImpostor defines the impostor used with the joint
  26437. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26438. * @param joint defines the joint to remove
  26439. */
  26440. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26441. /**
  26442. * Gets the current plugin used to run the simulation
  26443. * @returns current plugin
  26444. */
  26445. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26446. /**
  26447. * Gets the list of physic impostors
  26448. * @returns an array of PhysicsImpostor
  26449. */
  26450. getImpostors(): Array<PhysicsImpostor>;
  26451. /**
  26452. * Gets the impostor for a physics enabled object
  26453. * @param object defines the object impersonated by the impostor
  26454. * @returns the PhysicsImpostor or null if not found
  26455. */
  26456. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26457. /**
  26458. * Gets the impostor for a physics body object
  26459. * @param body defines physics body used by the impostor
  26460. * @returns the PhysicsImpostor or null if not found
  26461. */
  26462. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26463. /**
  26464. * Does a raycast in the physics world
  26465. * @param from when should the ray start?
  26466. * @param to when should the ray end?
  26467. * @returns PhysicsRaycastResult
  26468. */
  26469. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26470. /**
  26471. * Called by the scene. No need to call it.
  26472. * @param delta defines the timespam between frames
  26473. */
  26474. _step(delta: number): void;
  26475. }
  26476. }
  26477. declare module BABYLON {
  26478. /**
  26479. * The interface for the physics imposter parameters
  26480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26481. */
  26482. export interface PhysicsImpostorParameters {
  26483. /**
  26484. * The mass of the physics imposter
  26485. */
  26486. mass: number;
  26487. /**
  26488. * The friction of the physics imposter
  26489. */
  26490. friction?: number;
  26491. /**
  26492. * The coefficient of restitution of the physics imposter
  26493. */
  26494. restitution?: number;
  26495. /**
  26496. * The native options of the physics imposter
  26497. */
  26498. nativeOptions?: any;
  26499. /**
  26500. * Specifies if the parent should be ignored
  26501. */
  26502. ignoreParent?: boolean;
  26503. /**
  26504. * Specifies if bi-directional transformations should be disabled
  26505. */
  26506. disableBidirectionalTransformation?: boolean;
  26507. /**
  26508. * The pressure inside the physics imposter, soft object only
  26509. */
  26510. pressure?: number;
  26511. /**
  26512. * The stiffness the physics imposter, soft object only
  26513. */
  26514. stiffness?: number;
  26515. /**
  26516. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26517. */
  26518. velocityIterations?: number;
  26519. /**
  26520. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26521. */
  26522. positionIterations?: number;
  26523. /**
  26524. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26525. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26526. * Add to fix multiple points
  26527. */
  26528. fixedPoints?: number;
  26529. /**
  26530. * The collision margin around a soft object
  26531. */
  26532. margin?: number;
  26533. /**
  26534. * The collision margin around a soft object
  26535. */
  26536. damping?: number;
  26537. /**
  26538. * The path for a rope based on an extrusion
  26539. */
  26540. path?: any;
  26541. /**
  26542. * The shape of an extrusion used for a rope based on an extrusion
  26543. */
  26544. shape?: any;
  26545. }
  26546. /**
  26547. * Interface for a physics-enabled object
  26548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26549. */
  26550. export interface IPhysicsEnabledObject {
  26551. /**
  26552. * The position of the physics-enabled object
  26553. */
  26554. position: Vector3;
  26555. /**
  26556. * The rotation of the physics-enabled object
  26557. */
  26558. rotationQuaternion: Nullable<Quaternion>;
  26559. /**
  26560. * The scale of the physics-enabled object
  26561. */
  26562. scaling: Vector3;
  26563. /**
  26564. * The rotation of the physics-enabled object
  26565. */
  26566. rotation?: Vector3;
  26567. /**
  26568. * The parent of the physics-enabled object
  26569. */
  26570. parent?: any;
  26571. /**
  26572. * The bounding info of the physics-enabled object
  26573. * @returns The bounding info of the physics-enabled object
  26574. */
  26575. getBoundingInfo(): BoundingInfo;
  26576. /**
  26577. * Computes the world matrix
  26578. * @param force Specifies if the world matrix should be computed by force
  26579. * @returns A world matrix
  26580. */
  26581. computeWorldMatrix(force: boolean): Matrix;
  26582. /**
  26583. * Gets the world matrix
  26584. * @returns A world matrix
  26585. */
  26586. getWorldMatrix?(): Matrix;
  26587. /**
  26588. * Gets the child meshes
  26589. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26590. * @returns An array of abstract meshes
  26591. */
  26592. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26593. /**
  26594. * Gets the vertex data
  26595. * @param kind The type of vertex data
  26596. * @returns A nullable array of numbers, or a float32 array
  26597. */
  26598. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26599. /**
  26600. * Gets the indices from the mesh
  26601. * @returns A nullable array of index arrays
  26602. */
  26603. getIndices?(): Nullable<IndicesArray>;
  26604. /**
  26605. * Gets the scene from the mesh
  26606. * @returns the indices array or null
  26607. */
  26608. getScene?(): Scene;
  26609. /**
  26610. * Gets the absolute position from the mesh
  26611. * @returns the absolute position
  26612. */
  26613. getAbsolutePosition(): Vector3;
  26614. /**
  26615. * Gets the absolute pivot point from the mesh
  26616. * @returns the absolute pivot point
  26617. */
  26618. getAbsolutePivotPoint(): Vector3;
  26619. /**
  26620. * Rotates the mesh
  26621. * @param axis The axis of rotation
  26622. * @param amount The amount of rotation
  26623. * @param space The space of the rotation
  26624. * @returns The rotation transform node
  26625. */
  26626. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26627. /**
  26628. * Translates the mesh
  26629. * @param axis The axis of translation
  26630. * @param distance The distance of translation
  26631. * @param space The space of the translation
  26632. * @returns The transform node
  26633. */
  26634. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26635. /**
  26636. * Sets the absolute position of the mesh
  26637. * @param absolutePosition The absolute position of the mesh
  26638. * @returns The transform node
  26639. */
  26640. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26641. /**
  26642. * Gets the class name of the mesh
  26643. * @returns The class name
  26644. */
  26645. getClassName(): string;
  26646. }
  26647. /**
  26648. * Represents a physics imposter
  26649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26650. */
  26651. export class PhysicsImpostor {
  26652. /**
  26653. * The physics-enabled object used as the physics imposter
  26654. */
  26655. object: IPhysicsEnabledObject;
  26656. /**
  26657. * The type of the physics imposter
  26658. */
  26659. type: number;
  26660. private _options;
  26661. private _scene?;
  26662. /**
  26663. * The default object size of the imposter
  26664. */
  26665. static DEFAULT_OBJECT_SIZE: Vector3;
  26666. /**
  26667. * The identity quaternion of the imposter
  26668. */
  26669. static IDENTITY_QUATERNION: Quaternion;
  26670. /** @hidden */
  26671. _pluginData: any;
  26672. private _physicsEngine;
  26673. private _physicsBody;
  26674. private _bodyUpdateRequired;
  26675. private _onBeforePhysicsStepCallbacks;
  26676. private _onAfterPhysicsStepCallbacks;
  26677. /** @hidden */
  26678. _onPhysicsCollideCallbacks: Array<{
  26679. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26680. otherImpostors: Array<PhysicsImpostor>;
  26681. }>;
  26682. private _deltaPosition;
  26683. private _deltaRotation;
  26684. private _deltaRotationConjugated;
  26685. /** @hidden */
  26686. _isFromLine: boolean;
  26687. private _parent;
  26688. private _isDisposed;
  26689. private static _tmpVecs;
  26690. private static _tmpQuat;
  26691. /**
  26692. * Specifies if the physics imposter is disposed
  26693. */
  26694. get isDisposed(): boolean;
  26695. /**
  26696. * Gets the mass of the physics imposter
  26697. */
  26698. get mass(): number;
  26699. set mass(value: number);
  26700. /**
  26701. * Gets the coefficient of friction
  26702. */
  26703. get friction(): number;
  26704. /**
  26705. * Sets the coefficient of friction
  26706. */
  26707. set friction(value: number);
  26708. /**
  26709. * Gets the coefficient of restitution
  26710. */
  26711. get restitution(): number;
  26712. /**
  26713. * Sets the coefficient of restitution
  26714. */
  26715. set restitution(value: number);
  26716. /**
  26717. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26718. */
  26719. get pressure(): number;
  26720. /**
  26721. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26722. */
  26723. set pressure(value: number);
  26724. /**
  26725. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26726. */
  26727. get stiffness(): number;
  26728. /**
  26729. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26730. */
  26731. set stiffness(value: number);
  26732. /**
  26733. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26734. */
  26735. get velocityIterations(): number;
  26736. /**
  26737. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26738. */
  26739. set velocityIterations(value: number);
  26740. /**
  26741. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26742. */
  26743. get positionIterations(): number;
  26744. /**
  26745. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26746. */
  26747. set positionIterations(value: number);
  26748. /**
  26749. * The unique id of the physics imposter
  26750. * set by the physics engine when adding this impostor to the array
  26751. */
  26752. uniqueId: number;
  26753. /**
  26754. * @hidden
  26755. */
  26756. soft: boolean;
  26757. /**
  26758. * @hidden
  26759. */
  26760. segments: number;
  26761. private _joints;
  26762. /**
  26763. * Initializes the physics imposter
  26764. * @param object The physics-enabled object used as the physics imposter
  26765. * @param type The type of the physics imposter
  26766. * @param _options The options for the physics imposter
  26767. * @param _scene The Babylon scene
  26768. */
  26769. constructor(
  26770. /**
  26771. * The physics-enabled object used as the physics imposter
  26772. */
  26773. object: IPhysicsEnabledObject,
  26774. /**
  26775. * The type of the physics imposter
  26776. */
  26777. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26778. /**
  26779. * This function will completly initialize this impostor.
  26780. * It will create a new body - but only if this mesh has no parent.
  26781. * If it has, this impostor will not be used other than to define the impostor
  26782. * of the child mesh.
  26783. * @hidden
  26784. */
  26785. _init(): void;
  26786. private _getPhysicsParent;
  26787. /**
  26788. * Should a new body be generated.
  26789. * @returns boolean specifying if body initialization is required
  26790. */
  26791. isBodyInitRequired(): boolean;
  26792. /**
  26793. * Sets the updated scaling
  26794. * @param updated Specifies if the scaling is updated
  26795. */
  26796. setScalingUpdated(): void;
  26797. /**
  26798. * Force a regeneration of this or the parent's impostor's body.
  26799. * Use under cautious - This will remove all joints already implemented.
  26800. */
  26801. forceUpdate(): void;
  26802. /**
  26803. * Gets the body that holds this impostor. Either its own, or its parent.
  26804. */
  26805. get physicsBody(): any;
  26806. /**
  26807. * Get the parent of the physics imposter
  26808. * @returns Physics imposter or null
  26809. */
  26810. get parent(): Nullable<PhysicsImpostor>;
  26811. /**
  26812. * Sets the parent of the physics imposter
  26813. */
  26814. set parent(value: Nullable<PhysicsImpostor>);
  26815. /**
  26816. * Set the physics body. Used mainly by the physics engine/plugin
  26817. */
  26818. set physicsBody(physicsBody: any);
  26819. /**
  26820. * Resets the update flags
  26821. */
  26822. resetUpdateFlags(): void;
  26823. /**
  26824. * Gets the object extend size
  26825. * @returns the object extend size
  26826. */
  26827. getObjectExtendSize(): Vector3;
  26828. /**
  26829. * Gets the object center
  26830. * @returns The object center
  26831. */
  26832. getObjectCenter(): Vector3;
  26833. /**
  26834. * Get a specific parameter from the options parameters
  26835. * @param paramName The object parameter name
  26836. * @returns The object parameter
  26837. */
  26838. getParam(paramName: string): any;
  26839. /**
  26840. * Sets a specific parameter in the options given to the physics plugin
  26841. * @param paramName The parameter name
  26842. * @param value The value of the parameter
  26843. */
  26844. setParam(paramName: string, value: number): void;
  26845. /**
  26846. * Specifically change the body's mass option. Won't recreate the physics body object
  26847. * @param mass The mass of the physics imposter
  26848. */
  26849. setMass(mass: number): void;
  26850. /**
  26851. * Gets the linear velocity
  26852. * @returns linear velocity or null
  26853. */
  26854. getLinearVelocity(): Nullable<Vector3>;
  26855. /**
  26856. * Sets the linear velocity
  26857. * @param velocity linear velocity or null
  26858. */
  26859. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26860. /**
  26861. * Gets the angular velocity
  26862. * @returns angular velocity or null
  26863. */
  26864. getAngularVelocity(): Nullable<Vector3>;
  26865. /**
  26866. * Sets the angular velocity
  26867. * @param velocity The velocity or null
  26868. */
  26869. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26870. /**
  26871. * Execute a function with the physics plugin native code
  26872. * Provide a function the will have two variables - the world object and the physics body object
  26873. * @param func The function to execute with the physics plugin native code
  26874. */
  26875. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26876. /**
  26877. * Register a function that will be executed before the physics world is stepping forward
  26878. * @param func The function to execute before the physics world is stepped forward
  26879. */
  26880. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26881. /**
  26882. * Unregister a function that will be executed before the physics world is stepping forward
  26883. * @param func The function to execute before the physics world is stepped forward
  26884. */
  26885. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26886. /**
  26887. * Register a function that will be executed after the physics step
  26888. * @param func The function to execute after physics step
  26889. */
  26890. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26891. /**
  26892. * Unregisters a function that will be executed after the physics step
  26893. * @param func The function to execute after physics step
  26894. */
  26895. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26896. /**
  26897. * register a function that will be executed when this impostor collides against a different body
  26898. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26899. * @param func Callback that is executed on collision
  26900. */
  26901. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26902. /**
  26903. * Unregisters the physics imposter on contact
  26904. * @param collideAgainst The physics object to collide against
  26905. * @param func Callback to execute on collision
  26906. */
  26907. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26908. private _tmpQuat;
  26909. private _tmpQuat2;
  26910. /**
  26911. * Get the parent rotation
  26912. * @returns The parent rotation
  26913. */
  26914. getParentsRotation(): Quaternion;
  26915. /**
  26916. * this function is executed by the physics engine.
  26917. */
  26918. beforeStep: () => void;
  26919. /**
  26920. * this function is executed by the physics engine
  26921. */
  26922. afterStep: () => void;
  26923. /**
  26924. * Legacy collision detection event support
  26925. */
  26926. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26927. /**
  26928. * event and body object due to cannon's event-based architecture.
  26929. */
  26930. onCollide: (e: {
  26931. body: any;
  26932. }) => void;
  26933. /**
  26934. * Apply a force
  26935. * @param force The force to apply
  26936. * @param contactPoint The contact point for the force
  26937. * @returns The physics imposter
  26938. */
  26939. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26940. /**
  26941. * Apply an impulse
  26942. * @param force The impulse force
  26943. * @param contactPoint The contact point for the impulse force
  26944. * @returns The physics imposter
  26945. */
  26946. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26947. /**
  26948. * A help function to create a joint
  26949. * @param otherImpostor A physics imposter used to create a joint
  26950. * @param jointType The type of joint
  26951. * @param jointData The data for the joint
  26952. * @returns The physics imposter
  26953. */
  26954. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26955. /**
  26956. * Add a joint to this impostor with a different impostor
  26957. * @param otherImpostor A physics imposter used to add a joint
  26958. * @param joint The joint to add
  26959. * @returns The physics imposter
  26960. */
  26961. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26962. /**
  26963. * Add an anchor to a cloth impostor
  26964. * @param otherImpostor rigid impostor to anchor to
  26965. * @param width ratio across width from 0 to 1
  26966. * @param height ratio up height from 0 to 1
  26967. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26968. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  26969. * @returns impostor the soft imposter
  26970. */
  26971. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26972. /**
  26973. * Add a hook to a rope impostor
  26974. * @param otherImpostor rigid impostor to anchor to
  26975. * @param length ratio across rope from 0 to 1
  26976. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  26977. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  26978. * @returns impostor the rope imposter
  26979. */
  26980. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26981. /**
  26982. * Will keep this body still, in a sleep mode.
  26983. * @returns the physics imposter
  26984. */
  26985. sleep(): PhysicsImpostor;
  26986. /**
  26987. * Wake the body up.
  26988. * @returns The physics imposter
  26989. */
  26990. wakeUp(): PhysicsImpostor;
  26991. /**
  26992. * Clones the physics imposter
  26993. * @param newObject The physics imposter clones to this physics-enabled object
  26994. * @returns A nullable physics imposter
  26995. */
  26996. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26997. /**
  26998. * Disposes the physics imposter
  26999. */
  27000. dispose(): void;
  27001. /**
  27002. * Sets the delta position
  27003. * @param position The delta position amount
  27004. */
  27005. setDeltaPosition(position: Vector3): void;
  27006. /**
  27007. * Sets the delta rotation
  27008. * @param rotation The delta rotation amount
  27009. */
  27010. setDeltaRotation(rotation: Quaternion): void;
  27011. /**
  27012. * Gets the box size of the physics imposter and stores the result in the input parameter
  27013. * @param result Stores the box size
  27014. * @returns The physics imposter
  27015. */
  27016. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27017. /**
  27018. * Gets the radius of the physics imposter
  27019. * @returns Radius of the physics imposter
  27020. */
  27021. getRadius(): number;
  27022. /**
  27023. * Sync a bone with this impostor
  27024. * @param bone The bone to sync to the impostor.
  27025. * @param boneMesh The mesh that the bone is influencing.
  27026. * @param jointPivot The pivot of the joint / bone in local space.
  27027. * @param distToJoint Optional distance from the impostor to the joint.
  27028. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27029. */
  27030. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27031. /**
  27032. * Sync impostor to a bone
  27033. * @param bone The bone that the impostor will be synced to.
  27034. * @param boneMesh The mesh that the bone is influencing.
  27035. * @param jointPivot The pivot of the joint / bone in local space.
  27036. * @param distToJoint Optional distance from the impostor to the joint.
  27037. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27038. * @param boneAxis Optional vector3 axis the bone is aligned with
  27039. */
  27040. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27041. /**
  27042. * No-Imposter type
  27043. */
  27044. static NoImpostor: number;
  27045. /**
  27046. * Sphere-Imposter type
  27047. */
  27048. static SphereImpostor: number;
  27049. /**
  27050. * Box-Imposter type
  27051. */
  27052. static BoxImpostor: number;
  27053. /**
  27054. * Plane-Imposter type
  27055. */
  27056. static PlaneImpostor: number;
  27057. /**
  27058. * Mesh-imposter type
  27059. */
  27060. static MeshImpostor: number;
  27061. /**
  27062. * Capsule-Impostor type (Ammo.js plugin only)
  27063. */
  27064. static CapsuleImpostor: number;
  27065. /**
  27066. * Cylinder-Imposter type
  27067. */
  27068. static CylinderImpostor: number;
  27069. /**
  27070. * Particle-Imposter type
  27071. */
  27072. static ParticleImpostor: number;
  27073. /**
  27074. * Heightmap-Imposter type
  27075. */
  27076. static HeightmapImpostor: number;
  27077. /**
  27078. * ConvexHull-Impostor type (Ammo.js plugin only)
  27079. */
  27080. static ConvexHullImpostor: number;
  27081. /**
  27082. * Custom-Imposter type (Ammo.js plugin only)
  27083. */
  27084. static CustomImpostor: number;
  27085. /**
  27086. * Rope-Imposter type
  27087. */
  27088. static RopeImpostor: number;
  27089. /**
  27090. * Cloth-Imposter type
  27091. */
  27092. static ClothImpostor: number;
  27093. /**
  27094. * Softbody-Imposter type
  27095. */
  27096. static SoftbodyImpostor: number;
  27097. }
  27098. }
  27099. declare module BABYLON {
  27100. /**
  27101. * @hidden
  27102. **/
  27103. export class _CreationDataStorage {
  27104. closePath?: boolean;
  27105. closeArray?: boolean;
  27106. idx: number[];
  27107. dashSize: number;
  27108. gapSize: number;
  27109. path3D: Path3D;
  27110. pathArray: Vector3[][];
  27111. arc: number;
  27112. radius: number;
  27113. cap: number;
  27114. tessellation: number;
  27115. }
  27116. /**
  27117. * @hidden
  27118. **/
  27119. class _InstanceDataStorage {
  27120. visibleInstances: any;
  27121. batchCache: _InstancesBatch;
  27122. instancesBufferSize: number;
  27123. instancesBuffer: Nullable<Buffer>;
  27124. instancesData: Float32Array;
  27125. overridenInstanceCount: number;
  27126. isFrozen: boolean;
  27127. previousBatch: Nullable<_InstancesBatch>;
  27128. hardwareInstancedRendering: boolean;
  27129. sideOrientation: number;
  27130. manualUpdate: boolean;
  27131. }
  27132. /**
  27133. * @hidden
  27134. **/
  27135. export class _InstancesBatch {
  27136. mustReturn: boolean;
  27137. visibleInstances: Nullable<InstancedMesh[]>[];
  27138. renderSelf: boolean[];
  27139. hardwareInstancedRendering: boolean[];
  27140. }
  27141. /**
  27142. * @hidden
  27143. **/
  27144. class _ThinInstanceDataStorage {
  27145. instancesCount: number;
  27146. matrixBuffer: Nullable<Buffer>;
  27147. matrixBufferSize: number;
  27148. matrixData: Nullable<Float32Array>;
  27149. boundingVectors: Array<Vector3>;
  27150. }
  27151. /**
  27152. * Class used to represent renderable models
  27153. */
  27154. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27155. /**
  27156. * Mesh side orientation : usually the external or front surface
  27157. */
  27158. static readonly FRONTSIDE: number;
  27159. /**
  27160. * Mesh side orientation : usually the internal or back surface
  27161. */
  27162. static readonly BACKSIDE: number;
  27163. /**
  27164. * Mesh side orientation : both internal and external or front and back surfaces
  27165. */
  27166. static readonly DOUBLESIDE: number;
  27167. /**
  27168. * Mesh side orientation : by default, `FRONTSIDE`
  27169. */
  27170. static readonly DEFAULTSIDE: number;
  27171. /**
  27172. * Mesh cap setting : no cap
  27173. */
  27174. static readonly NO_CAP: number;
  27175. /**
  27176. * Mesh cap setting : one cap at the beginning of the mesh
  27177. */
  27178. static readonly CAP_START: number;
  27179. /**
  27180. * Mesh cap setting : one cap at the end of the mesh
  27181. */
  27182. static readonly CAP_END: number;
  27183. /**
  27184. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27185. */
  27186. static readonly CAP_ALL: number;
  27187. /**
  27188. * Mesh pattern setting : no flip or rotate
  27189. */
  27190. static readonly NO_FLIP: number;
  27191. /**
  27192. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27193. */
  27194. static readonly FLIP_TILE: number;
  27195. /**
  27196. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27197. */
  27198. static readonly ROTATE_TILE: number;
  27199. /**
  27200. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27201. */
  27202. static readonly FLIP_ROW: number;
  27203. /**
  27204. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27205. */
  27206. static readonly ROTATE_ROW: number;
  27207. /**
  27208. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27209. */
  27210. static readonly FLIP_N_ROTATE_TILE: number;
  27211. /**
  27212. * Mesh pattern setting : rotate pattern and rotate
  27213. */
  27214. static readonly FLIP_N_ROTATE_ROW: number;
  27215. /**
  27216. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27217. */
  27218. static readonly CENTER: number;
  27219. /**
  27220. * Mesh tile positioning : part tiles on left
  27221. */
  27222. static readonly LEFT: number;
  27223. /**
  27224. * Mesh tile positioning : part tiles on right
  27225. */
  27226. static readonly RIGHT: number;
  27227. /**
  27228. * Mesh tile positioning : part tiles on top
  27229. */
  27230. static readonly TOP: number;
  27231. /**
  27232. * Mesh tile positioning : part tiles on bottom
  27233. */
  27234. static readonly BOTTOM: number;
  27235. /**
  27236. * Gets the default side orientation.
  27237. * @param orientation the orientation to value to attempt to get
  27238. * @returns the default orientation
  27239. * @hidden
  27240. */
  27241. static _GetDefaultSideOrientation(orientation?: number): number;
  27242. private _internalMeshDataInfo;
  27243. /**
  27244. * An event triggered before rendering the mesh
  27245. */
  27246. get onBeforeRenderObservable(): Observable<Mesh>;
  27247. /**
  27248. * An event triggered before binding the mesh
  27249. */
  27250. get onBeforeBindObservable(): Observable<Mesh>;
  27251. /**
  27252. * An event triggered after rendering the mesh
  27253. */
  27254. get onAfterRenderObservable(): Observable<Mesh>;
  27255. /**
  27256. * An event triggered before drawing the mesh
  27257. */
  27258. get onBeforeDrawObservable(): Observable<Mesh>;
  27259. private _onBeforeDrawObserver;
  27260. /**
  27261. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27262. */
  27263. set onBeforeDraw(callback: () => void);
  27264. get hasInstances(): boolean;
  27265. get hasThinInstances(): boolean;
  27266. /**
  27267. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27268. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27269. */
  27270. delayLoadState: number;
  27271. /**
  27272. * Gets the list of instances created from this mesh
  27273. * it is not supposed to be modified manually.
  27274. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27275. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27276. */
  27277. instances: InstancedMesh[];
  27278. /**
  27279. * Gets the file containing delay loading data for this mesh
  27280. */
  27281. delayLoadingFile: string;
  27282. /** @hidden */
  27283. _binaryInfo: any;
  27284. /**
  27285. * User defined function used to change how LOD level selection is done
  27286. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27287. */
  27288. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27289. /**
  27290. * Gets or sets the morph target manager
  27291. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27292. */
  27293. get morphTargetManager(): Nullable<MorphTargetManager>;
  27294. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27295. /** @hidden */
  27296. _creationDataStorage: Nullable<_CreationDataStorage>;
  27297. /** @hidden */
  27298. _geometry: Nullable<Geometry>;
  27299. /** @hidden */
  27300. _delayInfo: Array<string>;
  27301. /** @hidden */
  27302. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27303. /** @hidden */
  27304. _instanceDataStorage: _InstanceDataStorage;
  27305. /** @hidden */
  27306. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27307. private _effectiveMaterial;
  27308. /** @hidden */
  27309. _shouldGenerateFlatShading: boolean;
  27310. /** @hidden */
  27311. _originalBuilderSideOrientation: number;
  27312. /**
  27313. * Use this property to change the original side orientation defined at construction time
  27314. */
  27315. overrideMaterialSideOrientation: Nullable<number>;
  27316. /**
  27317. * Gets the source mesh (the one used to clone this one from)
  27318. */
  27319. get source(): Nullable<Mesh>;
  27320. /**
  27321. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27322. */
  27323. get isUnIndexed(): boolean;
  27324. set isUnIndexed(value: boolean);
  27325. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27326. get worldMatrixInstancedBuffer(): Float32Array;
  27327. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27328. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27329. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27330. /**
  27331. * @constructor
  27332. * @param name The value used by scene.getMeshByName() to do a lookup.
  27333. * @param scene The scene to add this mesh to.
  27334. * @param parent The parent of this mesh, if it has one
  27335. * @param source An optional Mesh from which geometry is shared, cloned.
  27336. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27337. * When false, achieved by calling a clone(), also passing False.
  27338. * This will make creation of children, recursive.
  27339. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27340. */
  27341. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27342. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27343. doNotInstantiate: boolean;
  27344. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27345. /**
  27346. * Gets the class name
  27347. * @returns the string "Mesh".
  27348. */
  27349. getClassName(): string;
  27350. /** @hidden */
  27351. get _isMesh(): boolean;
  27352. /**
  27353. * Returns a description of this mesh
  27354. * @param fullDetails define if full details about this mesh must be used
  27355. * @returns a descriptive string representing this mesh
  27356. */
  27357. toString(fullDetails?: boolean): string;
  27358. /** @hidden */
  27359. _unBindEffect(): void;
  27360. /**
  27361. * Gets a boolean indicating if this mesh has LOD
  27362. */
  27363. get hasLODLevels(): boolean;
  27364. /**
  27365. * Gets the list of MeshLODLevel associated with the current mesh
  27366. * @returns an array of MeshLODLevel
  27367. */
  27368. getLODLevels(): MeshLODLevel[];
  27369. private _sortLODLevels;
  27370. /**
  27371. * Add a mesh as LOD level triggered at the given distance.
  27372. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27373. * @param distance The distance from the center of the object to show this level
  27374. * @param mesh The mesh to be added as LOD level (can be null)
  27375. * @return This mesh (for chaining)
  27376. */
  27377. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27378. /**
  27379. * Returns the LOD level mesh at the passed distance or null if not found.
  27380. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27381. * @param distance The distance from the center of the object to show this level
  27382. * @returns a Mesh or `null`
  27383. */
  27384. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27385. /**
  27386. * Remove a mesh from the LOD array
  27387. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27388. * @param mesh defines the mesh to be removed
  27389. * @return This mesh (for chaining)
  27390. */
  27391. removeLODLevel(mesh: Mesh): Mesh;
  27392. /**
  27393. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27394. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27395. * @param camera defines the camera to use to compute distance
  27396. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27397. * @return This mesh (for chaining)
  27398. */
  27399. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27400. /**
  27401. * Gets the mesh internal Geometry object
  27402. */
  27403. get geometry(): Nullable<Geometry>;
  27404. /**
  27405. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27406. * @returns the total number of vertices
  27407. */
  27408. getTotalVertices(): number;
  27409. /**
  27410. * Returns the content of an associated vertex buffer
  27411. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27412. * - VertexBuffer.PositionKind
  27413. * - VertexBuffer.UVKind
  27414. * - VertexBuffer.UV2Kind
  27415. * - VertexBuffer.UV3Kind
  27416. * - VertexBuffer.UV4Kind
  27417. * - VertexBuffer.UV5Kind
  27418. * - VertexBuffer.UV6Kind
  27419. * - VertexBuffer.ColorKind
  27420. * - VertexBuffer.MatricesIndicesKind
  27421. * - VertexBuffer.MatricesIndicesExtraKind
  27422. * - VertexBuffer.MatricesWeightsKind
  27423. * - VertexBuffer.MatricesWeightsExtraKind
  27424. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  27425. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27426. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27427. */
  27428. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27429. /**
  27430. * Returns the mesh VertexBuffer object from the requested `kind`
  27431. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27432. * - VertexBuffer.PositionKind
  27433. * - VertexBuffer.NormalKind
  27434. * - VertexBuffer.UVKind
  27435. * - VertexBuffer.UV2Kind
  27436. * - VertexBuffer.UV3Kind
  27437. * - VertexBuffer.UV4Kind
  27438. * - VertexBuffer.UV5Kind
  27439. * - VertexBuffer.UV6Kind
  27440. * - VertexBuffer.ColorKind
  27441. * - VertexBuffer.MatricesIndicesKind
  27442. * - VertexBuffer.MatricesIndicesExtraKind
  27443. * - VertexBuffer.MatricesWeightsKind
  27444. * - VertexBuffer.MatricesWeightsExtraKind
  27445. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27446. */
  27447. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27448. /**
  27449. * Tests if a specific vertex buffer is associated with this mesh
  27450. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27451. * - VertexBuffer.PositionKind
  27452. * - VertexBuffer.NormalKind
  27453. * - VertexBuffer.UVKind
  27454. * - VertexBuffer.UV2Kind
  27455. * - VertexBuffer.UV3Kind
  27456. * - VertexBuffer.UV4Kind
  27457. * - VertexBuffer.UV5Kind
  27458. * - VertexBuffer.UV6Kind
  27459. * - VertexBuffer.ColorKind
  27460. * - VertexBuffer.MatricesIndicesKind
  27461. * - VertexBuffer.MatricesIndicesExtraKind
  27462. * - VertexBuffer.MatricesWeightsKind
  27463. * - VertexBuffer.MatricesWeightsExtraKind
  27464. * @returns a boolean
  27465. */
  27466. isVerticesDataPresent(kind: string): boolean;
  27467. /**
  27468. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27469. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27470. * - VertexBuffer.PositionKind
  27471. * - VertexBuffer.UVKind
  27472. * - VertexBuffer.UV2Kind
  27473. * - VertexBuffer.UV3Kind
  27474. * - VertexBuffer.UV4Kind
  27475. * - VertexBuffer.UV5Kind
  27476. * - VertexBuffer.UV6Kind
  27477. * - VertexBuffer.ColorKind
  27478. * - VertexBuffer.MatricesIndicesKind
  27479. * - VertexBuffer.MatricesIndicesExtraKind
  27480. * - VertexBuffer.MatricesWeightsKind
  27481. * - VertexBuffer.MatricesWeightsExtraKind
  27482. * @returns a boolean
  27483. */
  27484. isVertexBufferUpdatable(kind: string): boolean;
  27485. /**
  27486. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27487. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27488. * - VertexBuffer.PositionKind
  27489. * - VertexBuffer.NormalKind
  27490. * - VertexBuffer.UVKind
  27491. * - VertexBuffer.UV2Kind
  27492. * - VertexBuffer.UV3Kind
  27493. * - VertexBuffer.UV4Kind
  27494. * - VertexBuffer.UV5Kind
  27495. * - VertexBuffer.UV6Kind
  27496. * - VertexBuffer.ColorKind
  27497. * - VertexBuffer.MatricesIndicesKind
  27498. * - VertexBuffer.MatricesIndicesExtraKind
  27499. * - VertexBuffer.MatricesWeightsKind
  27500. * - VertexBuffer.MatricesWeightsExtraKind
  27501. * @returns an array of strings
  27502. */
  27503. getVerticesDataKinds(): string[];
  27504. /**
  27505. * Returns a positive integer : the total number of indices in this mesh geometry.
  27506. * @returns the numner of indices or zero if the mesh has no geometry.
  27507. */
  27508. getTotalIndices(): number;
  27509. /**
  27510. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27511. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  27512. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27513. * @returns the indices array or an empty array if the mesh has no geometry
  27514. */
  27515. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27516. get isBlocked(): boolean;
  27517. /**
  27518. * Determine if the current mesh is ready to be rendered
  27519. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27520. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27521. * @returns true if all associated assets are ready (material, textures, shaders)
  27522. */
  27523. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27524. /**
  27525. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  27526. */
  27527. get areNormalsFrozen(): boolean;
  27528. /**
  27529. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  27530. * @returns the current mesh
  27531. */
  27532. freezeNormals(): Mesh;
  27533. /**
  27534. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  27535. * @returns the current mesh
  27536. */
  27537. unfreezeNormals(): Mesh;
  27538. /**
  27539. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27540. */
  27541. set overridenInstanceCount(count: number);
  27542. /** @hidden */
  27543. _preActivate(): Mesh;
  27544. /** @hidden */
  27545. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27546. /** @hidden */
  27547. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27548. protected _afterComputeWorldMatrix(): void;
  27549. /** @hidden */
  27550. _postActivate(): void;
  27551. /**
  27552. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27553. * This means the mesh underlying bounding box and sphere are recomputed.
  27554. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27555. * @returns the current mesh
  27556. */
  27557. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27558. /** @hidden */
  27559. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27560. /**
  27561. * This function will subdivide the mesh into multiple submeshes
  27562. * @param count defines the expected number of submeshes
  27563. */
  27564. subdivide(count: number): void;
  27565. /**
  27566. * Copy a FloatArray into a specific associated vertex buffer
  27567. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27568. * - VertexBuffer.PositionKind
  27569. * - VertexBuffer.UVKind
  27570. * - VertexBuffer.UV2Kind
  27571. * - VertexBuffer.UV3Kind
  27572. * - VertexBuffer.UV4Kind
  27573. * - VertexBuffer.UV5Kind
  27574. * - VertexBuffer.UV6Kind
  27575. * - VertexBuffer.ColorKind
  27576. * - VertexBuffer.MatricesIndicesKind
  27577. * - VertexBuffer.MatricesIndicesExtraKind
  27578. * - VertexBuffer.MatricesWeightsKind
  27579. * - VertexBuffer.MatricesWeightsExtraKind
  27580. * @param data defines the data source
  27581. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27582. * @param stride defines the data stride size (can be null)
  27583. * @returns the current mesh
  27584. */
  27585. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27586. /**
  27587. * Delete a vertex buffer associated with this mesh
  27588. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27589. * - VertexBuffer.PositionKind
  27590. * - VertexBuffer.UVKind
  27591. * - VertexBuffer.UV2Kind
  27592. * - VertexBuffer.UV3Kind
  27593. * - VertexBuffer.UV4Kind
  27594. * - VertexBuffer.UV5Kind
  27595. * - VertexBuffer.UV6Kind
  27596. * - VertexBuffer.ColorKind
  27597. * - VertexBuffer.MatricesIndicesKind
  27598. * - VertexBuffer.MatricesIndicesExtraKind
  27599. * - VertexBuffer.MatricesWeightsKind
  27600. * - VertexBuffer.MatricesWeightsExtraKind
  27601. */
  27602. removeVerticesData(kind: string): void;
  27603. /**
  27604. * Flags an associated vertex buffer as updatable
  27605. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27606. * - VertexBuffer.PositionKind
  27607. * - VertexBuffer.UVKind
  27608. * - VertexBuffer.UV2Kind
  27609. * - VertexBuffer.UV3Kind
  27610. * - VertexBuffer.UV4Kind
  27611. * - VertexBuffer.UV5Kind
  27612. * - VertexBuffer.UV6Kind
  27613. * - VertexBuffer.ColorKind
  27614. * - VertexBuffer.MatricesIndicesKind
  27615. * - VertexBuffer.MatricesIndicesExtraKind
  27616. * - VertexBuffer.MatricesWeightsKind
  27617. * - VertexBuffer.MatricesWeightsExtraKind
  27618. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27619. */
  27620. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27621. /**
  27622. * Sets the mesh global Vertex Buffer
  27623. * @param buffer defines the buffer to use
  27624. * @returns the current mesh
  27625. */
  27626. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27627. /**
  27628. * Update a specific associated vertex buffer
  27629. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27630. * - VertexBuffer.PositionKind
  27631. * - VertexBuffer.UVKind
  27632. * - VertexBuffer.UV2Kind
  27633. * - VertexBuffer.UV3Kind
  27634. * - VertexBuffer.UV4Kind
  27635. * - VertexBuffer.UV5Kind
  27636. * - VertexBuffer.UV6Kind
  27637. * - VertexBuffer.ColorKind
  27638. * - VertexBuffer.MatricesIndicesKind
  27639. * - VertexBuffer.MatricesIndicesExtraKind
  27640. * - VertexBuffer.MatricesWeightsKind
  27641. * - VertexBuffer.MatricesWeightsExtraKind
  27642. * @param data defines the data source
  27643. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27644. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  27645. * @returns the current mesh
  27646. */
  27647. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27648. /**
  27649. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27650. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27651. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27652. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27653. * @returns the current mesh
  27654. */
  27655. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27656. /**
  27657. * Creates a un-shared specific occurence of the geometry for the mesh.
  27658. * @returns the current mesh
  27659. */
  27660. makeGeometryUnique(): Mesh;
  27661. /**
  27662. * Set the index buffer of this mesh
  27663. * @param indices defines the source data
  27664. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27665. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27666. * @returns the current mesh
  27667. */
  27668. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27669. /**
  27670. * Update the current index buffer
  27671. * @param indices defines the source data
  27672. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27673. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  27674. * @returns the current mesh
  27675. */
  27676. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27677. /**
  27678. * Invert the geometry to move from a right handed system to a left handed one.
  27679. * @returns the current mesh
  27680. */
  27681. toLeftHanded(): Mesh;
  27682. /** @hidden */
  27683. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27684. /** @hidden */
  27685. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27686. /**
  27687. * Registers for this mesh a javascript function called just before the rendering process
  27688. * @param func defines the function to call before rendering this mesh
  27689. * @returns the current mesh
  27690. */
  27691. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27692. /**
  27693. * Disposes a previously registered javascript function called before the rendering
  27694. * @param func defines the function to remove
  27695. * @returns the current mesh
  27696. */
  27697. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27698. /**
  27699. * Registers for this mesh a javascript function called just after the rendering is complete
  27700. * @param func defines the function to call after rendering this mesh
  27701. * @returns the current mesh
  27702. */
  27703. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27704. /**
  27705. * Disposes a previously registered javascript function called after the rendering.
  27706. * @param func defines the function to remove
  27707. * @returns the current mesh
  27708. */
  27709. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27710. /** @hidden */
  27711. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27712. /** @hidden */
  27713. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27714. /** @hidden */
  27715. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27716. /** @hidden */
  27717. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27718. /** @hidden */
  27719. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27720. /** @hidden */
  27721. _rebuild(): void;
  27722. /** @hidden */
  27723. _freeze(): void;
  27724. /** @hidden */
  27725. _unFreeze(): void;
  27726. /**
  27727. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  27728. * @param subMesh defines the subMesh to render
  27729. * @param enableAlphaMode defines if alpha mode can be changed
  27730. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27731. * @returns the current mesh
  27732. */
  27733. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27734. private _onBeforeDraw;
  27735. /**
  27736. * Renormalize the mesh and patch it up if there are no weights
  27737. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27738. * However in the case of zero weights then we set just a single influence to 1.
  27739. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27740. */
  27741. cleanMatrixWeights(): void;
  27742. private normalizeSkinFourWeights;
  27743. private normalizeSkinWeightsAndExtra;
  27744. /**
  27745. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27746. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27747. * the user know there was an issue with importing the mesh
  27748. * @returns a validation object with skinned, valid and report string
  27749. */
  27750. validateSkinning(): {
  27751. skinned: boolean;
  27752. valid: boolean;
  27753. report: string;
  27754. };
  27755. /** @hidden */
  27756. _checkDelayState(): Mesh;
  27757. private _queueLoad;
  27758. /**
  27759. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27760. * A mesh is in the frustum if its bounding box intersects the frustum
  27761. * @param frustumPlanes defines the frustum to test
  27762. * @returns true if the mesh is in the frustum planes
  27763. */
  27764. isInFrustum(frustumPlanes: Plane[]): boolean;
  27765. /**
  27766. * Sets the mesh material by the material or multiMaterial `id` property
  27767. * @param id is a string identifying the material or the multiMaterial
  27768. * @returns the current mesh
  27769. */
  27770. setMaterialByID(id: string): Mesh;
  27771. /**
  27772. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27773. * @returns an array of IAnimatable
  27774. */
  27775. getAnimatables(): IAnimatable[];
  27776. /**
  27777. * Modifies the mesh geometry according to the passed transformation matrix.
  27778. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27779. * The mesh normals are modified using the same transformation.
  27780. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27781. * @param transform defines the transform matrix to use
  27782. * @see http://doc.babylonjs.com/resources/baking_transformations
  27783. * @returns the current mesh
  27784. */
  27785. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27786. /**
  27787. * Modifies the mesh geometry according to its own current World Matrix.
  27788. * The mesh World Matrix is then reset.
  27789. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27790. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27791. * @see http://doc.babylonjs.com/resources/baking_transformations
  27792. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27793. * @returns the current mesh
  27794. */
  27795. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27796. /** @hidden */
  27797. get _positions(): Nullable<Vector3[]>;
  27798. /** @hidden */
  27799. _resetPointsArrayCache(): Mesh;
  27800. /** @hidden */
  27801. _generatePointsArray(): boolean;
  27802. /**
  27803. * Returns a new Mesh object generated from the current mesh properties.
  27804. * This method must not get confused with createInstance()
  27805. * @param name is a string, the name given to the new mesh
  27806. * @param newParent can be any Node object (default `null`)
  27807. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27808. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27809. * @returns a new mesh
  27810. */
  27811. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27812. /**
  27813. * Releases resources associated with this mesh.
  27814. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27815. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27816. */
  27817. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27818. /** @hidden */
  27819. _disposeInstanceSpecificData(): void;
  27820. /** @hidden */
  27821. _disposeThinInstanceSpecificData(): void;
  27822. /**
  27823. * Modifies the mesh geometry according to a displacement map.
  27824. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  27825. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27826. * @param url is a string, the URL from the image file is to be downloaded.
  27827. * @param minHeight is the lower limit of the displacement.
  27828. * @param maxHeight is the upper limit of the displacement.
  27829. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  27830. * @param uvOffset is an optional vector2 used to offset UV.
  27831. * @param uvScale is an optional vector2 used to scale UV.
  27832. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  27833. * @returns the Mesh.
  27834. */
  27835. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27836. /**
  27837. * Modifies the mesh geometry according to a displacementMap buffer.
  27838. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  27839. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27840. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27841. * @param heightMapWidth is the width of the buffer image.
  27842. * @param heightMapHeight is the height of the buffer image.
  27843. * @param minHeight is the lower limit of the displacement.
  27844. * @param maxHeight is the upper limit of the displacement.
  27845. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  27846. * @param uvOffset is an optional vector2 used to offset UV.
  27847. * @param uvScale is an optional vector2 used to scale UV.
  27848. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  27849. * @returns the Mesh.
  27850. */
  27851. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27852. /**
  27853. * Modify the mesh to get a flat shading rendering.
  27854. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27855. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27856. * @returns current mesh
  27857. */
  27858. convertToFlatShadedMesh(): Mesh;
  27859. /**
  27860. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27861. * In other words, more vertices, no more indices and a single bigger VBO.
  27862. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27863. * @returns current mesh
  27864. */
  27865. convertToUnIndexedMesh(): Mesh;
  27866. /**
  27867. * Inverses facet orientations.
  27868. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27869. * @param flipNormals will also inverts the normals
  27870. * @returns current mesh
  27871. */
  27872. flipFaces(flipNormals?: boolean): Mesh;
  27873. /**
  27874. * Increase the number of facets and hence vertices in a mesh
  27875. * Vertex normals are interpolated from existing vertex normals
  27876. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27877. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27878. */
  27879. increaseVertices(numberPerEdge: number): void;
  27880. /**
  27881. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27882. * This will undo any application of covertToFlatShadedMesh
  27883. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27884. */
  27885. forceSharedVertices(): void;
  27886. /** @hidden */
  27887. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27888. /** @hidden */
  27889. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27890. /**
  27891. * Creates a new InstancedMesh object from the mesh model.
  27892. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27893. * @param name defines the name of the new instance
  27894. * @returns a new InstancedMesh
  27895. */
  27896. createInstance(name: string): InstancedMesh;
  27897. /**
  27898. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27899. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27900. * @returns the current mesh
  27901. */
  27902. synchronizeInstances(): Mesh;
  27903. /**
  27904. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27905. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27906. * This should be used together with the simplification to avoid disappearing triangles.
  27907. * @param successCallback an optional success callback to be called after the optimization finished.
  27908. * @returns the current mesh
  27909. */
  27910. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27911. /**
  27912. * Serialize current mesh
  27913. * @param serializationObject defines the object which will receive the serialization data
  27914. */
  27915. serialize(serializationObject: any): void;
  27916. /** @hidden */
  27917. _syncGeometryWithMorphTargetManager(): void;
  27918. /** @hidden */
  27919. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27920. /**
  27921. * Returns a new Mesh object parsed from the source provided.
  27922. * @param parsedMesh is the source
  27923. * @param scene defines the hosting scene
  27924. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27925. * @returns a new Mesh
  27926. */
  27927. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27928. /**
  27929. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27930. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27931. * @param name defines the name of the mesh to create
  27932. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27933. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27934. * @param closePath creates a seam between the first and the last points of each path of the path array
  27935. * @param offset is taken in account only if the `pathArray` is containing a single path
  27936. * @param scene defines the hosting scene
  27937. * @param updatable defines if the mesh must be flagged as updatable
  27938. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27939. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  27940. * @returns a new Mesh
  27941. */
  27942. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27943. /**
  27944. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27945. * @param name defines the name of the mesh to create
  27946. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27947. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  27948. * @param scene defines the hosting scene
  27949. * @param updatable defines if the mesh must be flagged as updatable
  27950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27951. * @returns a new Mesh
  27952. */
  27953. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27954. /**
  27955. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27956. * @param name defines the name of the mesh to create
  27957. * @param size sets the size (float) of each box side (default 1)
  27958. * @param scene defines the hosting scene
  27959. * @param updatable defines if the mesh must be flagged as updatable
  27960. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27961. * @returns a new Mesh
  27962. */
  27963. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27964. /**
  27965. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27966. * @param name defines the name of the mesh to create
  27967. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27968. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27969. * @param scene defines the hosting scene
  27970. * @param updatable defines if the mesh must be flagged as updatable
  27971. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27972. * @returns a new Mesh
  27973. */
  27974. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27975. /**
  27976. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  27977. * @param name defines the name of the mesh to create
  27978. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27979. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27980. * @param scene defines the hosting scene
  27981. * @returns a new Mesh
  27982. */
  27983. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  27984. /**
  27985. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27986. * @param name defines the name of the mesh to create
  27987. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27988. * @param diameterTop set the top cap diameter (floats, default 1)
  27989. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27990. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27991. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27992. * @param scene defines the hosting scene
  27993. * @param updatable defines if the mesh must be flagged as updatable
  27994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27995. * @returns a new Mesh
  27996. */
  27997. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27998. /**
  27999. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28000. * @param name defines the name of the mesh to create
  28001. * @param diameter sets the diameter size (float) of the torus (default 1)
  28002. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28003. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28004. * @param scene defines the hosting scene
  28005. * @param updatable defines if the mesh must be flagged as updatable
  28006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28007. * @returns a new Mesh
  28008. */
  28009. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28010. /**
  28011. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28012. * @param name defines the name of the mesh to create
  28013. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28014. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28015. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28016. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28017. * @param p the number of windings on X axis (positive integers, default 2)
  28018. * @param q the number of windings on Y axis (positive integers, default 3)
  28019. * @param scene defines the hosting scene
  28020. * @param updatable defines if the mesh must be flagged as updatable
  28021. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28022. * @returns a new Mesh
  28023. */
  28024. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28025. /**
  28026. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28027. * @param name defines the name of the mesh to create
  28028. * @param points is an array successive Vector3
  28029. * @param scene defines the hosting scene
  28030. * @param updatable defines if the mesh must be flagged as updatable
  28031. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  28032. * @returns a new Mesh
  28033. */
  28034. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28035. /**
  28036. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28037. * @param name defines the name of the mesh to create
  28038. * @param points is an array successive Vector3
  28039. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28040. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28041. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28042. * @param scene defines the hosting scene
  28043. * @param updatable defines if the mesh must be flagged as updatable
  28044. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  28045. * @returns a new Mesh
  28046. */
  28047. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28048. /**
  28049. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28050. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28051. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  28052. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28053. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28054. * Remember you can only change the shape positions, not their number when updating a polygon.
  28055. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28056. * @param name defines the name of the mesh to create
  28057. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  28058. * @param scene defines the hosting scene
  28059. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28060. * @param updatable defines if the mesh must be flagged as updatable
  28061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28062. * @param earcutInjection can be used to inject your own earcut reference
  28063. * @returns a new Mesh
  28064. */
  28065. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28066. /**
  28067. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28068. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28069. * @param name defines the name of the mesh to create
  28070. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  28071. * @param depth defines the height of extrusion
  28072. * @param scene defines the hosting scene
  28073. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28074. * @param updatable defines if the mesh must be flagged as updatable
  28075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28076. * @param earcutInjection can be used to inject your own earcut reference
  28077. * @returns a new Mesh
  28078. */
  28079. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28080. /**
  28081. * Creates an extruded shape mesh.
  28082. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  28083. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28084. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28085. * @param name defines the name of the mesh to create
  28086. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  28087. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28088. * @param scale is the value to scale the shape
  28089. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  28090. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  28091. * @param scene defines the hosting scene
  28092. * @param updatable defines if the mesh must be flagged as updatable
  28093. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28094. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  28095. * @returns a new Mesh
  28096. */
  28097. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28098. /**
  28099. * Creates an custom extruded shape mesh.
  28100. * The custom extrusion is a parametric shape.
  28101. * It has no predefined shape. Its final shape will depend on the input parameters.
  28102. * Please consider using the same method from the MeshBuilder class instead
  28103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28104. * @param name defines the name of the mesh to create
  28105. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  28106. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28107. * @param scaleFunction is a custom Javascript function called on each path point
  28108. * @param rotationFunction is a custom Javascript function called on each path point
  28109. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28110. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28111. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  28112. * @param scene defines the hosting scene
  28113. * @param updatable defines if the mesh must be flagged as updatable
  28114. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28115. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  28116. * @returns a new Mesh
  28117. */
  28118. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28119. /**
  28120. * Creates lathe mesh.
  28121. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28122. * Please consider using the same method from the MeshBuilder class instead
  28123. * @param name defines the name of the mesh to create
  28124. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  28125. * @param radius is the radius value of the lathe
  28126. * @param tessellation is the side number of the lathe.
  28127. * @param scene defines the hosting scene
  28128. * @param updatable defines if the mesh must be flagged as updatable
  28129. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28130. * @returns a new Mesh
  28131. */
  28132. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28133. /**
  28134. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28135. * @param name defines the name of the mesh to create
  28136. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28137. * @param scene defines the hosting scene
  28138. * @param updatable defines if the mesh must be flagged as updatable
  28139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28140. * @returns a new Mesh
  28141. */
  28142. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28143. /**
  28144. * Creates a ground mesh.
  28145. * Please consider using the same method from the MeshBuilder class instead
  28146. * @param name defines the name of the mesh to create
  28147. * @param width set the width of the ground
  28148. * @param height set the height of the ground
  28149. * @param subdivisions sets the number of subdivisions per side
  28150. * @param scene defines the hosting scene
  28151. * @param updatable defines if the mesh must be flagged as updatable
  28152. * @returns a new Mesh
  28153. */
  28154. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28155. /**
  28156. * Creates a tiled ground mesh.
  28157. * Please consider using the same method from the MeshBuilder class instead
  28158. * @param name defines the name of the mesh to create
  28159. * @param xmin set the ground minimum X coordinate
  28160. * @param zmin set the ground minimum Y coordinate
  28161. * @param xmax set the ground maximum X coordinate
  28162. * @param zmax set the ground maximum Z coordinate
  28163. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  28164. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  28165. * @param scene defines the hosting scene
  28166. * @param updatable defines if the mesh must be flagged as updatable
  28167. * @returns a new Mesh
  28168. */
  28169. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28170. w: number;
  28171. h: number;
  28172. }, precision: {
  28173. w: number;
  28174. h: number;
  28175. }, scene: Scene, updatable?: boolean): Mesh;
  28176. /**
  28177. * Creates a ground mesh from a height map.
  28178. * Please consider using the same method from the MeshBuilder class instead
  28179. * @see http://doc.babylonjs.com/babylon101/height_map
  28180. * @param name defines the name of the mesh to create
  28181. * @param url sets the URL of the height map image resource
  28182. * @param width set the ground width size
  28183. * @param height set the ground height size
  28184. * @param subdivisions sets the number of subdivision per side
  28185. * @param minHeight is the minimum altitude on the ground
  28186. * @param maxHeight is the maximum altitude on the ground
  28187. * @param scene defines the hosting scene
  28188. * @param updatable defines if the mesh must be flagged as updatable
  28189. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28190. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28191. * @returns a new Mesh
  28192. */
  28193. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  28194. /**
  28195. * Creates a tube mesh.
  28196. * The tube is a parametric shape.
  28197. * It has no predefined shape. Its final shape will depend on the input parameters.
  28198. * Please consider using the same method from the MeshBuilder class instead
  28199. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28200. * @param name defines the name of the mesh to create
  28201. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28202. * @param radius sets the tube radius size
  28203. * @param tessellation is the number of sides on the tubular surface
  28204. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  28205. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  28206. * @param scene defines the hosting scene
  28207. * @param updatable defines if the mesh must be flagged as updatable
  28208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28209. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  28210. * @returns a new Mesh
  28211. */
  28212. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28213. (i: number, distance: number): number;
  28214. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28215. /**
  28216. * Creates a polyhedron mesh.
  28217. * Please consider using the same method from the MeshBuilder class instead.
  28218. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  28219. * * The parameter `size` (positive float, default 1) sets the polygon size
  28220. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28221. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  28222. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  28223. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  28224. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28225. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  28226. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28229. * @param name defines the name of the mesh to create
  28230. * @param options defines the options used to create the mesh
  28231. * @param scene defines the hosting scene
  28232. * @returns a new Mesh
  28233. */
  28234. static CreatePolyhedron(name: string, options: {
  28235. type?: number;
  28236. size?: number;
  28237. sizeX?: number;
  28238. sizeY?: number;
  28239. sizeZ?: number;
  28240. custom?: any;
  28241. faceUV?: Vector4[];
  28242. faceColors?: Color4[];
  28243. updatable?: boolean;
  28244. sideOrientation?: number;
  28245. }, scene: Scene): Mesh;
  28246. /**
  28247. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28248. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28249. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  28250. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28251. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  28252. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28255. * @param name defines the name of the mesh
  28256. * @param options defines the options used to create the mesh
  28257. * @param scene defines the hosting scene
  28258. * @returns a new Mesh
  28259. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28260. */
  28261. static CreateIcoSphere(name: string, options: {
  28262. radius?: number;
  28263. flat?: boolean;
  28264. subdivisions?: number;
  28265. sideOrientation?: number;
  28266. updatable?: boolean;
  28267. }, scene: Scene): Mesh;
  28268. /**
  28269. * Creates a decal mesh.
  28270. * Please consider using the same method from the MeshBuilder class instead.
  28271. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28272. * @param name defines the name of the mesh
  28273. * @param sourceMesh defines the mesh receiving the decal
  28274. * @param position sets the position of the decal in world coordinates
  28275. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28276. * @param size sets the decal scaling
  28277. * @param angle sets the angle to rotate the decal
  28278. * @returns a new Mesh
  28279. */
  28280. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28281. /**
  28282. * Prepare internal position array for software CPU skinning
  28283. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28284. */
  28285. setPositionsForCPUSkinning(): Float32Array;
  28286. /**
  28287. * Prepare internal normal array for software CPU skinning
  28288. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28289. */
  28290. setNormalsForCPUSkinning(): Float32Array;
  28291. /**
  28292. * Updates the vertex buffer by applying transformation from the bones
  28293. * @param skeleton defines the skeleton to apply to current mesh
  28294. * @returns the current mesh
  28295. */
  28296. applySkeleton(skeleton: Skeleton): Mesh;
  28297. /**
  28298. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  28299. * @param meshes defines the list of meshes to scan
  28300. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28301. */
  28302. static MinMax(meshes: AbstractMesh[]): {
  28303. min: Vector3;
  28304. max: Vector3;
  28305. };
  28306. /**
  28307. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28308. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28309. * @returns a vector3
  28310. */
  28311. static Center(meshesOrMinMaxVector: {
  28312. min: Vector3;
  28313. max: Vector3;
  28314. } | AbstractMesh[]): Vector3;
  28315. /**
  28316. * Merge the array of meshes into a single mesh for performance reasons.
  28317. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28318. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28319. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28320. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28321. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28322. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28323. * @returns a new mesh
  28324. */
  28325. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28326. /** @hidden */
  28327. addInstance(instance: InstancedMesh): void;
  28328. /** @hidden */
  28329. removeInstance(instance: InstancedMesh): void;
  28330. }
  28331. }
  28332. declare module BABYLON {
  28333. /**
  28334. * This is the base class of all the camera used in the application.
  28335. * @see http://doc.babylonjs.com/features/cameras
  28336. */
  28337. export class Camera extends Node {
  28338. /** @hidden */
  28339. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28340. /**
  28341. * This is the default projection mode used by the cameras.
  28342. * It helps recreating a feeling of perspective and better appreciate depth.
  28343. * This is the best way to simulate real life cameras.
  28344. */
  28345. static readonly PERSPECTIVE_CAMERA: number;
  28346. /**
  28347. * This helps creating camera with an orthographic mode.
  28348. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  28349. */
  28350. static readonly ORTHOGRAPHIC_CAMERA: number;
  28351. /**
  28352. * This is the default FOV mode for perspective cameras.
  28353. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28354. */
  28355. static readonly FOVMODE_VERTICAL_FIXED: number;
  28356. /**
  28357. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28358. */
  28359. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28360. /**
  28361. * This specifies ther is no need for a camera rig.
  28362. * Basically only one eye is rendered corresponding to the camera.
  28363. */
  28364. static readonly RIG_MODE_NONE: number;
  28365. /**
  28366. * Simulates a camera Rig with one blue eye and one red eye.
  28367. * This can be use with 3d blue and red glasses.
  28368. */
  28369. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28370. /**
  28371. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28372. */
  28373. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28374. /**
  28375. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28376. */
  28377. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28378. /**
  28379. * Defines that both eyes of the camera will be rendered over under each other.
  28380. */
  28381. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28382. /**
  28383. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28384. */
  28385. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28386. /**
  28387. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28388. */
  28389. static readonly RIG_MODE_VR: number;
  28390. /**
  28391. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28392. */
  28393. static readonly RIG_MODE_WEBVR: number;
  28394. /**
  28395. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28396. */
  28397. static readonly RIG_MODE_CUSTOM: number;
  28398. /**
  28399. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28400. */
  28401. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28402. /**
  28403. * Define the input manager associated with the camera.
  28404. */
  28405. inputs: CameraInputsManager<Camera>;
  28406. /** @hidden */
  28407. _position: Vector3;
  28408. /**
  28409. * Define the current local position of the camera in the scene
  28410. */
  28411. get position(): Vector3;
  28412. set position(newPosition: Vector3);
  28413. /**
  28414. * The vector the camera should consider as up.
  28415. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28416. */
  28417. upVector: Vector3;
  28418. /**
  28419. * Define the current limit on the left side for an orthographic camera
  28420. * In scene unit
  28421. */
  28422. orthoLeft: Nullable<number>;
  28423. /**
  28424. * Define the current limit on the right side for an orthographic camera
  28425. * In scene unit
  28426. */
  28427. orthoRight: Nullable<number>;
  28428. /**
  28429. * Define the current limit on the bottom side for an orthographic camera
  28430. * In scene unit
  28431. */
  28432. orthoBottom: Nullable<number>;
  28433. /**
  28434. * Define the current limit on the top side for an orthographic camera
  28435. * In scene unit
  28436. */
  28437. orthoTop: Nullable<number>;
  28438. /**
  28439. * Field Of View is set in Radians. (default is 0.8)
  28440. */
  28441. fov: number;
  28442. /**
  28443. * Define the minimum distance the camera can see from.
  28444. * This is important to note that the depth buffer are not infinite and the closer it starts
  28445. * the more your scene might encounter depth fighting issue.
  28446. */
  28447. minZ: number;
  28448. /**
  28449. * Define the maximum distance the camera can see to.
  28450. * This is important to note that the depth buffer are not infinite and the further it end
  28451. * the more your scene might encounter depth fighting issue.
  28452. */
  28453. maxZ: number;
  28454. /**
  28455. * Define the default inertia of the camera.
  28456. * This helps giving a smooth feeling to the camera movement.
  28457. */
  28458. inertia: number;
  28459. /**
  28460. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28461. */
  28462. mode: number;
  28463. /**
  28464. * Define whether the camera is intermediate.
  28465. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28466. */
  28467. isIntermediate: boolean;
  28468. /**
  28469. * Define the viewport of the camera.
  28470. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28471. */
  28472. viewport: Viewport;
  28473. /**
  28474. * Restricts the camera to viewing objects with the same layerMask.
  28475. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28476. */
  28477. layerMask: number;
  28478. /**
  28479. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28480. */
  28481. fovMode: number;
  28482. /**
  28483. * Rig mode of the camera.
  28484. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28485. * This is normally controlled byt the camera themselves as internal use.
  28486. */
  28487. cameraRigMode: number;
  28488. /**
  28489. * Defines the distance between both "eyes" in case of a RIG
  28490. */
  28491. interaxialDistance: number;
  28492. /**
  28493. * Defines if stereoscopic rendering is done side by side or over under.
  28494. */
  28495. isStereoscopicSideBySide: boolean;
  28496. /**
  28497. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  28498. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28499. * else in the scene. (Eg. security camera)
  28500. *
  28501. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  28502. */
  28503. customRenderTargets: RenderTargetTexture[];
  28504. /**
  28505. * When set, the camera will render to this render target instead of the default canvas
  28506. *
  28507. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28508. */
  28509. outputRenderTarget: Nullable<RenderTargetTexture>;
  28510. /**
  28511. * Observable triggered when the camera view matrix has changed.
  28512. */
  28513. onViewMatrixChangedObservable: Observable<Camera>;
  28514. /**
  28515. * Observable triggered when the camera Projection matrix has changed.
  28516. */
  28517. onProjectionMatrixChangedObservable: Observable<Camera>;
  28518. /**
  28519. * Observable triggered when the inputs have been processed.
  28520. */
  28521. onAfterCheckInputsObservable: Observable<Camera>;
  28522. /**
  28523. * Observable triggered when reset has been called and applied to the camera.
  28524. */
  28525. onRestoreStateObservable: Observable<Camera>;
  28526. /**
  28527. * Is this camera a part of a rig system?
  28528. */
  28529. isRigCamera: boolean;
  28530. /**
  28531. * If isRigCamera set to true this will be set with the parent camera.
  28532. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28533. */
  28534. rigParent?: Camera;
  28535. /** @hidden */
  28536. _cameraRigParams: any;
  28537. /** @hidden */
  28538. _rigCameras: Camera[];
  28539. /** @hidden */
  28540. _rigPostProcess: Nullable<PostProcess>;
  28541. protected _webvrViewMatrix: Matrix;
  28542. /** @hidden */
  28543. _skipRendering: boolean;
  28544. /** @hidden */
  28545. _projectionMatrix: Matrix;
  28546. /** @hidden */
  28547. _postProcesses: Nullable<PostProcess>[];
  28548. /** @hidden */
  28549. _activeMeshes: SmartArray<AbstractMesh>;
  28550. protected _globalPosition: Vector3;
  28551. /** @hidden */
  28552. _computedViewMatrix: Matrix;
  28553. private _doNotComputeProjectionMatrix;
  28554. private _transformMatrix;
  28555. private _frustumPlanes;
  28556. private _refreshFrustumPlanes;
  28557. private _storedFov;
  28558. private _stateStored;
  28559. /**
  28560. * Instantiates a new camera object.
  28561. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28562. * @see http://doc.babylonjs.com/features/cameras
  28563. * @param name Defines the name of the camera in the scene
  28564. * @param position Defines the position of the camera
  28565. * @param scene Defines the scene the camera belongs too
  28566. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28567. */
  28568. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28569. /**
  28570. * Store current camera state (fov, position, etc..)
  28571. * @returns the camera
  28572. */
  28573. storeState(): Camera;
  28574. /**
  28575. * Restores the camera state values if it has been stored. You must call storeState() first
  28576. */
  28577. protected _restoreStateValues(): boolean;
  28578. /**
  28579. * Restored camera state. You must call storeState() first.
  28580. * @returns true if restored and false otherwise
  28581. */
  28582. restoreState(): boolean;
  28583. /**
  28584. * Gets the class name of the camera.
  28585. * @returns the class name
  28586. */
  28587. getClassName(): string;
  28588. /** @hidden */
  28589. readonly _isCamera: boolean;
  28590. /**
  28591. * Gets a string representation of the camera useful for debug purpose.
  28592. * @param fullDetails Defines that a more verboe level of logging is required
  28593. * @returns the string representation
  28594. */
  28595. toString(fullDetails?: boolean): string;
  28596. /**
  28597. * Gets the current world space position of the camera.
  28598. */
  28599. get globalPosition(): Vector3;
  28600. /**
  28601. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28602. * @returns the active meshe list
  28603. */
  28604. getActiveMeshes(): SmartArray<AbstractMesh>;
  28605. /**
  28606. * Check whether a mesh is part of the current active mesh list of the camera
  28607. * @param mesh Defines the mesh to check
  28608. * @returns true if active, false otherwise
  28609. */
  28610. isActiveMesh(mesh: Mesh): boolean;
  28611. /**
  28612. * Is this camera ready to be used/rendered
  28613. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28614. * @return true if the camera is ready
  28615. */
  28616. isReady(completeCheck?: boolean): boolean;
  28617. /** @hidden */
  28618. _initCache(): void;
  28619. /** @hidden */
  28620. _updateCache(ignoreParentClass?: boolean): void;
  28621. /** @hidden */
  28622. _isSynchronized(): boolean;
  28623. /** @hidden */
  28624. _isSynchronizedViewMatrix(): boolean;
  28625. /** @hidden */
  28626. _isSynchronizedProjectionMatrix(): boolean;
  28627. /**
  28628. * Attach the input controls to a specific dom element to get the input from.
  28629. * @param element Defines the element the controls should be listened from
  28630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28631. */
  28632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28633. /**
  28634. * Detach the current controls from the specified dom element.
  28635. * @param element Defines the element to stop listening the inputs from
  28636. */
  28637. detachControl(element: HTMLElement): void;
  28638. /**
  28639. * Update the camera state according to the different inputs gathered during the frame.
  28640. */
  28641. update(): void;
  28642. /** @hidden */
  28643. _checkInputs(): void;
  28644. /** @hidden */
  28645. get rigCameras(): Camera[];
  28646. /**
  28647. * Gets the post process used by the rig cameras
  28648. */
  28649. get rigPostProcess(): Nullable<PostProcess>;
  28650. /**
  28651. * Internal, gets the first post proces.
  28652. * @returns the first post process to be run on this camera.
  28653. */
  28654. _getFirstPostProcess(): Nullable<PostProcess>;
  28655. private _cascadePostProcessesToRigCams;
  28656. /**
  28657. * Attach a post process to the camera.
  28658. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28659. * @param postProcess The post process to attach to the camera
  28660. * @param insertAt The position of the post process in case several of them are in use in the scene
  28661. * @returns the position the post process has been inserted at
  28662. */
  28663. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28664. /**
  28665. * Detach a post process to the camera.
  28666. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28667. * @param postProcess The post process to detach from the camera
  28668. */
  28669. detachPostProcess(postProcess: PostProcess): void;
  28670. /**
  28671. * Gets the current world matrix of the camera
  28672. */
  28673. getWorldMatrix(): Matrix;
  28674. /** @hidden */
  28675. _getViewMatrix(): Matrix;
  28676. /**
  28677. * Gets the current view matrix of the camera.
  28678. * @param force forces the camera to recompute the matrix without looking at the cached state
  28679. * @returns the view matrix
  28680. */
  28681. getViewMatrix(force?: boolean): Matrix;
  28682. /**
  28683. * Freeze the projection matrix.
  28684. * It will prevent the cache check of the camera projection compute and can speed up perf
  28685. * if no parameter of the camera are meant to change
  28686. * @param projection Defines manually a projection if necessary
  28687. */
  28688. freezeProjectionMatrix(projection?: Matrix): void;
  28689. /**
  28690. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28691. */
  28692. unfreezeProjectionMatrix(): void;
  28693. /**
  28694. * Gets the current projection matrix of the camera.
  28695. * @param force forces the camera to recompute the matrix without looking at the cached state
  28696. * @returns the projection matrix
  28697. */
  28698. getProjectionMatrix(force?: boolean): Matrix;
  28699. /**
  28700. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28701. * @returns a Matrix
  28702. */
  28703. getTransformationMatrix(): Matrix;
  28704. private _updateFrustumPlanes;
  28705. /**
  28706. * Checks if a cullable object (mesh...) is in the camera frustum
  28707. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28708. * @param target The object to check
  28709. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28710. * @returns true if the object is in frustum otherwise false
  28711. */
  28712. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28713. /**
  28714. * Checks if a cullable object (mesh...) is in the camera frustum
  28715. * Unlike isInFrustum this cheks the full bounding box
  28716. * @param target The object to check
  28717. * @returns true if the object is in frustum otherwise false
  28718. */
  28719. isCompletelyInFrustum(target: ICullable): boolean;
  28720. /**
  28721. * Gets a ray in the forward direction from the camera.
  28722. * @param length Defines the length of the ray to create
  28723. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28724. * @param origin Defines the start point of the ray which defaults to the camera position
  28725. * @returns the forward ray
  28726. */
  28727. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28728. /**
  28729. * Releases resources associated with this node.
  28730. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28731. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28732. */
  28733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28734. /** @hidden */
  28735. _isLeftCamera: boolean;
  28736. /**
  28737. * Gets the left camera of a rig setup in case of Rigged Camera
  28738. */
  28739. get isLeftCamera(): boolean;
  28740. /** @hidden */
  28741. _isRightCamera: boolean;
  28742. /**
  28743. * Gets the right camera of a rig setup in case of Rigged Camera
  28744. */
  28745. get isRightCamera(): boolean;
  28746. /**
  28747. * Gets the left camera of a rig setup in case of Rigged Camera
  28748. */
  28749. get leftCamera(): Nullable<FreeCamera>;
  28750. /**
  28751. * Gets the right camera of a rig setup in case of Rigged Camera
  28752. */
  28753. get rightCamera(): Nullable<FreeCamera>;
  28754. /**
  28755. * Gets the left camera target of a rig setup in case of Rigged Camera
  28756. * @returns the target position
  28757. */
  28758. getLeftTarget(): Nullable<Vector3>;
  28759. /**
  28760. * Gets the right camera target of a rig setup in case of Rigged Camera
  28761. * @returns the target position
  28762. */
  28763. getRightTarget(): Nullable<Vector3>;
  28764. /**
  28765. * @hidden
  28766. */
  28767. setCameraRigMode(mode: number, rigParams: any): void;
  28768. /** @hidden */
  28769. static _setStereoscopicRigMode(camera: Camera): void;
  28770. /** @hidden */
  28771. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28772. /** @hidden */
  28773. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28774. /** @hidden */
  28775. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28776. /** @hidden */
  28777. _getVRProjectionMatrix(): Matrix;
  28778. protected _updateCameraRotationMatrix(): void;
  28779. protected _updateWebVRCameraRotationMatrix(): void;
  28780. /**
  28781. * This function MUST be overwritten by the different WebVR cameras available.
  28782. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28783. * @hidden
  28784. */
  28785. _getWebVRProjectionMatrix(): Matrix;
  28786. /**
  28787. * This function MUST be overwritten by the different WebVR cameras available.
  28788. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28789. * @hidden
  28790. */
  28791. _getWebVRViewMatrix(): Matrix;
  28792. /** @hidden */
  28793. setCameraRigParameter(name: string, value: any): void;
  28794. /**
  28795. * needs to be overridden by children so sub has required properties to be copied
  28796. * @hidden
  28797. */
  28798. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28799. /**
  28800. * May need to be overridden by children
  28801. * @hidden
  28802. */
  28803. _updateRigCameras(): void;
  28804. /** @hidden */
  28805. _setupInputs(): void;
  28806. /**
  28807. * Serialiaze the camera setup to a json represention
  28808. * @returns the JSON representation
  28809. */
  28810. serialize(): any;
  28811. /**
  28812. * Clones the current camera.
  28813. * @param name The cloned camera name
  28814. * @returns the cloned camera
  28815. */
  28816. clone(name: string): Camera;
  28817. /**
  28818. * Gets the direction of the camera relative to a given local axis.
  28819. * @param localAxis Defines the reference axis to provide a relative direction.
  28820. * @return the direction
  28821. */
  28822. getDirection(localAxis: Vector3): Vector3;
  28823. /**
  28824. * Returns the current camera absolute rotation
  28825. */
  28826. get absoluteRotation(): Quaternion;
  28827. /**
  28828. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28829. * @param localAxis Defines the reference axis to provide a relative direction.
  28830. * @param result Defines the vector to store the result in
  28831. */
  28832. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28833. /**
  28834. * Gets a camera constructor for a given camera type
  28835. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28836. * @param name The name of the camera the result will be able to instantiate
  28837. * @param scene The scene the result will construct the camera in
  28838. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28839. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28840. * @returns a factory method to construc the camera
  28841. */
  28842. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28843. /**
  28844. * Compute the world matrix of the camera.
  28845. * @returns the camera world matrix
  28846. */
  28847. computeWorldMatrix(): Matrix;
  28848. /**
  28849. * Parse a JSON and creates the camera from the parsed information
  28850. * @param parsedCamera The JSON to parse
  28851. * @param scene The scene to instantiate the camera in
  28852. * @returns the newly constructed camera
  28853. */
  28854. static Parse(parsedCamera: any, scene: Scene): Camera;
  28855. }
  28856. }
  28857. declare module BABYLON {
  28858. /**
  28859. * Class containing static functions to help procedurally build meshes
  28860. */
  28861. export class DiscBuilder {
  28862. /**
  28863. * Creates a plane polygonal mesh. By default, this is a disc
  28864. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28865. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  28866. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  28867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28870. * @param name defines the name of the mesh
  28871. * @param options defines the options used to create the mesh
  28872. * @param scene defines the hosting scene
  28873. * @returns the plane polygonal mesh
  28874. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28875. */
  28876. static CreateDisc(name: string, options: {
  28877. radius?: number;
  28878. tessellation?: number;
  28879. arc?: number;
  28880. updatable?: boolean;
  28881. sideOrientation?: number;
  28882. frontUVs?: Vector4;
  28883. backUVs?: Vector4;
  28884. }, scene?: Nullable<Scene>): Mesh;
  28885. }
  28886. }
  28887. declare module BABYLON {
  28888. /**
  28889. * Options to be used when creating a FresnelParameters.
  28890. */
  28891. export type IFresnelParametersCreationOptions = {
  28892. /**
  28893. * Define the color used on edges (grazing angle)
  28894. */
  28895. leftColor?: Color3;
  28896. /**
  28897. * Define the color used on center
  28898. */
  28899. rightColor?: Color3;
  28900. /**
  28901. * Define bias applied to computed fresnel term
  28902. */
  28903. bias?: number;
  28904. /**
  28905. * Defined the power exponent applied to fresnel term
  28906. */
  28907. power?: number;
  28908. /**
  28909. * Define if the fresnel effect is enable or not.
  28910. */
  28911. isEnabled?: boolean;
  28912. };
  28913. /**
  28914. * Serialized format for FresnelParameters.
  28915. */
  28916. export type IFresnelParametersSerialized = {
  28917. /**
  28918. * Define the color used on edges (grazing angle) [as an array]
  28919. */
  28920. leftColor: number[];
  28921. /**
  28922. * Define the color used on center [as an array]
  28923. */
  28924. rightColor: number[];
  28925. /**
  28926. * Define bias applied to computed fresnel term
  28927. */
  28928. bias: number;
  28929. /**
  28930. * Defined the power exponent applied to fresnel term
  28931. */
  28932. power?: number;
  28933. /**
  28934. * Define if the fresnel effect is enable or not.
  28935. */
  28936. isEnabled: boolean;
  28937. };
  28938. /**
  28939. * This represents all the required information to add a fresnel effect on a material:
  28940. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28941. */
  28942. export class FresnelParameters {
  28943. private _isEnabled;
  28944. /**
  28945. * Define if the fresnel effect is enable or not.
  28946. */
  28947. get isEnabled(): boolean;
  28948. set isEnabled(value: boolean);
  28949. /**
  28950. * Define the color used on edges (grazing angle)
  28951. */
  28952. leftColor: Color3;
  28953. /**
  28954. * Define the color used on center
  28955. */
  28956. rightColor: Color3;
  28957. /**
  28958. * Define bias applied to computed fresnel term
  28959. */
  28960. bias: number;
  28961. /**
  28962. * Defined the power exponent applied to fresnel term
  28963. */
  28964. power: number;
  28965. /**
  28966. * Creates a new FresnelParameters object.
  28967. *
  28968. * @param options provide your own settings to optionally to override defaults
  28969. */
  28970. constructor(options?: IFresnelParametersCreationOptions);
  28971. /**
  28972. * Clones the current fresnel and its valuues
  28973. * @returns a clone fresnel configuration
  28974. */
  28975. clone(): FresnelParameters;
  28976. /**
  28977. * Determines equality between FresnelParameters objects
  28978. * @param otherFresnelParameters defines the second operand
  28979. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  28980. */
  28981. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  28982. /**
  28983. * Serializes the current fresnel parameters to a JSON representation.
  28984. * @return the JSON serialization
  28985. */
  28986. serialize(): IFresnelParametersSerialized;
  28987. /**
  28988. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28989. * @param parsedFresnelParameters Define the JSON representation
  28990. * @returns the parsed parameters
  28991. */
  28992. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  28993. }
  28994. }
  28995. declare module BABYLON {
  28996. /**
  28997. * This groups all the flags used to control the materials channel.
  28998. */
  28999. export class MaterialFlags {
  29000. private static _DiffuseTextureEnabled;
  29001. /**
  29002. * Are diffuse textures enabled in the application.
  29003. */
  29004. static get DiffuseTextureEnabled(): boolean;
  29005. static set DiffuseTextureEnabled(value: boolean);
  29006. private static _DetailTextureEnabled;
  29007. /**
  29008. * Are detail textures enabled in the application.
  29009. */
  29010. static get DetailTextureEnabled(): boolean;
  29011. static set DetailTextureEnabled(value: boolean);
  29012. private static _AmbientTextureEnabled;
  29013. /**
  29014. * Are ambient textures enabled in the application.
  29015. */
  29016. static get AmbientTextureEnabled(): boolean;
  29017. static set AmbientTextureEnabled(value: boolean);
  29018. private static _OpacityTextureEnabled;
  29019. /**
  29020. * Are opacity textures enabled in the application.
  29021. */
  29022. static get OpacityTextureEnabled(): boolean;
  29023. static set OpacityTextureEnabled(value: boolean);
  29024. private static _ReflectionTextureEnabled;
  29025. /**
  29026. * Are reflection textures enabled in the application.
  29027. */
  29028. static get ReflectionTextureEnabled(): boolean;
  29029. static set ReflectionTextureEnabled(value: boolean);
  29030. private static _EmissiveTextureEnabled;
  29031. /**
  29032. * Are emissive textures enabled in the application.
  29033. */
  29034. static get EmissiveTextureEnabled(): boolean;
  29035. static set EmissiveTextureEnabled(value: boolean);
  29036. private static _SpecularTextureEnabled;
  29037. /**
  29038. * Are specular textures enabled in the application.
  29039. */
  29040. static get SpecularTextureEnabled(): boolean;
  29041. static set SpecularTextureEnabled(value: boolean);
  29042. private static _BumpTextureEnabled;
  29043. /**
  29044. * Are bump textures enabled in the application.
  29045. */
  29046. static get BumpTextureEnabled(): boolean;
  29047. static set BumpTextureEnabled(value: boolean);
  29048. private static _LightmapTextureEnabled;
  29049. /**
  29050. * Are lightmap textures enabled in the application.
  29051. */
  29052. static get LightmapTextureEnabled(): boolean;
  29053. static set LightmapTextureEnabled(value: boolean);
  29054. private static _RefractionTextureEnabled;
  29055. /**
  29056. * Are refraction textures enabled in the application.
  29057. */
  29058. static get RefractionTextureEnabled(): boolean;
  29059. static set RefractionTextureEnabled(value: boolean);
  29060. private static _ColorGradingTextureEnabled;
  29061. /**
  29062. * Are color grading textures enabled in the application.
  29063. */
  29064. static get ColorGradingTextureEnabled(): boolean;
  29065. static set ColorGradingTextureEnabled(value: boolean);
  29066. private static _FresnelEnabled;
  29067. /**
  29068. * Are fresnels enabled in the application.
  29069. */
  29070. static get FresnelEnabled(): boolean;
  29071. static set FresnelEnabled(value: boolean);
  29072. private static _ClearCoatTextureEnabled;
  29073. /**
  29074. * Are clear coat textures enabled in the application.
  29075. */
  29076. static get ClearCoatTextureEnabled(): boolean;
  29077. static set ClearCoatTextureEnabled(value: boolean);
  29078. private static _ClearCoatBumpTextureEnabled;
  29079. /**
  29080. * Are clear coat bump textures enabled in the application.
  29081. */
  29082. static get ClearCoatBumpTextureEnabled(): boolean;
  29083. static set ClearCoatBumpTextureEnabled(value: boolean);
  29084. private static _ClearCoatTintTextureEnabled;
  29085. /**
  29086. * Are clear coat tint textures enabled in the application.
  29087. */
  29088. static get ClearCoatTintTextureEnabled(): boolean;
  29089. static set ClearCoatTintTextureEnabled(value: boolean);
  29090. private static _SheenTextureEnabled;
  29091. /**
  29092. * Are sheen textures enabled in the application.
  29093. */
  29094. static get SheenTextureEnabled(): boolean;
  29095. static set SheenTextureEnabled(value: boolean);
  29096. private static _AnisotropicTextureEnabled;
  29097. /**
  29098. * Are anisotropic textures enabled in the application.
  29099. */
  29100. static get AnisotropicTextureEnabled(): boolean;
  29101. static set AnisotropicTextureEnabled(value: boolean);
  29102. private static _ThicknessTextureEnabled;
  29103. /**
  29104. * Are thickness textures enabled in the application.
  29105. */
  29106. static get ThicknessTextureEnabled(): boolean;
  29107. static set ThicknessTextureEnabled(value: boolean);
  29108. }
  29109. }
  29110. declare module BABYLON {
  29111. /** @hidden */
  29112. export var defaultFragmentDeclaration: {
  29113. name: string;
  29114. shader: string;
  29115. };
  29116. }
  29117. declare module BABYLON {
  29118. /** @hidden */
  29119. export var defaultUboDeclaration: {
  29120. name: string;
  29121. shader: string;
  29122. };
  29123. }
  29124. declare module BABYLON {
  29125. /** @hidden */
  29126. export var lightFragmentDeclaration: {
  29127. name: string;
  29128. shader: string;
  29129. };
  29130. }
  29131. declare module BABYLON {
  29132. /** @hidden */
  29133. export var lightUboDeclaration: {
  29134. name: string;
  29135. shader: string;
  29136. };
  29137. }
  29138. declare module BABYLON {
  29139. /** @hidden */
  29140. export var lightsFragmentFunctions: {
  29141. name: string;
  29142. shader: string;
  29143. };
  29144. }
  29145. declare module BABYLON {
  29146. /** @hidden */
  29147. export var shadowsFragmentFunctions: {
  29148. name: string;
  29149. shader: string;
  29150. };
  29151. }
  29152. declare module BABYLON {
  29153. /** @hidden */
  29154. export var fresnelFunction: {
  29155. name: string;
  29156. shader: string;
  29157. };
  29158. }
  29159. declare module BABYLON {
  29160. /** @hidden */
  29161. export var bumpFragmentMainFunctions: {
  29162. name: string;
  29163. shader: string;
  29164. };
  29165. }
  29166. declare module BABYLON {
  29167. /** @hidden */
  29168. export var bumpFragmentFunctions: {
  29169. name: string;
  29170. shader: string;
  29171. };
  29172. }
  29173. declare module BABYLON {
  29174. /** @hidden */
  29175. export var logDepthDeclaration: {
  29176. name: string;
  29177. shader: string;
  29178. };
  29179. }
  29180. declare module BABYLON {
  29181. /** @hidden */
  29182. export var bumpFragment: {
  29183. name: string;
  29184. shader: string;
  29185. };
  29186. }
  29187. declare module BABYLON {
  29188. /** @hidden */
  29189. export var depthPrePass: {
  29190. name: string;
  29191. shader: string;
  29192. };
  29193. }
  29194. declare module BABYLON {
  29195. /** @hidden */
  29196. export var lightFragment: {
  29197. name: string;
  29198. shader: string;
  29199. };
  29200. }
  29201. declare module BABYLON {
  29202. /** @hidden */
  29203. export var logDepthFragment: {
  29204. name: string;
  29205. shader: string;
  29206. };
  29207. }
  29208. declare module BABYLON {
  29209. /** @hidden */
  29210. export var defaultPixelShader: {
  29211. name: string;
  29212. shader: string;
  29213. };
  29214. }
  29215. declare module BABYLON {
  29216. /** @hidden */
  29217. export var defaultVertexDeclaration: {
  29218. name: string;
  29219. shader: string;
  29220. };
  29221. }
  29222. declare module BABYLON {
  29223. /** @hidden */
  29224. export var bumpVertexDeclaration: {
  29225. name: string;
  29226. shader: string;
  29227. };
  29228. }
  29229. declare module BABYLON {
  29230. /** @hidden */
  29231. export var bumpVertex: {
  29232. name: string;
  29233. shader: string;
  29234. };
  29235. }
  29236. declare module BABYLON {
  29237. /** @hidden */
  29238. export var fogVertex: {
  29239. name: string;
  29240. shader: string;
  29241. };
  29242. }
  29243. declare module BABYLON {
  29244. /** @hidden */
  29245. export var shadowsVertex: {
  29246. name: string;
  29247. shader: string;
  29248. };
  29249. }
  29250. declare module BABYLON {
  29251. /** @hidden */
  29252. export var pointCloudVertex: {
  29253. name: string;
  29254. shader: string;
  29255. };
  29256. }
  29257. declare module BABYLON {
  29258. /** @hidden */
  29259. export var logDepthVertex: {
  29260. name: string;
  29261. shader: string;
  29262. };
  29263. }
  29264. declare module BABYLON {
  29265. /** @hidden */
  29266. export var defaultVertexShader: {
  29267. name: string;
  29268. shader: string;
  29269. };
  29270. }
  29271. declare module BABYLON {
  29272. /**
  29273. * @hidden
  29274. */
  29275. export interface IMaterialDetailMapDefines {
  29276. DETAIL: boolean;
  29277. DETAILDIRECTUV: number;
  29278. DETAIL_NORMALBLENDMETHOD: number;
  29279. /** @hidden */
  29280. _areTexturesDirty: boolean;
  29281. }
  29282. /**
  29283. * Define the code related to the detail map parameters of a material
  29284. *
  29285. * Inspired from:
  29286. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  29287. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  29288. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  29289. */
  29290. export class DetailMapConfiguration {
  29291. private _texture;
  29292. /**
  29293. * The detail texture of the material.
  29294. */
  29295. texture: Nullable<BaseTexture>;
  29296. /**
  29297. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  29298. * Bigger values mean stronger blending
  29299. */
  29300. diffuseBlendLevel: number;
  29301. /**
  29302. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  29303. * Bigger values mean stronger blending. Only used with PBR materials
  29304. */
  29305. roughnessBlendLevel: number;
  29306. /**
  29307. * Defines how strong the bump effect from the detail map is
  29308. * Bigger values mean stronger effect
  29309. */
  29310. bumpLevel: number;
  29311. private _normalBlendMethod;
  29312. /**
  29313. * The method used to blend the bump and detail normals together
  29314. */
  29315. normalBlendMethod: number;
  29316. private _isEnabled;
  29317. /**
  29318. * Enable or disable the detail map on this material
  29319. */
  29320. isEnabled: boolean;
  29321. /** @hidden */
  29322. private _internalMarkAllSubMeshesAsTexturesDirty;
  29323. /** @hidden */
  29324. _markAllSubMeshesAsTexturesDirty(): void;
  29325. /**
  29326. * Instantiate a new detail map
  29327. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  29328. */
  29329. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  29330. /**
  29331. * Gets whether the submesh is ready to be used or not.
  29332. * @param defines the list of "defines" to update.
  29333. * @param scene defines the scene the material belongs to.
  29334. * @returns - boolean indicating that the submesh is ready or not.
  29335. */
  29336. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  29337. /**
  29338. * Update the defines for detail map usage
  29339. * @param defines the list of "defines" to update.
  29340. * @param scene defines the scene the material belongs to.
  29341. */
  29342. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  29343. /**
  29344. * Binds the material data.
  29345. * @param uniformBuffer defines the Uniform buffer to fill in.
  29346. * @param scene defines the scene the material belongs to.
  29347. * @param isFrozen defines whether the material is frozen or not.
  29348. */
  29349. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  29350. /**
  29351. * Checks to see if a texture is used in the material.
  29352. * @param texture - Base texture to use.
  29353. * @returns - Boolean specifying if a texture is used in the material.
  29354. */
  29355. hasTexture(texture: BaseTexture): boolean;
  29356. /**
  29357. * Returns an array of the actively used textures.
  29358. * @param activeTextures Array of BaseTextures
  29359. */
  29360. getActiveTextures(activeTextures: BaseTexture[]): void;
  29361. /**
  29362. * Returns the animatable textures.
  29363. * @param animatables Array of animatable textures.
  29364. */
  29365. getAnimatables(animatables: IAnimatable[]): void;
  29366. /**
  29367. * Disposes the resources of the material.
  29368. * @param forceDisposeTextures - Forces the disposal of all textures.
  29369. */
  29370. dispose(forceDisposeTextures?: boolean): void;
  29371. /**
  29372. * Get the current class name useful for serialization or dynamic coding.
  29373. * @returns "DetailMap"
  29374. */
  29375. getClassName(): string;
  29376. /**
  29377. * Add the required uniforms to the current list.
  29378. * @param uniforms defines the current uniform list.
  29379. */
  29380. static AddUniforms(uniforms: string[]): void;
  29381. /**
  29382. * Add the required samplers to the current list.
  29383. * @param samplers defines the current sampler list.
  29384. */
  29385. static AddSamplers(samplers: string[]): void;
  29386. /**
  29387. * Add the required uniforms to the current buffer.
  29388. * @param uniformBuffer defines the current uniform buffer.
  29389. */
  29390. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  29391. /**
  29392. * Makes a duplicate of the current instance into another one.
  29393. * @param detailMap define the instance where to copy the info
  29394. */
  29395. copyTo(detailMap: DetailMapConfiguration): void;
  29396. /**
  29397. * Serializes this detail map instance
  29398. * @returns - An object with the serialized instance.
  29399. */
  29400. serialize(): any;
  29401. /**
  29402. * Parses a detail map setting from a serialized object.
  29403. * @param source - Serialized object.
  29404. * @param scene Defines the scene we are parsing for
  29405. * @param rootUrl Defines the rootUrl to load from
  29406. */
  29407. parse(source: any, scene: Scene, rootUrl: string): void;
  29408. }
  29409. }
  29410. declare module BABYLON {
  29411. /** @hidden */
  29412. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  29413. MAINUV1: boolean;
  29414. MAINUV2: boolean;
  29415. DIFFUSE: boolean;
  29416. DIFFUSEDIRECTUV: number;
  29417. DETAIL: boolean;
  29418. DETAILDIRECTUV: number;
  29419. DETAIL_NORMALBLENDMETHOD: number;
  29420. AMBIENT: boolean;
  29421. AMBIENTDIRECTUV: number;
  29422. OPACITY: boolean;
  29423. OPACITYDIRECTUV: number;
  29424. OPACITYRGB: boolean;
  29425. REFLECTION: boolean;
  29426. EMISSIVE: boolean;
  29427. EMISSIVEDIRECTUV: number;
  29428. SPECULAR: boolean;
  29429. SPECULARDIRECTUV: number;
  29430. BUMP: boolean;
  29431. BUMPDIRECTUV: number;
  29432. PARALLAX: boolean;
  29433. PARALLAXOCCLUSION: boolean;
  29434. SPECULAROVERALPHA: boolean;
  29435. CLIPPLANE: boolean;
  29436. CLIPPLANE2: boolean;
  29437. CLIPPLANE3: boolean;
  29438. CLIPPLANE4: boolean;
  29439. CLIPPLANE5: boolean;
  29440. CLIPPLANE6: boolean;
  29441. ALPHATEST: boolean;
  29442. DEPTHPREPASS: boolean;
  29443. ALPHAFROMDIFFUSE: boolean;
  29444. POINTSIZE: boolean;
  29445. FOG: boolean;
  29446. SPECULARTERM: boolean;
  29447. DIFFUSEFRESNEL: boolean;
  29448. OPACITYFRESNEL: boolean;
  29449. REFLECTIONFRESNEL: boolean;
  29450. REFRACTIONFRESNEL: boolean;
  29451. EMISSIVEFRESNEL: boolean;
  29452. FRESNEL: boolean;
  29453. NORMAL: boolean;
  29454. UV1: boolean;
  29455. UV2: boolean;
  29456. VERTEXCOLOR: boolean;
  29457. VERTEXALPHA: boolean;
  29458. NUM_BONE_INFLUENCERS: number;
  29459. BonesPerMesh: number;
  29460. BONETEXTURE: boolean;
  29461. INSTANCES: boolean;
  29462. THIN_INSTANCES: boolean;
  29463. GLOSSINESS: boolean;
  29464. ROUGHNESS: boolean;
  29465. EMISSIVEASILLUMINATION: boolean;
  29466. LINKEMISSIVEWITHDIFFUSE: boolean;
  29467. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29468. LIGHTMAP: boolean;
  29469. LIGHTMAPDIRECTUV: number;
  29470. OBJECTSPACE_NORMALMAP: boolean;
  29471. USELIGHTMAPASSHADOWMAP: boolean;
  29472. REFLECTIONMAP_3D: boolean;
  29473. REFLECTIONMAP_SPHERICAL: boolean;
  29474. REFLECTIONMAP_PLANAR: boolean;
  29475. REFLECTIONMAP_CUBIC: boolean;
  29476. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29477. REFLECTIONMAP_PROJECTION: boolean;
  29478. REFLECTIONMAP_SKYBOX: boolean;
  29479. REFLECTIONMAP_EXPLICIT: boolean;
  29480. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29481. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29482. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29483. INVERTCUBICMAP: boolean;
  29484. LOGARITHMICDEPTH: boolean;
  29485. REFRACTION: boolean;
  29486. REFRACTIONMAP_3D: boolean;
  29487. REFLECTIONOVERALPHA: boolean;
  29488. TWOSIDEDLIGHTING: boolean;
  29489. SHADOWFLOAT: boolean;
  29490. MORPHTARGETS: boolean;
  29491. MORPHTARGETS_NORMAL: boolean;
  29492. MORPHTARGETS_TANGENT: boolean;
  29493. MORPHTARGETS_UV: boolean;
  29494. NUM_MORPH_INFLUENCERS: number;
  29495. NONUNIFORMSCALING: boolean;
  29496. PREMULTIPLYALPHA: boolean;
  29497. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29498. ALPHABLEND: boolean;
  29499. RGBDLIGHTMAP: boolean;
  29500. RGBDREFLECTION: boolean;
  29501. RGBDREFRACTION: boolean;
  29502. IMAGEPROCESSING: boolean;
  29503. VIGNETTE: boolean;
  29504. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29505. VIGNETTEBLENDMODEOPAQUE: boolean;
  29506. TONEMAPPING: boolean;
  29507. TONEMAPPING_ACES: boolean;
  29508. CONTRAST: boolean;
  29509. COLORCURVES: boolean;
  29510. COLORGRADING: boolean;
  29511. COLORGRADING3D: boolean;
  29512. SAMPLER3DGREENDEPTH: boolean;
  29513. SAMPLER3DBGRMAP: boolean;
  29514. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29515. MULTIVIEW: boolean;
  29516. /**
  29517. * If the reflection texture on this material is in linear color space
  29518. * @hidden
  29519. */
  29520. IS_REFLECTION_LINEAR: boolean;
  29521. /**
  29522. * If the refraction texture on this material is in linear color space
  29523. * @hidden
  29524. */
  29525. IS_REFRACTION_LINEAR: boolean;
  29526. EXPOSURE: boolean;
  29527. constructor();
  29528. setReflectionMode(modeToEnable: string): void;
  29529. }
  29530. /**
  29531. * This is the default material used in Babylon. It is the best trade off between quality
  29532. * and performances.
  29533. * @see http://doc.babylonjs.com/babylon101/materials
  29534. */
  29535. export class StandardMaterial extends PushMaterial {
  29536. private _diffuseTexture;
  29537. /**
  29538. * The basic texture of the material as viewed under a light.
  29539. */
  29540. diffuseTexture: Nullable<BaseTexture>;
  29541. private _ambientTexture;
  29542. /**
  29543. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29544. */
  29545. ambientTexture: Nullable<BaseTexture>;
  29546. private _opacityTexture;
  29547. /**
  29548. * Define the transparency of the material from a texture.
  29549. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29550. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29551. */
  29552. opacityTexture: Nullable<BaseTexture>;
  29553. private _reflectionTexture;
  29554. /**
  29555. * Define the texture used to display the reflection.
  29556. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29557. */
  29558. reflectionTexture: Nullable<BaseTexture>;
  29559. private _emissiveTexture;
  29560. /**
  29561. * Define texture of the material as if self lit.
  29562. * This will be mixed in the final result even in the absence of light.
  29563. */
  29564. emissiveTexture: Nullable<BaseTexture>;
  29565. private _specularTexture;
  29566. /**
  29567. * Define how the color and intensity of the highlight given by the light in the material.
  29568. */
  29569. specularTexture: Nullable<BaseTexture>;
  29570. private _bumpTexture;
  29571. /**
  29572. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29573. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  29574. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29575. */
  29576. bumpTexture: Nullable<BaseTexture>;
  29577. private _lightmapTexture;
  29578. /**
  29579. * Complex lighting can be computationally expensive to compute at runtime.
  29580. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29581. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29582. */
  29583. lightmapTexture: Nullable<BaseTexture>;
  29584. private _refractionTexture;
  29585. /**
  29586. * Define the texture used to display the refraction.
  29587. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29588. */
  29589. refractionTexture: Nullable<BaseTexture>;
  29590. /**
  29591. * The color of the material lit by the environmental background lighting.
  29592. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29593. */
  29594. ambientColor: Color3;
  29595. /**
  29596. * The basic color of the material as viewed under a light.
  29597. */
  29598. diffuseColor: Color3;
  29599. /**
  29600. * Define how the color and intensity of the highlight given by the light in the material.
  29601. */
  29602. specularColor: Color3;
  29603. /**
  29604. * Define the color of the material as if self lit.
  29605. * This will be mixed in the final result even in the absence of light.
  29606. */
  29607. emissiveColor: Color3;
  29608. /**
  29609. * Defines how sharp are the highlights in the material.
  29610. * The bigger the value the sharper giving a more glossy feeling to the result.
  29611. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29612. */
  29613. specularPower: number;
  29614. private _useAlphaFromDiffuseTexture;
  29615. /**
  29616. * Does the transparency come from the diffuse texture alpha channel.
  29617. */
  29618. useAlphaFromDiffuseTexture: boolean;
  29619. private _useEmissiveAsIllumination;
  29620. /**
  29621. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29622. */
  29623. useEmissiveAsIllumination: boolean;
  29624. private _linkEmissiveWithDiffuse;
  29625. /**
  29626. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29627. * the emissive level when the final color is close to one.
  29628. */
  29629. linkEmissiveWithDiffuse: boolean;
  29630. private _useSpecularOverAlpha;
  29631. /**
  29632. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29633. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29634. */
  29635. useSpecularOverAlpha: boolean;
  29636. private _useReflectionOverAlpha;
  29637. /**
  29638. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29639. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29640. */
  29641. useReflectionOverAlpha: boolean;
  29642. private _disableLighting;
  29643. /**
  29644. * Does lights from the scene impacts this material.
  29645. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29646. */
  29647. disableLighting: boolean;
  29648. private _useObjectSpaceNormalMap;
  29649. /**
  29650. * Allows using an object space normal map (instead of tangent space).
  29651. */
  29652. useObjectSpaceNormalMap: boolean;
  29653. private _useParallax;
  29654. /**
  29655. * Is parallax enabled or not.
  29656. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29657. */
  29658. useParallax: boolean;
  29659. private _useParallaxOcclusion;
  29660. /**
  29661. * Is parallax occlusion enabled or not.
  29662. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29663. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29664. */
  29665. useParallaxOcclusion: boolean;
  29666. /**
  29667. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  29668. */
  29669. parallaxScaleBias: number;
  29670. private _roughness;
  29671. /**
  29672. * Helps to define how blurry the reflections should appears in the material.
  29673. */
  29674. roughness: number;
  29675. /**
  29676. * In case of refraction, define the value of the index of refraction.
  29677. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29678. */
  29679. indexOfRefraction: number;
  29680. /**
  29681. * Invert the refraction texture alongside the y axis.
  29682. * It can be useful with procedural textures or probe for instance.
  29683. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29684. */
  29685. invertRefractionY: boolean;
  29686. /**
  29687. * Defines the alpha limits in alpha test mode.
  29688. */
  29689. alphaCutOff: number;
  29690. private _useLightmapAsShadowmap;
  29691. /**
  29692. * In case of light mapping, define whether the map contains light or shadow informations.
  29693. */
  29694. useLightmapAsShadowmap: boolean;
  29695. private _diffuseFresnelParameters;
  29696. /**
  29697. * Define the diffuse fresnel parameters of the material.
  29698. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29699. */
  29700. diffuseFresnelParameters: FresnelParameters;
  29701. private _opacityFresnelParameters;
  29702. /**
  29703. * Define the opacity fresnel parameters of the material.
  29704. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29705. */
  29706. opacityFresnelParameters: FresnelParameters;
  29707. private _reflectionFresnelParameters;
  29708. /**
  29709. * Define the reflection fresnel parameters of the material.
  29710. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29711. */
  29712. reflectionFresnelParameters: FresnelParameters;
  29713. private _refractionFresnelParameters;
  29714. /**
  29715. * Define the refraction fresnel parameters of the material.
  29716. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29717. */
  29718. refractionFresnelParameters: FresnelParameters;
  29719. private _emissiveFresnelParameters;
  29720. /**
  29721. * Define the emissive fresnel parameters of the material.
  29722. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29723. */
  29724. emissiveFresnelParameters: FresnelParameters;
  29725. private _useReflectionFresnelFromSpecular;
  29726. /**
  29727. * If true automatically deducts the fresnels values from the material specularity.
  29728. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29729. */
  29730. useReflectionFresnelFromSpecular: boolean;
  29731. private _useGlossinessFromSpecularMapAlpha;
  29732. /**
  29733. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29734. */
  29735. useGlossinessFromSpecularMapAlpha: boolean;
  29736. private _maxSimultaneousLights;
  29737. /**
  29738. * Defines the maximum number of lights that can be used in the material
  29739. */
  29740. maxSimultaneousLights: number;
  29741. private _invertNormalMapX;
  29742. /**
  29743. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29744. */
  29745. invertNormalMapX: boolean;
  29746. private _invertNormalMapY;
  29747. /**
  29748. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29749. */
  29750. invertNormalMapY: boolean;
  29751. private _twoSidedLighting;
  29752. /**
  29753. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29754. */
  29755. twoSidedLighting: boolean;
  29756. /**
  29757. * Default configuration related to image processing available in the standard Material.
  29758. */
  29759. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29760. /**
  29761. * Gets the image processing configuration used either in this material.
  29762. */
  29763. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29764. /**
  29765. * Sets the Default image processing configuration used either in the this material.
  29766. *
  29767. * If sets to null, the scene one is in use.
  29768. */
  29769. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29770. /**
  29771. * Keep track of the image processing observer to allow dispose and replace.
  29772. */
  29773. private _imageProcessingObserver;
  29774. /**
  29775. * Attaches a new image processing configuration to the Standard Material.
  29776. * @param configuration
  29777. */
  29778. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29779. /**
  29780. * Gets wether the color curves effect is enabled.
  29781. */
  29782. get cameraColorCurvesEnabled(): boolean;
  29783. /**
  29784. * Sets wether the color curves effect is enabled.
  29785. */
  29786. set cameraColorCurvesEnabled(value: boolean);
  29787. /**
  29788. * Gets wether the color grading effect is enabled.
  29789. */
  29790. get cameraColorGradingEnabled(): boolean;
  29791. /**
  29792. * Gets wether the color grading effect is enabled.
  29793. */
  29794. set cameraColorGradingEnabled(value: boolean);
  29795. /**
  29796. * Gets wether tonemapping is enabled or not.
  29797. */
  29798. get cameraToneMappingEnabled(): boolean;
  29799. /**
  29800. * Sets wether tonemapping is enabled or not
  29801. */
  29802. set cameraToneMappingEnabled(value: boolean);
  29803. /**
  29804. * The camera exposure used on this material.
  29805. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29806. * This corresponds to a photographic exposure.
  29807. */
  29808. get cameraExposure(): number;
  29809. /**
  29810. * The camera exposure used on this material.
  29811. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29812. * This corresponds to a photographic exposure.
  29813. */
  29814. set cameraExposure(value: number);
  29815. /**
  29816. * Gets The camera contrast used on this material.
  29817. */
  29818. get cameraContrast(): number;
  29819. /**
  29820. * Sets The camera contrast used on this material.
  29821. */
  29822. set cameraContrast(value: number);
  29823. /**
  29824. * Gets the Color Grading 2D Lookup Texture.
  29825. */
  29826. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29827. /**
  29828. * Sets the Color Grading 2D Lookup Texture.
  29829. */
  29830. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29831. /**
  29832. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29833. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29834. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  29835. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29836. */
  29837. get cameraColorCurves(): Nullable<ColorCurves>;
  29838. /**
  29839. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29840. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29841. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  29842. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29843. */
  29844. set cameraColorCurves(value: Nullable<ColorCurves>);
  29845. /**
  29846. * Defines the detail map parameters for the material.
  29847. */
  29848. readonly detailMap: DetailMapConfiguration;
  29849. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29850. protected _worldViewProjectionMatrix: Matrix;
  29851. protected _globalAmbientColor: Color3;
  29852. protected _useLogarithmicDepth: boolean;
  29853. protected _rebuildInParallel: boolean;
  29854. /**
  29855. * Instantiates a new standard material.
  29856. * This is the default material used in Babylon. It is the best trade off between quality
  29857. * and performances.
  29858. * @see http://doc.babylonjs.com/babylon101/materials
  29859. * @param name Define the name of the material in the scene
  29860. * @param scene Define the scene the material belong to
  29861. */
  29862. constructor(name: string, scene: Scene);
  29863. /**
  29864. * Gets a boolean indicating that current material needs to register RTT
  29865. */
  29866. get hasRenderTargetTextures(): boolean;
  29867. /**
  29868. * Gets the current class name of the material e.g. "StandardMaterial"
  29869. * Mainly use in serialization.
  29870. * @returns the class name
  29871. */
  29872. getClassName(): string;
  29873. /**
  29874. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29875. * You can try switching to logarithmic depth.
  29876. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29877. */
  29878. get useLogarithmicDepth(): boolean;
  29879. set useLogarithmicDepth(value: boolean);
  29880. /**
  29881. * Specifies if the material will require alpha blending
  29882. * @returns a boolean specifying if alpha blending is needed
  29883. */
  29884. needAlphaBlending(): boolean;
  29885. /**
  29886. * Specifies if this material should be rendered in alpha test mode
  29887. * @returns a boolean specifying if an alpha test is needed.
  29888. */
  29889. needAlphaTesting(): boolean;
  29890. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29891. /**
  29892. * Get the texture used for alpha test purpose.
  29893. * @returns the diffuse texture in case of the standard material.
  29894. */
  29895. getAlphaTestTexture(): Nullable<BaseTexture>;
  29896. /**
  29897. * Get if the submesh is ready to be used and all its information available.
  29898. * Child classes can use it to update shaders
  29899. * @param mesh defines the mesh to check
  29900. * @param subMesh defines which submesh to check
  29901. * @param useInstances specifies that instances should be used
  29902. * @returns a boolean indicating that the submesh is ready or not
  29903. */
  29904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29905. /**
  29906. * Builds the material UBO layouts.
  29907. * Used internally during the effect preparation.
  29908. */
  29909. buildUniformLayout(): void;
  29910. /**
  29911. * Unbinds the material from the mesh
  29912. */
  29913. unbind(): void;
  29914. /**
  29915. * Binds the submesh to this material by preparing the effect and shader to draw
  29916. * @param world defines the world transformation matrix
  29917. * @param mesh defines the mesh containing the submesh
  29918. * @param subMesh defines the submesh to bind the material to
  29919. */
  29920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29921. /**
  29922. * Get the list of animatables in the material.
  29923. * @returns the list of animatables object used in the material
  29924. */
  29925. getAnimatables(): IAnimatable[];
  29926. /**
  29927. * Gets the active textures from the material
  29928. * @returns an array of textures
  29929. */
  29930. getActiveTextures(): BaseTexture[];
  29931. /**
  29932. * Specifies if the material uses a texture
  29933. * @param texture defines the texture to check against the material
  29934. * @returns a boolean specifying if the material uses the texture
  29935. */
  29936. hasTexture(texture: BaseTexture): boolean;
  29937. /**
  29938. * Disposes the material
  29939. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29940. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29941. */
  29942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29943. /**
  29944. * Makes a duplicate of the material, and gives it a new name
  29945. * @param name defines the new name for the duplicated material
  29946. * @returns the cloned material
  29947. */
  29948. clone(name: string): StandardMaterial;
  29949. /**
  29950. * Serializes this material in a JSON representation
  29951. * @returns the serialized material object
  29952. */
  29953. serialize(): any;
  29954. /**
  29955. * Creates a standard material from parsed material data
  29956. * @param source defines the JSON representation of the material
  29957. * @param scene defines the hosting scene
  29958. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29959. * @returns a new standard material
  29960. */
  29961. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29962. /**
  29963. * Are diffuse textures enabled in the application.
  29964. */
  29965. static get DiffuseTextureEnabled(): boolean;
  29966. static set DiffuseTextureEnabled(value: boolean);
  29967. /**
  29968. * Are detail textures enabled in the application.
  29969. */
  29970. static get DetailTextureEnabled(): boolean;
  29971. static set DetailTextureEnabled(value: boolean);
  29972. /**
  29973. * Are ambient textures enabled in the application.
  29974. */
  29975. static get AmbientTextureEnabled(): boolean;
  29976. static set AmbientTextureEnabled(value: boolean);
  29977. /**
  29978. * Are opacity textures enabled in the application.
  29979. */
  29980. static get OpacityTextureEnabled(): boolean;
  29981. static set OpacityTextureEnabled(value: boolean);
  29982. /**
  29983. * Are reflection textures enabled in the application.
  29984. */
  29985. static get ReflectionTextureEnabled(): boolean;
  29986. static set ReflectionTextureEnabled(value: boolean);
  29987. /**
  29988. * Are emissive textures enabled in the application.
  29989. */
  29990. static get EmissiveTextureEnabled(): boolean;
  29991. static set EmissiveTextureEnabled(value: boolean);
  29992. /**
  29993. * Are specular textures enabled in the application.
  29994. */
  29995. static get SpecularTextureEnabled(): boolean;
  29996. static set SpecularTextureEnabled(value: boolean);
  29997. /**
  29998. * Are bump textures enabled in the application.
  29999. */
  30000. static get BumpTextureEnabled(): boolean;
  30001. static set BumpTextureEnabled(value: boolean);
  30002. /**
  30003. * Are lightmap textures enabled in the application.
  30004. */
  30005. static get LightmapTextureEnabled(): boolean;
  30006. static set LightmapTextureEnabled(value: boolean);
  30007. /**
  30008. * Are refraction textures enabled in the application.
  30009. */
  30010. static get RefractionTextureEnabled(): boolean;
  30011. static set RefractionTextureEnabled(value: boolean);
  30012. /**
  30013. * Are color grading textures enabled in the application.
  30014. */
  30015. static get ColorGradingTextureEnabled(): boolean;
  30016. static set ColorGradingTextureEnabled(value: boolean);
  30017. /**
  30018. * Are fresnels enabled in the application.
  30019. */
  30020. static get FresnelEnabled(): boolean;
  30021. static set FresnelEnabled(value: boolean);
  30022. }
  30023. }
  30024. declare module BABYLON {
  30025. /**
  30026. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30027. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  30028. * The SPS is also a particle system. It provides some methods to manage the particles.
  30029. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30030. *
  30031. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30032. */
  30033. export class SolidParticleSystem implements IDisposable {
  30034. /**
  30035. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30036. * Example : var p = SPS.particles[i];
  30037. */
  30038. particles: SolidParticle[];
  30039. /**
  30040. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30041. */
  30042. nbParticles: number;
  30043. /**
  30044. * If the particles must ever face the camera (default false). Useful for planar particles.
  30045. */
  30046. billboard: boolean;
  30047. /**
  30048. * Recompute normals when adding a shape
  30049. */
  30050. recomputeNormals: boolean;
  30051. /**
  30052. * This a counter ofr your own usage. It's not set by any SPS functions.
  30053. */
  30054. counter: number;
  30055. /**
  30056. * The SPS name. This name is also given to the underlying mesh.
  30057. */
  30058. name: string;
  30059. /**
  30060. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30061. */
  30062. mesh: Mesh;
  30063. /**
  30064. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30065. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30066. */
  30067. vars: any;
  30068. /**
  30069. * This array is populated when the SPS is set as 'pickable'.
  30070. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30071. * Each element of this array is an object `{idx: int, faceId: int}`.
  30072. * `idx` is the picked particle index in the `SPS.particles` array
  30073. * `faceId` is the picked face index counted within this particle.
  30074. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30075. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30076. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30077. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30078. */
  30079. pickedParticles: {
  30080. idx: number;
  30081. faceId: number;
  30082. }[];
  30083. /**
  30084. * This array is populated when the SPS is set as 'pickable'
  30085. * Each key of this array is a submesh index.
  30086. * Each element of this array is a second array defined like this :
  30087. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30088. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30089. * `idx` is the picked particle index in the `SPS.particles` array
  30090. * `faceId` is the picked face index counted within this particle.
  30091. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30092. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30093. */
  30094. pickedBySubMesh: {
  30095. idx: number;
  30096. faceId: number;
  30097. }[][];
  30098. /**
  30099. * This array is populated when `enableDepthSort` is set to true.
  30100. * Each element of this array is an instance of the class DepthSortedParticle.
  30101. */
  30102. depthSortedParticles: DepthSortedParticle[];
  30103. /**
  30104. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30105. * @hidden
  30106. */
  30107. _bSphereOnly: boolean;
  30108. /**
  30109. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30110. * @hidden
  30111. */
  30112. _bSphereRadiusFactor: number;
  30113. private _scene;
  30114. private _positions;
  30115. private _indices;
  30116. private _normals;
  30117. private _colors;
  30118. private _uvs;
  30119. private _indices32;
  30120. private _positions32;
  30121. private _normals32;
  30122. private _fixedNormal32;
  30123. private _colors32;
  30124. private _uvs32;
  30125. private _index;
  30126. private _updatable;
  30127. private _pickable;
  30128. private _isVisibilityBoxLocked;
  30129. private _alwaysVisible;
  30130. private _depthSort;
  30131. private _expandable;
  30132. private _shapeCounter;
  30133. private _copy;
  30134. private _color;
  30135. private _computeParticleColor;
  30136. private _computeParticleTexture;
  30137. private _computeParticleRotation;
  30138. private _computeParticleVertex;
  30139. private _computeBoundingBox;
  30140. private _depthSortParticles;
  30141. private _camera;
  30142. private _mustUnrotateFixedNormals;
  30143. private _particlesIntersect;
  30144. private _needs32Bits;
  30145. private _isNotBuilt;
  30146. private _lastParticleId;
  30147. private _idxOfId;
  30148. private _multimaterialEnabled;
  30149. private _useModelMaterial;
  30150. private _indicesByMaterial;
  30151. private _materialIndexes;
  30152. private _depthSortFunction;
  30153. private _materialSortFunction;
  30154. private _materials;
  30155. private _multimaterial;
  30156. private _materialIndexesById;
  30157. private _defaultMaterial;
  30158. private _autoUpdateSubMeshes;
  30159. private _tmpVertex;
  30160. /**
  30161. * Creates a SPS (Solid Particle System) object.
  30162. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30163. * @param scene (Scene) is the scene in which the SPS is added.
  30164. * @param options defines the options of the sps e.g.
  30165. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30166. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30167. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30168. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  30169. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30170. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30171. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30172. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30173. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30174. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30175. */
  30176. constructor(name: string, scene: Scene, options?: {
  30177. updatable?: boolean;
  30178. isPickable?: boolean;
  30179. enableDepthSort?: boolean;
  30180. particleIntersection?: boolean;
  30181. boundingSphereOnly?: boolean;
  30182. bSphereRadiusFactor?: number;
  30183. expandable?: boolean;
  30184. useModelMaterial?: boolean;
  30185. enableMultiMaterial?: boolean;
  30186. });
  30187. /**
  30188. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30189. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30190. * @returns the created mesh
  30191. */
  30192. buildMesh(): Mesh;
  30193. /**
  30194. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30195. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30196. * Thus the particles generated from `digest()` have their property `position` set yet.
  30197. * @param mesh ( Mesh ) is the mesh to be digested
  30198. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  30199. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30200. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30201. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30202. * @returns the current SPS
  30203. */
  30204. digest(mesh: Mesh, options?: {
  30205. facetNb?: number;
  30206. number?: number;
  30207. delta?: number;
  30208. storage?: [];
  30209. }): SolidParticleSystem;
  30210. /**
  30211. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30212. * @hidden
  30213. */
  30214. private _unrotateFixedNormals;
  30215. /**
  30216. * Resets the temporary working copy particle
  30217. * @hidden
  30218. */
  30219. private _resetCopy;
  30220. /**
  30221. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30222. * @param p the current index in the positions array to be updated
  30223. * @param ind the current index in the indices array
  30224. * @param shape a Vector3 array, the shape geometry
  30225. * @param positions the positions array to be updated
  30226. * @param meshInd the shape indices array
  30227. * @param indices the indices array to be updated
  30228. * @param meshUV the shape uv array
  30229. * @param uvs the uv array to be updated
  30230. * @param meshCol the shape color array
  30231. * @param colors the color array to be updated
  30232. * @param meshNor the shape normals array
  30233. * @param normals the normals array to be updated
  30234. * @param idx the particle index
  30235. * @param idxInShape the particle index in its shape
  30236. * @param options the addShape() method passed options
  30237. * @model the particle model
  30238. * @hidden
  30239. */
  30240. private _meshBuilder;
  30241. /**
  30242. * Returns a shape Vector3 array from positions float array
  30243. * @param positions float array
  30244. * @returns a vector3 array
  30245. * @hidden
  30246. */
  30247. private _posToShape;
  30248. /**
  30249. * Returns a shapeUV array from a float uvs (array deep copy)
  30250. * @param uvs as a float array
  30251. * @returns a shapeUV array
  30252. * @hidden
  30253. */
  30254. private _uvsToShapeUV;
  30255. /**
  30256. * Adds a new particle object in the particles array
  30257. * @param idx particle index in particles array
  30258. * @param id particle id
  30259. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30260. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30261. * @param model particle ModelShape object
  30262. * @param shapeId model shape identifier
  30263. * @param idxInShape index of the particle in the current model
  30264. * @param bInfo model bounding info object
  30265. * @param storage target storage array, if any
  30266. * @hidden
  30267. */
  30268. private _addParticle;
  30269. /**
  30270. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30271. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30272. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30273. * @param nb (positive integer) the number of particles to be created from this model
  30274. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30275. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30276. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30277. * @returns the number of shapes in the system
  30278. */
  30279. addShape(mesh: Mesh, nb: number, options?: {
  30280. positionFunction?: any;
  30281. vertexFunction?: any;
  30282. storage?: [];
  30283. }): number;
  30284. /**
  30285. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30286. * @hidden
  30287. */
  30288. private _rebuildParticle;
  30289. /**
  30290. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30291. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  30292. * @returns the SPS.
  30293. */
  30294. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30295. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30296. * Returns an array with the removed particles.
  30297. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  30298. * The SPS can't be empty so at least one particle needs to remain in place.
  30299. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30300. * @param start index of the first particle to remove
  30301. * @param end index of the last particle to remove (included)
  30302. * @returns an array populated with the removed particles
  30303. */
  30304. removeParticles(start: number, end: number): SolidParticle[];
  30305. /**
  30306. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30307. * @param solidParticleArray an array populated with Solid Particles objects
  30308. * @returns the SPS
  30309. */
  30310. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30311. /**
  30312. * Creates a new particle and modifies the SPS mesh geometry :
  30313. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30314. * - calls _addParticle() to populate the particle array
  30315. * factorized code from addShape() and insertParticlesFromArray()
  30316. * @param idx particle index in the particles array
  30317. * @param i particle index in its shape
  30318. * @param modelShape particle ModelShape object
  30319. * @param shape shape vertex array
  30320. * @param meshInd shape indices array
  30321. * @param meshUV shape uv array
  30322. * @param meshCol shape color array
  30323. * @param meshNor shape normals array
  30324. * @param bbInfo shape bounding info
  30325. * @param storage target particle storage
  30326. * @options addShape() passed options
  30327. * @hidden
  30328. */
  30329. private _insertNewParticle;
  30330. /**
  30331. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30332. * This method calls `updateParticle()` for each particle of the SPS.
  30333. * For an animated SPS, it is usually called within the render loop.
  30334. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  30335. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30336. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30337. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30338. * @returns the SPS.
  30339. */
  30340. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30341. /**
  30342. * Disposes the SPS.
  30343. */
  30344. dispose(): void;
  30345. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30346. * idx is the particle index in the SPS
  30347. * faceId is the picked face index counted within this particle.
  30348. * Returns null if the pickInfo can't identify a picked particle.
  30349. * @param pickingInfo (PickingInfo object)
  30350. * @returns {idx: number, faceId: number} or null
  30351. */
  30352. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30353. idx: number;
  30354. faceId: number;
  30355. }>;
  30356. /**
  30357. * Returns a SolidParticle object from its identifier : particle.id
  30358. * @param id (integer) the particle Id
  30359. * @returns the searched particle or null if not found in the SPS.
  30360. */
  30361. getParticleById(id: number): Nullable<SolidParticle>;
  30362. /**
  30363. * Returns a new array populated with the particles having the passed shapeId.
  30364. * @param shapeId (integer) the shape identifier
  30365. * @returns a new solid particle array
  30366. */
  30367. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30368. /**
  30369. * Populates the passed array "ref" with the particles having the passed shapeId.
  30370. * @param shapeId the shape identifier
  30371. * @returns the SPS
  30372. * @param ref
  30373. */
  30374. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30375. /**
  30376. * Computes the required SubMeshes according the materials assigned to the particles.
  30377. * @returns the solid particle system.
  30378. * Does nothing if called before the SPS mesh is built.
  30379. */
  30380. computeSubMeshes(): SolidParticleSystem;
  30381. /**
  30382. * Sorts the solid particles by material when MultiMaterial is enabled.
  30383. * Updates the indices32 array.
  30384. * Updates the indicesByMaterial array.
  30385. * Updates the mesh indices array.
  30386. * @returns the SPS
  30387. * @hidden
  30388. */
  30389. private _sortParticlesByMaterial;
  30390. /**
  30391. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30392. * @hidden
  30393. */
  30394. private _setMaterialIndexesById;
  30395. /**
  30396. * Returns an array with unique values of Materials from the passed array
  30397. * @param array the material array to be checked and filtered
  30398. * @hidden
  30399. */
  30400. private _filterUniqueMaterialId;
  30401. /**
  30402. * Sets a new Standard Material as _defaultMaterial if not already set.
  30403. * @hidden
  30404. */
  30405. private _setDefaultMaterial;
  30406. /**
  30407. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30408. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30409. * @returns the SPS.
  30410. */
  30411. refreshVisibleSize(): SolidParticleSystem;
  30412. /**
  30413. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30414. * @param size the size (float) of the visibility box
  30415. * note : this doesn't lock the SPS mesh bounding box.
  30416. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30417. */
  30418. setVisibilityBox(size: number): void;
  30419. /**
  30420. * Gets whether the SPS as always visible or not
  30421. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30422. */
  30423. get isAlwaysVisible(): boolean;
  30424. /**
  30425. * Sets the SPS as always visible or not
  30426. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30427. */
  30428. set isAlwaysVisible(val: boolean);
  30429. /**
  30430. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30431. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30432. */
  30433. set isVisibilityBoxLocked(val: boolean);
  30434. /**
  30435. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30436. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30437. */
  30438. get isVisibilityBoxLocked(): boolean;
  30439. /**
  30440. * Tells to `setParticles()` to compute the particle rotations or not.
  30441. * Default value : true. The SPS is faster when it's set to false.
  30442. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30443. */
  30444. set computeParticleRotation(val: boolean);
  30445. /**
  30446. * Tells to `setParticles()` to compute the particle colors or not.
  30447. * Default value : true. The SPS is faster when it's set to false.
  30448. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30449. */
  30450. set computeParticleColor(val: boolean);
  30451. set computeParticleTexture(val: boolean);
  30452. /**
  30453. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30454. * Default value : false. The SPS is faster when it's set to false.
  30455. * Note : the particle custom vertex positions aren't stored values.
  30456. */
  30457. set computeParticleVertex(val: boolean);
  30458. /**
  30459. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30460. */
  30461. set computeBoundingBox(val: boolean);
  30462. /**
  30463. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30464. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30465. * Default : `true`
  30466. */
  30467. set depthSortParticles(val: boolean);
  30468. /**
  30469. * Gets if `setParticles()` computes the particle rotations or not.
  30470. * Default value : true. The SPS is faster when it's set to false.
  30471. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30472. */
  30473. get computeParticleRotation(): boolean;
  30474. /**
  30475. * Gets if `setParticles()` computes the particle colors or not.
  30476. * Default value : true. The SPS is faster when it's set to false.
  30477. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30478. */
  30479. get computeParticleColor(): boolean;
  30480. /**
  30481. * Gets if `setParticles()` computes the particle textures or not.
  30482. * Default value : true. The SPS is faster when it's set to false.
  30483. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30484. */
  30485. get computeParticleTexture(): boolean;
  30486. /**
  30487. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30488. * Default value : false. The SPS is faster when it's set to false.
  30489. * Note : the particle custom vertex positions aren't stored values.
  30490. */
  30491. get computeParticleVertex(): boolean;
  30492. /**
  30493. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30494. */
  30495. get computeBoundingBox(): boolean;
  30496. /**
  30497. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30498. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30499. * Default : `true`
  30500. */
  30501. get depthSortParticles(): boolean;
  30502. /**
  30503. * Gets if the SPS is created as expandable at construction time.
  30504. * Default : `false`
  30505. */
  30506. get expandable(): boolean;
  30507. /**
  30508. * Gets if the SPS supports the Multi Materials
  30509. */
  30510. get multimaterialEnabled(): boolean;
  30511. /**
  30512. * Gets if the SPS uses the model materials for its own multimaterial.
  30513. */
  30514. get useModelMaterial(): boolean;
  30515. /**
  30516. * The SPS used material array.
  30517. */
  30518. get materials(): Material[];
  30519. /**
  30520. * Sets the SPS MultiMaterial from the passed materials.
  30521. * Note : the passed array is internally copied and not used then by reference.
  30522. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30523. */
  30524. setMultiMaterial(materials: Material[]): void;
  30525. /**
  30526. * The SPS computed multimaterial object
  30527. */
  30528. get multimaterial(): MultiMaterial;
  30529. set multimaterial(mm: MultiMaterial);
  30530. /**
  30531. * If the subMeshes must be updated on the next call to setParticles()
  30532. */
  30533. get autoUpdateSubMeshes(): boolean;
  30534. set autoUpdateSubMeshes(val: boolean);
  30535. /**
  30536. * This function does nothing. It may be overwritten to set all the particle first values.
  30537. * The SPS doesn't call this function, you may have to call it by your own.
  30538. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30539. */
  30540. initParticles(): void;
  30541. /**
  30542. * This function does nothing. It may be overwritten to recycle a particle.
  30543. * The SPS doesn't call this function, you may have to call it by your own.
  30544. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30545. * @param particle The particle to recycle
  30546. * @returns the recycled particle
  30547. */
  30548. recycleParticle(particle: SolidParticle): SolidParticle;
  30549. /**
  30550. * Updates a particle : this function should be overwritten by the user.
  30551. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30552. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30553. * @example : just set a particle position or velocity and recycle conditions
  30554. * @param particle The particle to update
  30555. * @returns the updated particle
  30556. */
  30557. updateParticle(particle: SolidParticle): SolidParticle;
  30558. /**
  30559. * Updates a vertex of a particle : it can be overwritten by the user.
  30560. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30561. * @param particle the current particle
  30562. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30563. * @param pt the index of the current vertex in the particle shape
  30564. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30565. * @example : just set a vertex particle position or color
  30566. * @returns the sps
  30567. */
  30568. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30569. /**
  30570. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30571. * This does nothing and may be overwritten by the user.
  30572. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30573. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30574. * @param update the boolean update value actually passed to setParticles()
  30575. */
  30576. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30577. /**
  30578. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30579. * This will be passed three parameters.
  30580. * This does nothing and may be overwritten by the user.
  30581. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30582. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30583. * @param update the boolean update value actually passed to setParticles()
  30584. */
  30585. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30586. }
  30587. }
  30588. declare module BABYLON {
  30589. /**
  30590. * Represents one particle of a solid particle system.
  30591. */
  30592. export class SolidParticle {
  30593. /**
  30594. * particle global index
  30595. */
  30596. idx: number;
  30597. /**
  30598. * particle identifier
  30599. */
  30600. id: number;
  30601. /**
  30602. * The color of the particle
  30603. */
  30604. color: Nullable<Color4>;
  30605. /**
  30606. * The world space position of the particle.
  30607. */
  30608. position: Vector3;
  30609. /**
  30610. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30611. */
  30612. rotation: Vector3;
  30613. /**
  30614. * The world space rotation quaternion of the particle.
  30615. */
  30616. rotationQuaternion: Nullable<Quaternion>;
  30617. /**
  30618. * The scaling of the particle.
  30619. */
  30620. scaling: Vector3;
  30621. /**
  30622. * The uvs of the particle.
  30623. */
  30624. uvs: Vector4;
  30625. /**
  30626. * The current speed of the particle.
  30627. */
  30628. velocity: Vector3;
  30629. /**
  30630. * The pivot point in the particle local space.
  30631. */
  30632. pivot: Vector3;
  30633. /**
  30634. * Must the particle be translated from its pivot point in its local space ?
  30635. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30636. * Default : false
  30637. */
  30638. translateFromPivot: boolean;
  30639. /**
  30640. * Is the particle active or not ?
  30641. */
  30642. alive: boolean;
  30643. /**
  30644. * Is the particle visible or not ?
  30645. */
  30646. isVisible: boolean;
  30647. /**
  30648. * Index of this particle in the global "positions" array (Internal use)
  30649. * @hidden
  30650. */
  30651. _pos: number;
  30652. /**
  30653. * @hidden Index of this particle in the global "indices" array (Internal use)
  30654. */
  30655. _ind: number;
  30656. /**
  30657. * @hidden ModelShape of this particle (Internal use)
  30658. */
  30659. _model: ModelShape;
  30660. /**
  30661. * ModelShape id of this particle
  30662. */
  30663. shapeId: number;
  30664. /**
  30665. * Index of the particle in its shape id
  30666. */
  30667. idxInShape: number;
  30668. /**
  30669. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30670. */
  30671. _modelBoundingInfo: BoundingInfo;
  30672. /**
  30673. * @hidden Particle BoundingInfo object (Internal use)
  30674. */
  30675. _boundingInfo: BoundingInfo;
  30676. /**
  30677. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30678. */
  30679. _sps: SolidParticleSystem;
  30680. /**
  30681. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30682. */
  30683. _stillInvisible: boolean;
  30684. /**
  30685. * @hidden Last computed particle rotation matrix
  30686. */
  30687. _rotationMatrix: number[];
  30688. /**
  30689. * Parent particle Id, if any.
  30690. * Default null.
  30691. */
  30692. parentId: Nullable<number>;
  30693. /**
  30694. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30695. */
  30696. materialIndex: Nullable<number>;
  30697. /**
  30698. * Custom object or properties.
  30699. */
  30700. props: Nullable<any>;
  30701. /**
  30702. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30703. * The possible values are :
  30704. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30705. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30706. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30707. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30708. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30709. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30710. * */
  30711. cullingStrategy: number;
  30712. /**
  30713. * @hidden Internal global position in the SPS.
  30714. */
  30715. _globalPosition: Vector3;
  30716. /**
  30717. * Creates a Solid Particle object.
  30718. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30719. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30720. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30721. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30722. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30723. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30724. * @param shapeId (integer) is the model shape identifier in the SPS.
  30725. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30726. * @param sps defines the sps it is associated to
  30727. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30728. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30729. */
  30730. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30731. /**
  30732. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30733. * @param target the particle target
  30734. * @returns the current particle
  30735. */
  30736. copyToRef(target: SolidParticle): SolidParticle;
  30737. /**
  30738. * Legacy support, changed scale to scaling
  30739. */
  30740. get scale(): Vector3;
  30741. /**
  30742. * Legacy support, changed scale to scaling
  30743. */
  30744. set scale(scale: Vector3);
  30745. /**
  30746. * Legacy support, changed quaternion to rotationQuaternion
  30747. */
  30748. get quaternion(): Nullable<Quaternion>;
  30749. /**
  30750. * Legacy support, changed quaternion to rotationQuaternion
  30751. */
  30752. set quaternion(q: Nullable<Quaternion>);
  30753. /**
  30754. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30755. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30756. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30757. * @returns true if it intersects
  30758. */
  30759. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30760. /**
  30761. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30762. * A particle is in the frustum if its bounding box intersects the frustum
  30763. * @param frustumPlanes defines the frustum to test
  30764. * @returns true if the particle is in the frustum planes
  30765. */
  30766. isInFrustum(frustumPlanes: Plane[]): boolean;
  30767. /**
  30768. * get the rotation matrix of the particle
  30769. * @hidden
  30770. */
  30771. getRotationMatrix(m: Matrix): void;
  30772. }
  30773. /**
  30774. * Represents the shape of the model used by one particle of a solid particle system.
  30775. * SPS internal tool, don't use it manually.
  30776. */
  30777. export class ModelShape {
  30778. /**
  30779. * The shape id
  30780. * @hidden
  30781. */
  30782. shapeID: number;
  30783. /**
  30784. * flat array of model positions (internal use)
  30785. * @hidden
  30786. */
  30787. _shape: Vector3[];
  30788. /**
  30789. * flat array of model UVs (internal use)
  30790. * @hidden
  30791. */
  30792. _shapeUV: number[];
  30793. /**
  30794. * color array of the model
  30795. * @hidden
  30796. */
  30797. _shapeColors: number[];
  30798. /**
  30799. * indices array of the model
  30800. * @hidden
  30801. */
  30802. _indices: number[];
  30803. /**
  30804. * normals array of the model
  30805. * @hidden
  30806. */
  30807. _normals: number[];
  30808. /**
  30809. * length of the shape in the model indices array (internal use)
  30810. * @hidden
  30811. */
  30812. _indicesLength: number;
  30813. /**
  30814. * Custom position function (internal use)
  30815. * @hidden
  30816. */
  30817. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30818. /**
  30819. * Custom vertex function (internal use)
  30820. * @hidden
  30821. */
  30822. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30823. /**
  30824. * Model material (internal use)
  30825. * @hidden
  30826. */
  30827. _material: Nullable<Material>;
  30828. /**
  30829. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  30830. * SPS internal tool, don't use it manually.
  30831. * @hidden
  30832. */
  30833. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  30834. }
  30835. /**
  30836. * Represents a Depth Sorted Particle in the solid particle system.
  30837. * @hidden
  30838. */
  30839. export class DepthSortedParticle {
  30840. /**
  30841. * Particle index
  30842. */
  30843. idx: number;
  30844. /**
  30845. * Index of the particle in the "indices" array
  30846. */
  30847. ind: number;
  30848. /**
  30849. * Length of the particle shape in the "indices" array
  30850. */
  30851. indicesLength: number;
  30852. /**
  30853. * Squared distance from the particle to the camera
  30854. */
  30855. sqDistance: number;
  30856. /**
  30857. * Material index when used with MultiMaterials
  30858. */
  30859. materialIndex: number;
  30860. /**
  30861. * Creates a new sorted particle
  30862. * @param materialIndex
  30863. */
  30864. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30865. }
  30866. /**
  30867. * Represents a solid particle vertex
  30868. */
  30869. export class SolidParticleVertex {
  30870. /**
  30871. * Vertex position
  30872. */
  30873. position: Vector3;
  30874. /**
  30875. * Vertex color
  30876. */
  30877. color: Color4;
  30878. /**
  30879. * Vertex UV
  30880. */
  30881. uv: Vector2;
  30882. /**
  30883. * Creates a new solid particle vertex
  30884. */
  30885. constructor();
  30886. /** Vertex x coordinate */
  30887. get x(): number;
  30888. set x(val: number);
  30889. /** Vertex y coordinate */
  30890. get y(): number;
  30891. set y(val: number);
  30892. /** Vertex z coordinate */
  30893. get z(): number;
  30894. set z(val: number);
  30895. }
  30896. }
  30897. declare module BABYLON {
  30898. /**
  30899. * @hidden
  30900. */
  30901. export class _MeshCollisionData {
  30902. _checkCollisions: boolean;
  30903. _collisionMask: number;
  30904. _collisionGroup: number;
  30905. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30906. _collider: Nullable<Collider>;
  30907. _oldPositionForCollisions: Vector3;
  30908. _diffPositionForCollisions: Vector3;
  30909. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30910. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30911. }
  30912. }
  30913. declare module BABYLON {
  30914. /** @hidden */
  30915. class _FacetDataStorage {
  30916. facetPositions: Vector3[];
  30917. facetNormals: Vector3[];
  30918. facetPartitioning: number[][];
  30919. facetNb: number;
  30920. partitioningSubdivisions: number;
  30921. partitioningBBoxRatio: number;
  30922. facetDataEnabled: boolean;
  30923. facetParameters: any;
  30924. bbSize: Vector3;
  30925. subDiv: {
  30926. max: number;
  30927. X: number;
  30928. Y: number;
  30929. Z: number;
  30930. };
  30931. facetDepthSort: boolean;
  30932. facetDepthSortEnabled: boolean;
  30933. depthSortedIndices: IndicesArray;
  30934. depthSortedFacets: {
  30935. ind: number;
  30936. sqDistance: number;
  30937. }[];
  30938. facetDepthSortFunction: (f1: {
  30939. ind: number;
  30940. sqDistance: number;
  30941. }, f2: {
  30942. ind: number;
  30943. sqDistance: number;
  30944. }) => number;
  30945. facetDepthSortFrom: Vector3;
  30946. facetDepthSortOrigin: Vector3;
  30947. invertedMatrix: Matrix;
  30948. }
  30949. /**
  30950. * @hidden
  30951. **/
  30952. class _InternalAbstractMeshDataInfo {
  30953. _hasVertexAlpha: boolean;
  30954. _useVertexColors: boolean;
  30955. _numBoneInfluencers: number;
  30956. _applyFog: boolean;
  30957. _receiveShadows: boolean;
  30958. _facetData: _FacetDataStorage;
  30959. _visibility: number;
  30960. _skeleton: Nullable<Skeleton>;
  30961. _layerMask: number;
  30962. _computeBonesUsingShaders: boolean;
  30963. _isActive: boolean;
  30964. _onlyForInstances: boolean;
  30965. _isActiveIntermediate: boolean;
  30966. _onlyForInstancesIntermediate: boolean;
  30967. _actAsRegularMesh: boolean;
  30968. }
  30969. /**
  30970. * Class used to store all common mesh properties
  30971. */
  30972. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30973. /** No occlusion */
  30974. static OCCLUSION_TYPE_NONE: number;
  30975. /** Occlusion set to optimisitic */
  30976. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30977. /** Occlusion set to strict */
  30978. static OCCLUSION_TYPE_STRICT: number;
  30979. /** Use an accurante occlusion algorithm */
  30980. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30981. /** Use a conservative occlusion algorithm */
  30982. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30983. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30984. * Test order :
  30985. * Is the bounding sphere outside the frustum ?
  30986. * If not, are the bounding box vertices outside the frustum ?
  30987. * It not, then the cullable object is in the frustum.
  30988. */
  30989. static readonly CULLINGSTRATEGY_STANDARD: number;
  30990. /** Culling strategy : Bounding Sphere Only.
  30991. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30992. * It's also less accurate than the standard because some not visible objects can still be selected.
  30993. * Test : is the bounding sphere outside the frustum ?
  30994. * If not, then the cullable object is in the frustum.
  30995. */
  30996. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30997. /** Culling strategy : Optimistic Inclusion.
  30998. * This in an inclusion test first, then the standard exclusion test.
  30999. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31000. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  31001. * Anyway, it's as accurate as the standard strategy.
  31002. * Test :
  31003. * Is the cullable object bounding sphere center in the frustum ?
  31004. * If not, apply the default culling strategy.
  31005. */
  31006. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31007. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31008. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31009. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31010. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  31011. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31012. * Test :
  31013. * Is the cullable object bounding sphere center in the frustum ?
  31014. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31015. */
  31016. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31017. /**
  31018. * No billboard
  31019. */
  31020. static get BILLBOARDMODE_NONE(): number;
  31021. /** Billboard on X axis */
  31022. static get BILLBOARDMODE_X(): number;
  31023. /** Billboard on Y axis */
  31024. static get BILLBOARDMODE_Y(): number;
  31025. /** Billboard on Z axis */
  31026. static get BILLBOARDMODE_Z(): number;
  31027. /** Billboard on all axes */
  31028. static get BILLBOARDMODE_ALL(): number;
  31029. /** Billboard on using position instead of orientation */
  31030. static get BILLBOARDMODE_USE_POSITION(): number;
  31031. /** @hidden */
  31032. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31033. /**
  31034. * The culling strategy to use to check whether the mesh must be rendered or not.
  31035. * This value can be changed at any time and will be used on the next render mesh selection.
  31036. * The possible values are :
  31037. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31038. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31039. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31040. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31041. * Please read each static variable documentation to get details about the culling process.
  31042. * */
  31043. cullingStrategy: number;
  31044. /**
  31045. * Gets the number of facets in the mesh
  31046. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31047. */
  31048. get facetNb(): number;
  31049. /**
  31050. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31052. */
  31053. get partitioningSubdivisions(): number;
  31054. set partitioningSubdivisions(nb: number);
  31055. /**
  31056. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31057. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31059. */
  31060. get partitioningBBoxRatio(): number;
  31061. set partitioningBBoxRatio(ratio: number);
  31062. /**
  31063. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31064. * Works only for updatable meshes.
  31065. * Doesn't work with multi-materials
  31066. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31067. */
  31068. get mustDepthSortFacets(): boolean;
  31069. set mustDepthSortFacets(sort: boolean);
  31070. /**
  31071. * The location (Vector3) where the facet depth sort must be computed from.
  31072. * By default, the active camera position.
  31073. * Used only when facet depth sort is enabled
  31074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31075. */
  31076. get facetDepthSortFrom(): Vector3;
  31077. set facetDepthSortFrom(location: Vector3);
  31078. /**
  31079. * gets a boolean indicating if facetData is enabled
  31080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31081. */
  31082. get isFacetDataEnabled(): boolean;
  31083. /** @hidden */
  31084. _updateNonUniformScalingState(value: boolean): boolean;
  31085. /**
  31086. * An event triggered when this mesh collides with another one
  31087. */
  31088. onCollideObservable: Observable<AbstractMesh>;
  31089. /** Set a function to call when this mesh collides with another one */
  31090. set onCollide(callback: () => void);
  31091. /**
  31092. * An event triggered when the collision's position changes
  31093. */
  31094. onCollisionPositionChangeObservable: Observable<Vector3>;
  31095. /** Set a function to call when the collision's position changes */
  31096. set onCollisionPositionChange(callback: () => void);
  31097. /**
  31098. * An event triggered when material is changed
  31099. */
  31100. onMaterialChangedObservable: Observable<AbstractMesh>;
  31101. /**
  31102. * Gets or sets the orientation for POV movement & rotation
  31103. */
  31104. definedFacingForward: boolean;
  31105. /** @hidden */
  31106. _occlusionQuery: Nullable<WebGLQuery>;
  31107. /** @hidden */
  31108. _renderingGroup: Nullable<RenderingGroup>;
  31109. /**
  31110. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31111. */
  31112. get visibility(): number;
  31113. /**
  31114. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31115. */
  31116. set visibility(value: number);
  31117. /** Gets or sets the alpha index used to sort transparent meshes
  31118. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31119. */
  31120. alphaIndex: number;
  31121. /**
  31122. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31123. */
  31124. isVisible: boolean;
  31125. /**
  31126. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31127. */
  31128. isPickable: boolean;
  31129. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31130. showSubMeshesBoundingBox: boolean;
  31131. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31132. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31133. */
  31134. isBlocker: boolean;
  31135. /**
  31136. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31137. */
  31138. enablePointerMoveEvents: boolean;
  31139. /**
  31140. * Specifies the rendering group id for this mesh (0 by default)
  31141. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31142. */
  31143. renderingGroupId: number;
  31144. private _material;
  31145. /** Gets or sets current material */
  31146. get material(): Nullable<Material>;
  31147. set material(value: Nullable<Material>);
  31148. /**
  31149. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31150. * @see http://doc.babylonjs.com/babylon101/shadows
  31151. */
  31152. get receiveShadows(): boolean;
  31153. set receiveShadows(value: boolean);
  31154. /** Defines color to use when rendering outline */
  31155. outlineColor: Color3;
  31156. /** Define width to use when rendering outline */
  31157. outlineWidth: number;
  31158. /** Defines color to use when rendering overlay */
  31159. overlayColor: Color3;
  31160. /** Defines alpha to use when rendering overlay */
  31161. overlayAlpha: number;
  31162. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31163. get hasVertexAlpha(): boolean;
  31164. set hasVertexAlpha(value: boolean);
  31165. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  31166. get useVertexColors(): boolean;
  31167. set useVertexColors(value: boolean);
  31168. /**
  31169. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31170. */
  31171. get computeBonesUsingShaders(): boolean;
  31172. set computeBonesUsingShaders(value: boolean);
  31173. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31174. get numBoneInfluencers(): number;
  31175. set numBoneInfluencers(value: number);
  31176. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31177. get applyFog(): boolean;
  31178. set applyFog(value: boolean);
  31179. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31180. useOctreeForRenderingSelection: boolean;
  31181. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31182. useOctreeForPicking: boolean;
  31183. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31184. useOctreeForCollisions: boolean;
  31185. /**
  31186. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31187. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31188. */
  31189. get layerMask(): number;
  31190. set layerMask(value: number);
  31191. /**
  31192. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31193. */
  31194. alwaysSelectAsActiveMesh: boolean;
  31195. /**
  31196. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31197. */
  31198. doNotSyncBoundingInfo: boolean;
  31199. /**
  31200. * Gets or sets the current action manager
  31201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31202. */
  31203. actionManager: Nullable<AbstractActionManager>;
  31204. private _meshCollisionData;
  31205. /**
  31206. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31207. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31208. */
  31209. ellipsoid: Vector3;
  31210. /**
  31211. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31212. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31213. */
  31214. ellipsoidOffset: Vector3;
  31215. /**
  31216. * Gets or sets a collision mask used to mask collisions (default is -1).
  31217. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31218. */
  31219. get collisionMask(): number;
  31220. set collisionMask(mask: number);
  31221. /**
  31222. * Gets or sets the current collision group mask (-1 by default).
  31223. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31224. */
  31225. get collisionGroup(): number;
  31226. set collisionGroup(mask: number);
  31227. /**
  31228. * Gets or sets current surrounding meshes (null by default).
  31229. *
  31230. * By default collision detection is tested against every mesh in the scene.
  31231. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31232. * meshes will be tested for the collision.
  31233. *
  31234. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31235. */
  31236. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31237. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31238. /**
  31239. * Defines edge width used when edgesRenderer is enabled
  31240. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31241. */
  31242. edgesWidth: number;
  31243. /**
  31244. * Defines edge color used when edgesRenderer is enabled
  31245. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31246. */
  31247. edgesColor: Color4;
  31248. /** @hidden */
  31249. _edgesRenderer: Nullable<IEdgesRenderer>;
  31250. /** @hidden */
  31251. _masterMesh: Nullable<AbstractMesh>;
  31252. /** @hidden */
  31253. _boundingInfo: Nullable<BoundingInfo>;
  31254. /** @hidden */
  31255. _renderId: number;
  31256. /**
  31257. * Gets or sets the list of subMeshes
  31258. * @see http://doc.babylonjs.com/how_to/multi_materials
  31259. */
  31260. subMeshes: SubMesh[];
  31261. /** @hidden */
  31262. _intersectionsInProgress: AbstractMesh[];
  31263. /** @hidden */
  31264. _unIndexed: boolean;
  31265. /** @hidden */
  31266. _lightSources: Light[];
  31267. /** Gets the list of lights affecting that mesh */
  31268. get lightSources(): Light[];
  31269. /** @hidden */
  31270. get _positions(): Nullable<Vector3[]>;
  31271. /** @hidden */
  31272. _waitingData: {
  31273. lods: Nullable<any>;
  31274. actions: Nullable<any>;
  31275. freezeWorldMatrix: Nullable<boolean>;
  31276. };
  31277. /** @hidden */
  31278. _bonesTransformMatrices: Nullable<Float32Array>;
  31279. /** @hidden */
  31280. _transformMatrixTexture: Nullable<RawTexture>;
  31281. /**
  31282. * Gets or sets a skeleton to apply skining transformations
  31283. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31284. */
  31285. set skeleton(value: Nullable<Skeleton>);
  31286. get skeleton(): Nullable<Skeleton>;
  31287. /**
  31288. * An event triggered when the mesh is rebuilt.
  31289. */
  31290. onRebuildObservable: Observable<AbstractMesh>;
  31291. /**
  31292. * Creates a new AbstractMesh
  31293. * @param name defines the name of the mesh
  31294. * @param scene defines the hosting scene
  31295. */
  31296. constructor(name: string, scene?: Nullable<Scene>);
  31297. /**
  31298. * Returns the string "AbstractMesh"
  31299. * @returns "AbstractMesh"
  31300. */
  31301. getClassName(): string;
  31302. /**
  31303. * Gets a string representation of the current mesh
  31304. * @param fullDetails defines a boolean indicating if full details must be included
  31305. * @returns a string representation of the current mesh
  31306. */
  31307. toString(fullDetails?: boolean): string;
  31308. /**
  31309. * @hidden
  31310. */
  31311. protected _getEffectiveParent(): Nullable<Node>;
  31312. /** @hidden */
  31313. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31314. /** @hidden */
  31315. _rebuild(): void;
  31316. /** @hidden */
  31317. _resyncLightSources(): void;
  31318. /** @hidden */
  31319. _resyncLightSource(light: Light): void;
  31320. /** @hidden */
  31321. _unBindEffect(): void;
  31322. /** @hidden */
  31323. _removeLightSource(light: Light, dispose: boolean): void;
  31324. private _markSubMeshesAsDirty;
  31325. /** @hidden */
  31326. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31327. /** @hidden */
  31328. _markSubMeshesAsAttributesDirty(): void;
  31329. /** @hidden */
  31330. _markSubMeshesAsMiscDirty(): void;
  31331. /**
  31332. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31333. */
  31334. get scaling(): Vector3;
  31335. set scaling(newScaling: Vector3);
  31336. /**
  31337. * Returns true if the mesh is blocked. Implemented by child classes
  31338. */
  31339. get isBlocked(): boolean;
  31340. /**
  31341. * Returns the mesh itself by default. Implemented by child classes
  31342. * @param camera defines the camera to use to pick the right LOD level
  31343. * @returns the currentAbstractMesh
  31344. */
  31345. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31346. /**
  31347. * Returns 0 by default. Implemented by child classes
  31348. * @returns an integer
  31349. */
  31350. getTotalVertices(): number;
  31351. /**
  31352. * Returns a positive integer : the total number of indices in this mesh geometry.
  31353. * @returns the numner of indices or zero if the mesh has no geometry.
  31354. */
  31355. getTotalIndices(): number;
  31356. /**
  31357. * Returns null by default. Implemented by child classes
  31358. * @returns null
  31359. */
  31360. getIndices(): Nullable<IndicesArray>;
  31361. /**
  31362. * Returns the array of the requested vertex data kind. Implemented by child classes
  31363. * @param kind defines the vertex data kind to use
  31364. * @returns null
  31365. */
  31366. getVerticesData(kind: string): Nullable<FloatArray>;
  31367. /**
  31368. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31369. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31370. * Note that a new underlying VertexBuffer object is created each call.
  31371. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31372. * @param kind defines vertex data kind:
  31373. * * VertexBuffer.PositionKind
  31374. * * VertexBuffer.UVKind
  31375. * * VertexBuffer.UV2Kind
  31376. * * VertexBuffer.UV3Kind
  31377. * * VertexBuffer.UV4Kind
  31378. * * VertexBuffer.UV5Kind
  31379. * * VertexBuffer.UV6Kind
  31380. * * VertexBuffer.ColorKind
  31381. * * VertexBuffer.MatricesIndicesKind
  31382. * * VertexBuffer.MatricesIndicesExtraKind
  31383. * * VertexBuffer.MatricesWeightsKind
  31384. * * VertexBuffer.MatricesWeightsExtraKind
  31385. * @param data defines the data source
  31386. * @param updatable defines if the data must be flagged as updatable (or static)
  31387. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  31388. * @returns the current mesh
  31389. */
  31390. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31391. /**
  31392. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31393. * If the mesh has no geometry, it is simply returned as it is.
  31394. * @param kind defines vertex data kind:
  31395. * * VertexBuffer.PositionKind
  31396. * * VertexBuffer.UVKind
  31397. * * VertexBuffer.UV2Kind
  31398. * * VertexBuffer.UV3Kind
  31399. * * VertexBuffer.UV4Kind
  31400. * * VertexBuffer.UV5Kind
  31401. * * VertexBuffer.UV6Kind
  31402. * * VertexBuffer.ColorKind
  31403. * * VertexBuffer.MatricesIndicesKind
  31404. * * VertexBuffer.MatricesIndicesExtraKind
  31405. * * VertexBuffer.MatricesWeightsKind
  31406. * * VertexBuffer.MatricesWeightsExtraKind
  31407. * @param data defines the data source
  31408. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  31409. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31410. * @returns the current mesh
  31411. */
  31412. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31413. /**
  31414. * Sets the mesh indices,
  31415. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31416. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31417. * @param totalVertices Defines the total number of vertices
  31418. * @returns the current mesh
  31419. */
  31420. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31421. /**
  31422. * Gets a boolean indicating if specific vertex data is present
  31423. * @param kind defines the vertex data kind to use
  31424. * @returns true is data kind is present
  31425. */
  31426. isVerticesDataPresent(kind: string): boolean;
  31427. /**
  31428. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31429. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31430. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31431. * @returns a BoundingInfo
  31432. */
  31433. getBoundingInfo(): BoundingInfo;
  31434. /**
  31435. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31436. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31437. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31438. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31439. * @returns the current mesh
  31440. */
  31441. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31442. /**
  31443. * Overwrite the current bounding info
  31444. * @param boundingInfo defines the new bounding info
  31445. * @returns the current mesh
  31446. */
  31447. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31448. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31449. get useBones(): boolean;
  31450. /** @hidden */
  31451. _preActivate(): void;
  31452. /** @hidden */
  31453. _preActivateForIntermediateRendering(renderId: number): void;
  31454. /** @hidden */
  31455. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31456. /** @hidden */
  31457. _postActivate(): void;
  31458. /** @hidden */
  31459. _freeze(): void;
  31460. /** @hidden */
  31461. _unFreeze(): void;
  31462. /**
  31463. * Gets the current world matrix
  31464. * @returns a Matrix
  31465. */
  31466. getWorldMatrix(): Matrix;
  31467. /** @hidden */
  31468. _getWorldMatrixDeterminant(): number;
  31469. /**
  31470. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31471. */
  31472. get isAnInstance(): boolean;
  31473. /**
  31474. * Gets a boolean indicating if this mesh has instances
  31475. */
  31476. get hasInstances(): boolean;
  31477. /**
  31478. * Gets a boolean indicating if this mesh has thin instances
  31479. */
  31480. get hasThinInstances(): boolean;
  31481. /**
  31482. * Perform relative position change from the point of view of behind the front of the mesh.
  31483. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31484. * Supports definition of mesh facing forward or backward
  31485. * @param amountRight defines the distance on the right axis
  31486. * @param amountUp defines the distance on the up axis
  31487. * @param amountForward defines the distance on the forward axis
  31488. * @returns the current mesh
  31489. */
  31490. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31491. /**
  31492. * Calculate relative position change from the point of view of behind the front of the mesh.
  31493. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31494. * Supports definition of mesh facing forward or backward
  31495. * @param amountRight defines the distance on the right axis
  31496. * @param amountUp defines the distance on the up axis
  31497. * @param amountForward defines the distance on the forward axis
  31498. * @returns the new displacement vector
  31499. */
  31500. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31501. /**
  31502. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31503. * Supports definition of mesh facing forward or backward
  31504. * @param flipBack defines the flip
  31505. * @param twirlClockwise defines the twirl
  31506. * @param tiltRight defines the tilt
  31507. * @returns the current mesh
  31508. */
  31509. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31510. /**
  31511. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31512. * Supports definition of mesh facing forward or backward.
  31513. * @param flipBack defines the flip
  31514. * @param twirlClockwise defines the twirl
  31515. * @param tiltRight defines the tilt
  31516. * @returns the new rotation vector
  31517. */
  31518. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31519. /**
  31520. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31521. * This means the mesh underlying bounding box and sphere are recomputed.
  31522. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31523. * @returns the current mesh
  31524. */
  31525. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31526. /** @hidden */
  31527. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31528. /** @hidden */
  31529. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31530. /** @hidden */
  31531. _updateBoundingInfo(): AbstractMesh;
  31532. /** @hidden */
  31533. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31534. /** @hidden */
  31535. protected _afterComputeWorldMatrix(): void;
  31536. /** @hidden */
  31537. get _effectiveMesh(): AbstractMesh;
  31538. /**
  31539. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31540. * A mesh is in the frustum if its bounding box intersects the frustum
  31541. * @param frustumPlanes defines the frustum to test
  31542. * @returns true if the mesh is in the frustum planes
  31543. */
  31544. isInFrustum(frustumPlanes: Plane[]): boolean;
  31545. /**
  31546. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31547. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31548. * @param frustumPlanes defines the frustum to test
  31549. * @returns true if the mesh is completely in the frustum planes
  31550. */
  31551. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31552. /**
  31553. * True if the mesh intersects another mesh or a SolidParticle object
  31554. * @param mesh defines a target mesh or SolidParticle to test
  31555. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  31556. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31557. * @returns true if there is an intersection
  31558. */
  31559. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31560. /**
  31561. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31562. * @param point defines the point to test
  31563. * @returns true if there is an intersection
  31564. */
  31565. intersectsPoint(point: Vector3): boolean;
  31566. /**
  31567. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31568. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31569. */
  31570. get checkCollisions(): boolean;
  31571. set checkCollisions(collisionEnabled: boolean);
  31572. /**
  31573. * Gets Collider object used to compute collisions (not physics)
  31574. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31575. */
  31576. get collider(): Nullable<Collider>;
  31577. /**
  31578. * Move the mesh using collision engine
  31579. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31580. * @param displacement defines the requested displacement vector
  31581. * @returns the current mesh
  31582. */
  31583. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31584. private _onCollisionPositionChange;
  31585. /** @hidden */
  31586. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31587. /** @hidden */
  31588. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31589. /** @hidden */
  31590. _checkCollision(collider: Collider): AbstractMesh;
  31591. /** @hidden */
  31592. _generatePointsArray(): boolean;
  31593. /**
  31594. * Checks if the passed Ray intersects with the mesh
  31595. * @param ray defines the ray to use
  31596. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31597. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31598. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31599. * @returns the picking info
  31600. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31601. */
  31602. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31603. /**
  31604. * Clones the current mesh
  31605. * @param name defines the mesh name
  31606. * @param newParent defines the new mesh parent
  31607. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31608. * @returns the new mesh
  31609. */
  31610. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31611. /**
  31612. * Disposes all the submeshes of the current meshnp
  31613. * @returns the current mesh
  31614. */
  31615. releaseSubMeshes(): AbstractMesh;
  31616. /**
  31617. * Releases resources associated with this abstract mesh.
  31618. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31619. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31620. */
  31621. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31622. /**
  31623. * Adds the passed mesh as a child to the current mesh
  31624. * @param mesh defines the child mesh
  31625. * @returns the current mesh
  31626. */
  31627. addChild(mesh: AbstractMesh): AbstractMesh;
  31628. /**
  31629. * Removes the passed mesh from the current mesh children list
  31630. * @param mesh defines the child mesh
  31631. * @returns the current mesh
  31632. */
  31633. removeChild(mesh: AbstractMesh): AbstractMesh;
  31634. /** @hidden */
  31635. private _initFacetData;
  31636. /**
  31637. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31638. * This method can be called within the render loop.
  31639. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  31640. * @returns the current mesh
  31641. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31642. */
  31643. updateFacetData(): AbstractMesh;
  31644. /**
  31645. * Returns the facetLocalNormals array.
  31646. * The normals are expressed in the mesh local spac
  31647. * @returns an array of Vector3
  31648. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31649. */
  31650. getFacetLocalNormals(): Vector3[];
  31651. /**
  31652. * Returns the facetLocalPositions array.
  31653. * The facet positions are expressed in the mesh local space
  31654. * @returns an array of Vector3
  31655. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31656. */
  31657. getFacetLocalPositions(): Vector3[];
  31658. /**
  31659. * Returns the facetLocalPartioning array
  31660. * @returns an array of array of numbers
  31661. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31662. */
  31663. getFacetLocalPartitioning(): number[][];
  31664. /**
  31665. * Returns the i-th facet position in the world system.
  31666. * This method allocates a new Vector3 per call
  31667. * @param i defines the facet index
  31668. * @returns a new Vector3
  31669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31670. */
  31671. getFacetPosition(i: number): Vector3;
  31672. /**
  31673. * Sets the reference Vector3 with the i-th facet position in the world system
  31674. * @param i defines the facet index
  31675. * @param ref defines the target vector
  31676. * @returns the current mesh
  31677. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31678. */
  31679. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31680. /**
  31681. * Returns the i-th facet normal in the world system.
  31682. * This method allocates a new Vector3 per call
  31683. * @param i defines the facet index
  31684. * @returns a new Vector3
  31685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31686. */
  31687. getFacetNormal(i: number): Vector3;
  31688. /**
  31689. * Sets the reference Vector3 with the i-th facet normal in the world system
  31690. * @param i defines the facet index
  31691. * @param ref defines the target vector
  31692. * @returns the current mesh
  31693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31694. */
  31695. getFacetNormalToRef(i: number, ref: Vector3): this;
  31696. /**
  31697. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  31698. * @param x defines x coordinate
  31699. * @param y defines y coordinate
  31700. * @param z defines z coordinate
  31701. * @returns the array of facet indexes
  31702. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31703. */
  31704. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31705. /**
  31706. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31707. * @param projected sets as the (x,y,z) world projection on the facet
  31708. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  31709. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  31710. * @param x defines x coordinate
  31711. * @param y defines y coordinate
  31712. * @param z defines z coordinate
  31713. * @returns the face index if found (or null instead)
  31714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31715. */
  31716. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31717. /**
  31718. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31719. * @param projected sets as the (x,y,z) local projection on the facet
  31720. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  31721. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  31722. * @param x defines x coordinate
  31723. * @param y defines y coordinate
  31724. * @param z defines z coordinate
  31725. * @returns the face index if found (or null instead)
  31726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31727. */
  31728. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31729. /**
  31730. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31731. * @returns the parameters
  31732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31733. */
  31734. getFacetDataParameters(): any;
  31735. /**
  31736. * Disables the feature FacetData and frees the related memory
  31737. * @returns the current mesh
  31738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31739. */
  31740. disableFacetData(): AbstractMesh;
  31741. /**
  31742. * Updates the AbstractMesh indices array
  31743. * @param indices defines the data source
  31744. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31745. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  31746. * @returns the current mesh
  31747. */
  31748. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31749. /**
  31750. * Creates new normals data for the mesh
  31751. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31752. * @returns the current mesh
  31753. */
  31754. createNormals(updatable: boolean): AbstractMesh;
  31755. /**
  31756. * Align the mesh with a normal
  31757. * @param normal defines the normal to use
  31758. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31759. * @returns the current mesh
  31760. */
  31761. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31762. /** @hidden */
  31763. _checkOcclusionQuery(): boolean;
  31764. /**
  31765. * Disables the mesh edge rendering mode
  31766. * @returns the currentAbstractMesh
  31767. */
  31768. disableEdgesRendering(): AbstractMesh;
  31769. /**
  31770. * Enables the edge rendering mode on the mesh.
  31771. * This mode makes the mesh edges visible
  31772. * @param epsilon defines the maximal distance between two angles to detect a face
  31773. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31774. * @returns the currentAbstractMesh
  31775. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31776. */
  31777. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31778. }
  31779. }
  31780. declare module BABYLON {
  31781. /**
  31782. * Interface used to define ActionEvent
  31783. */
  31784. export interface IActionEvent {
  31785. /** The mesh or sprite that triggered the action */
  31786. source: any;
  31787. /** The X mouse cursor position at the time of the event */
  31788. pointerX: number;
  31789. /** The Y mouse cursor position at the time of the event */
  31790. pointerY: number;
  31791. /** The mesh that is currently pointed at (can be null) */
  31792. meshUnderPointer: Nullable<AbstractMesh>;
  31793. /** the original (browser) event that triggered the ActionEvent */
  31794. sourceEvent?: any;
  31795. /** additional data for the event */
  31796. additionalData?: any;
  31797. }
  31798. /**
  31799. * ActionEvent is the event being sent when an action is triggered.
  31800. */
  31801. export class ActionEvent implements IActionEvent {
  31802. /** The mesh or sprite that triggered the action */
  31803. source: any;
  31804. /** The X mouse cursor position at the time of the event */
  31805. pointerX: number;
  31806. /** The Y mouse cursor position at the time of the event */
  31807. pointerY: number;
  31808. /** The mesh that is currently pointed at (can be null) */
  31809. meshUnderPointer: Nullable<AbstractMesh>;
  31810. /** the original (browser) event that triggered the ActionEvent */
  31811. sourceEvent?: any;
  31812. /** additional data for the event */
  31813. additionalData?: any;
  31814. /**
  31815. * Creates a new ActionEvent
  31816. * @param source The mesh or sprite that triggered the action
  31817. * @param pointerX The X mouse cursor position at the time of the event
  31818. * @param pointerY The Y mouse cursor position at the time of the event
  31819. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31820. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31821. * @param additionalData additional data for the event
  31822. */
  31823. constructor(
  31824. /** The mesh or sprite that triggered the action */
  31825. source: any,
  31826. /** The X mouse cursor position at the time of the event */
  31827. pointerX: number,
  31828. /** The Y mouse cursor position at the time of the event */
  31829. pointerY: number,
  31830. /** The mesh that is currently pointed at (can be null) */
  31831. meshUnderPointer: Nullable<AbstractMesh>,
  31832. /** the original (browser) event that triggered the ActionEvent */
  31833. sourceEvent?: any,
  31834. /** additional data for the event */
  31835. additionalData?: any);
  31836. /**
  31837. * Helper function to auto-create an ActionEvent from a source mesh.
  31838. * @param source The source mesh that triggered the event
  31839. * @param evt The original (browser) event
  31840. * @param additionalData additional data for the event
  31841. * @returns the new ActionEvent
  31842. */
  31843. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31844. /**
  31845. * Helper function to auto-create an ActionEvent from a source sprite
  31846. * @param source The source sprite that triggered the event
  31847. * @param scene Scene associated with the sprite
  31848. * @param evt The original (browser) event
  31849. * @param additionalData additional data for the event
  31850. * @returns the new ActionEvent
  31851. */
  31852. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31853. /**
  31854. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31855. * @param scene the scene where the event occurred
  31856. * @param evt The original (browser) event
  31857. * @returns the new ActionEvent
  31858. */
  31859. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31860. /**
  31861. * Helper function to auto-create an ActionEvent from a primitive
  31862. * @param prim defines the target primitive
  31863. * @param pointerPos defines the pointer position
  31864. * @param evt The original (browser) event
  31865. * @param additionalData additional data for the event
  31866. * @returns the new ActionEvent
  31867. */
  31868. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31869. }
  31870. }
  31871. declare module BABYLON {
  31872. /**
  31873. * Abstract class used to decouple action Manager from scene and meshes.
  31874. * Do not instantiate.
  31875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31876. */
  31877. export abstract class AbstractActionManager implements IDisposable {
  31878. /** Gets the list of active triggers */
  31879. static Triggers: {
  31880. [key: string]: number;
  31881. };
  31882. /** Gets the cursor to use when hovering items */
  31883. hoverCursor: string;
  31884. /** Gets the list of actions */
  31885. actions: IAction[];
  31886. /**
  31887. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31888. */
  31889. isRecursive: boolean;
  31890. /**
  31891. * Releases all associated resources
  31892. */
  31893. abstract dispose(): void;
  31894. /**
  31895. * Does this action manager has pointer triggers
  31896. */
  31897. abstract get hasPointerTriggers(): boolean;
  31898. /**
  31899. * Does this action manager has pick triggers
  31900. */
  31901. abstract get hasPickTriggers(): boolean;
  31902. /**
  31903. * Process a specific trigger
  31904. * @param trigger defines the trigger to process
  31905. * @param evt defines the event details to be processed
  31906. */
  31907. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31908. /**
  31909. * Does this action manager handles actions of any of the given triggers
  31910. * @param triggers defines the triggers to be tested
  31911. * @return a boolean indicating whether one (or more) of the triggers is handled
  31912. */
  31913. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31914. /**
  31915. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31916. * speed.
  31917. * @param triggerA defines the trigger to be tested
  31918. * @param triggerB defines the trigger to be tested
  31919. * @return a boolean indicating whether one (or more) of the triggers is handled
  31920. */
  31921. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31922. /**
  31923. * Does this action manager handles actions of a given trigger
  31924. * @param trigger defines the trigger to be tested
  31925. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31926. * @return whether the trigger is handled
  31927. */
  31928. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31929. /**
  31930. * Serialize this manager to a JSON object
  31931. * @param name defines the property name to store this manager
  31932. * @returns a JSON representation of this manager
  31933. */
  31934. abstract serialize(name: string): any;
  31935. /**
  31936. * Registers an action to this action manager
  31937. * @param action defines the action to be registered
  31938. * @return the action amended (prepared) after registration
  31939. */
  31940. abstract registerAction(action: IAction): Nullable<IAction>;
  31941. /**
  31942. * Unregisters an action to this action manager
  31943. * @param action defines the action to be unregistered
  31944. * @return a boolean indicating whether the action has been unregistered
  31945. */
  31946. abstract unregisterAction(action: IAction): Boolean;
  31947. /**
  31948. * Does exist one action manager with at least one trigger
  31949. **/
  31950. static get HasTriggers(): boolean;
  31951. /**
  31952. * Does exist one action manager with at least one pick trigger
  31953. **/
  31954. static get HasPickTriggers(): boolean;
  31955. /**
  31956. * Does exist one action manager that handles actions of a given trigger
  31957. * @param trigger defines the trigger to be tested
  31958. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31959. **/
  31960. static HasSpecificTrigger(trigger: number): boolean;
  31961. }
  31962. }
  31963. declare module BABYLON {
  31964. /**
  31965. * Defines how a node can be built from a string name.
  31966. */
  31967. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31968. /**
  31969. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31970. */
  31971. export class Node implements IBehaviorAware<Node> {
  31972. /** @hidden */
  31973. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31974. private static _NodeConstructors;
  31975. /**
  31976. * Add a new node constructor
  31977. * @param type defines the type name of the node to construct
  31978. * @param constructorFunc defines the constructor function
  31979. */
  31980. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31981. /**
  31982. * Returns a node constructor based on type name
  31983. * @param type defines the type name
  31984. * @param name defines the new node name
  31985. * @param scene defines the hosting scene
  31986. * @param options defines optional options to transmit to constructors
  31987. * @returns the new constructor or null
  31988. */
  31989. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31990. /**
  31991. * Gets or sets the name of the node
  31992. */
  31993. name: string;
  31994. /**
  31995. * Gets or sets the id of the node
  31996. */
  31997. id: string;
  31998. /**
  31999. * Gets or sets the unique id of the node
  32000. */
  32001. uniqueId: number;
  32002. /**
  32003. * Gets or sets a string used to store user defined state for the node
  32004. */
  32005. state: string;
  32006. /**
  32007. * Gets or sets an object used to store user defined information for the node
  32008. */
  32009. metadata: any;
  32010. /**
  32011. * For internal use only. Please do not use.
  32012. */
  32013. reservedDataStore: any;
  32014. /**
  32015. * List of inspectable custom properties (used by the Inspector)
  32016. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32017. */
  32018. inspectableCustomProperties: IInspectable[];
  32019. private _doNotSerialize;
  32020. /**
  32021. * Gets or sets a boolean used to define if the node must be serialized
  32022. */
  32023. get doNotSerialize(): boolean;
  32024. set doNotSerialize(value: boolean);
  32025. /** @hidden */
  32026. _isDisposed: boolean;
  32027. /**
  32028. * Gets a list of Animations associated with the node
  32029. */
  32030. animations: Animation[];
  32031. protected _ranges: {
  32032. [name: string]: Nullable<AnimationRange>;
  32033. };
  32034. /**
  32035. * Callback raised when the node is ready to be used
  32036. */
  32037. onReady: Nullable<(node: Node) => void>;
  32038. private _isEnabled;
  32039. private _isParentEnabled;
  32040. private _isReady;
  32041. /** @hidden */
  32042. _currentRenderId: number;
  32043. private _parentUpdateId;
  32044. /** @hidden */
  32045. _childUpdateId: number;
  32046. /** @hidden */
  32047. _waitingParentId: Nullable<string>;
  32048. /** @hidden */
  32049. _scene: Scene;
  32050. /** @hidden */
  32051. _cache: any;
  32052. private _parentNode;
  32053. private _children;
  32054. /** @hidden */
  32055. _worldMatrix: Matrix;
  32056. /** @hidden */
  32057. _worldMatrixDeterminant: number;
  32058. /** @hidden */
  32059. _worldMatrixDeterminantIsDirty: boolean;
  32060. /** @hidden */
  32061. private _sceneRootNodesIndex;
  32062. /**
  32063. * Gets a boolean indicating if the node has been disposed
  32064. * @returns true if the node was disposed
  32065. */
  32066. isDisposed(): boolean;
  32067. /**
  32068. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32069. * @see https://doc.babylonjs.com/how_to/parenting
  32070. */
  32071. set parent(parent: Nullable<Node>);
  32072. get parent(): Nullable<Node>;
  32073. /** @hidden */
  32074. _addToSceneRootNodes(): void;
  32075. /** @hidden */
  32076. _removeFromSceneRootNodes(): void;
  32077. private _animationPropertiesOverride;
  32078. /**
  32079. * Gets or sets the animation properties override
  32080. */
  32081. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32082. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32083. /**
  32084. * Gets a string idenfifying the name of the class
  32085. * @returns "Node" string
  32086. */
  32087. getClassName(): string;
  32088. /** @hidden */
  32089. readonly _isNode: boolean;
  32090. /**
  32091. * An event triggered when the mesh is disposed
  32092. */
  32093. onDisposeObservable: Observable<Node>;
  32094. private _onDisposeObserver;
  32095. /**
  32096. * Sets a callback that will be raised when the node will be disposed
  32097. */
  32098. set onDispose(callback: () => void);
  32099. /**
  32100. * Creates a new Node
  32101. * @param name the name and id to be given to this node
  32102. * @param scene the scene this node will be added to
  32103. */
  32104. constructor(name: string, scene?: Nullable<Scene>);
  32105. /**
  32106. * Gets the scene of the node
  32107. * @returns a scene
  32108. */
  32109. getScene(): Scene;
  32110. /**
  32111. * Gets the engine of the node
  32112. * @returns a Engine
  32113. */
  32114. getEngine(): Engine;
  32115. private _behaviors;
  32116. /**
  32117. * Attach a behavior to the node
  32118. * @see http://doc.babylonjs.com/features/behaviour
  32119. * @param behavior defines the behavior to attach
  32120. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32121. * @returns the current Node
  32122. */
  32123. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32124. /**
  32125. * Remove an attached behavior
  32126. * @see http://doc.babylonjs.com/features/behaviour
  32127. * @param behavior defines the behavior to attach
  32128. * @returns the current Node
  32129. */
  32130. removeBehavior(behavior: Behavior<Node>): Node;
  32131. /**
  32132. * Gets the list of attached behaviors
  32133. * @see http://doc.babylonjs.com/features/behaviour
  32134. */
  32135. get behaviors(): Behavior<Node>[];
  32136. /**
  32137. * Gets an attached behavior by name
  32138. * @param name defines the name of the behavior to look for
  32139. * @see http://doc.babylonjs.com/features/behaviour
  32140. * @returns null if behavior was not found else the requested behavior
  32141. */
  32142. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32143. /**
  32144. * Returns the latest update of the World matrix
  32145. * @returns a Matrix
  32146. */
  32147. getWorldMatrix(): Matrix;
  32148. /** @hidden */
  32149. _getWorldMatrixDeterminant(): number;
  32150. /**
  32151. * Returns directly the latest state of the mesh World matrix.
  32152. * A Matrix is returned.
  32153. */
  32154. get worldMatrixFromCache(): Matrix;
  32155. /** @hidden */
  32156. _initCache(): void;
  32157. /** @hidden */
  32158. updateCache(force?: boolean): void;
  32159. /** @hidden */
  32160. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32161. /** @hidden */
  32162. _updateCache(ignoreParentClass?: boolean): void;
  32163. /** @hidden */
  32164. _isSynchronized(): boolean;
  32165. /** @hidden */
  32166. _markSyncedWithParent(): void;
  32167. /** @hidden */
  32168. isSynchronizedWithParent(): boolean;
  32169. /** @hidden */
  32170. isSynchronized(): boolean;
  32171. /**
  32172. * Is this node ready to be used/rendered
  32173. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32174. * @return true if the node is ready
  32175. */
  32176. isReady(completeCheck?: boolean): boolean;
  32177. /**
  32178. * Is this node enabled?
  32179. * 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
  32180. * @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
  32181. * @return whether this node (and its parent) is enabled
  32182. */
  32183. isEnabled(checkAncestors?: boolean): boolean;
  32184. /** @hidden */
  32185. protected _syncParentEnabledState(): void;
  32186. /**
  32187. * Set the enabled state of this node
  32188. * @param value defines the new enabled state
  32189. */
  32190. setEnabled(value: boolean): void;
  32191. /**
  32192. * Is this node a descendant of the given node?
  32193. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32194. * @param ancestor defines the parent node to inspect
  32195. * @returns a boolean indicating if this node is a descendant of the given node
  32196. */
  32197. isDescendantOf(ancestor: Node): boolean;
  32198. /** @hidden */
  32199. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32200. /**
  32201. * Will return all nodes that have this node as ascendant
  32202. * @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
  32203. * @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
  32204. * @return all children nodes of all types
  32205. */
  32206. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32207. /**
  32208. * Get all child-meshes of this node
  32209. * @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)
  32210. * @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
  32211. * @returns an array of AbstractMesh
  32212. */
  32213. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32214. /**
  32215. * Get all direct children of this node
  32216. * @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
  32217. * @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)
  32218. * @returns an array of Node
  32219. */
  32220. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32221. /** @hidden */
  32222. _setReady(state: boolean): void;
  32223. /**
  32224. * Get an animation by name
  32225. * @param name defines the name of the animation to look for
  32226. * @returns null if not found else the requested animation
  32227. */
  32228. getAnimationByName(name: string): Nullable<Animation>;
  32229. /**
  32230. * Creates an animation range for this node
  32231. * @param name defines the name of the range
  32232. * @param from defines the starting key
  32233. * @param to defines the end key
  32234. */
  32235. createAnimationRange(name: string, from: number, to: number): void;
  32236. /**
  32237. * Delete a specific animation range
  32238. * @param name defines the name of the range to delete
  32239. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32240. */
  32241. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32242. /**
  32243. * Get an animation range by name
  32244. * @param name defines the name of the animation range to look for
  32245. * @returns null if not found else the requested animation range
  32246. */
  32247. getAnimationRange(name: string): Nullable<AnimationRange>;
  32248. /**
  32249. * Gets the list of all animation ranges defined on this node
  32250. * @returns an array
  32251. */
  32252. getAnimationRanges(): Nullable<AnimationRange>[];
  32253. /**
  32254. * Will start the animation sequence
  32255. * @param name defines the range frames for animation sequence
  32256. * @param loop defines if the animation should loop (false by default)
  32257. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32258. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32259. * @returns the object created for this animation. If range does not exist, it will return null
  32260. */
  32261. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32262. /**
  32263. * Serialize animation ranges into a JSON compatible object
  32264. * @returns serialization object
  32265. */
  32266. serializeAnimationRanges(): any;
  32267. /**
  32268. * Computes the world matrix of the node
  32269. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32270. * @returns the world matrix
  32271. */
  32272. computeWorldMatrix(force?: boolean): Matrix;
  32273. /**
  32274. * Releases resources associated with this node.
  32275. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32276. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32277. */
  32278. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32279. /**
  32280. * Parse animation range data from a serialization object and store them into a given node
  32281. * @param node defines where to store the animation ranges
  32282. * @param parsedNode defines the serialization object to read data from
  32283. * @param scene defines the hosting scene
  32284. */
  32285. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32286. /**
  32287. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32288. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32289. * @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
  32290. * @returns the new bounding vectors
  32291. */
  32292. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32293. min: Vector3;
  32294. max: Vector3;
  32295. };
  32296. }
  32297. }
  32298. declare module BABYLON {
  32299. /**
  32300. * @hidden
  32301. */
  32302. export class _IAnimationState {
  32303. key: number;
  32304. repeatCount: number;
  32305. workValue?: any;
  32306. loopMode?: number;
  32307. offsetValue?: any;
  32308. highLimitValue?: any;
  32309. }
  32310. /**
  32311. * Class used to store any kind of animation
  32312. */
  32313. export class Animation {
  32314. /**Name of the animation */
  32315. name: string;
  32316. /**Property to animate */
  32317. targetProperty: string;
  32318. /**The frames per second of the animation */
  32319. framePerSecond: number;
  32320. /**The data type of the animation */
  32321. dataType: number;
  32322. /**The loop mode of the animation */
  32323. loopMode?: number | undefined;
  32324. /**Specifies if blending should be enabled */
  32325. enableBlending?: boolean | undefined;
  32326. /**
  32327. * Use matrix interpolation instead of using direct key value when animating matrices
  32328. */
  32329. static AllowMatricesInterpolation: boolean;
  32330. /**
  32331. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32332. */
  32333. static AllowMatrixDecomposeForInterpolation: boolean;
  32334. /** Define the Url to load snippets */
  32335. static SnippetUrl: string;
  32336. /** Snippet ID if the animation was created from the snippet server */
  32337. snippetId: string;
  32338. /**
  32339. * Stores the key frames of the animation
  32340. */
  32341. private _keys;
  32342. /**
  32343. * Stores the easing function of the animation
  32344. */
  32345. private _easingFunction;
  32346. /**
  32347. * @hidden Internal use only
  32348. */
  32349. _runtimeAnimations: RuntimeAnimation[];
  32350. /**
  32351. * The set of event that will be linked to this animation
  32352. */
  32353. private _events;
  32354. /**
  32355. * Stores an array of target property paths
  32356. */
  32357. targetPropertyPath: string[];
  32358. /**
  32359. * Stores the blending speed of the animation
  32360. */
  32361. blendingSpeed: number;
  32362. /**
  32363. * Stores the animation ranges for the animation
  32364. */
  32365. private _ranges;
  32366. /**
  32367. * @hidden Internal use
  32368. */
  32369. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32370. /**
  32371. * Sets up an animation
  32372. * @param property The property to animate
  32373. * @param animationType The animation type to apply
  32374. * @param framePerSecond The frames per second of the animation
  32375. * @param easingFunction The easing function used in the animation
  32376. * @returns The created animation
  32377. */
  32378. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32379. /**
  32380. * Create and start an animation on a node
  32381. * @param name defines the name of the global animation that will be run on all nodes
  32382. * @param node defines the root node where the animation will take place
  32383. * @param targetProperty defines property to animate
  32384. * @param framePerSecond defines the number of frame per second yo use
  32385. * @param totalFrame defines the number of frames in total
  32386. * @param from defines the initial value
  32387. * @param to defines the final value
  32388. * @param loopMode defines which loop mode you want to use (off by default)
  32389. * @param easingFunction defines the easing function to use (linear by default)
  32390. * @param onAnimationEnd defines the callback to call when animation end
  32391. * @returns the animatable created for this animation
  32392. */
  32393. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32394. /**
  32395. * Create and start an animation on a node and its descendants
  32396. * @param name defines the name of the global animation that will be run on all nodes
  32397. * @param node defines the root node where the animation will take place
  32398. * @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
  32399. * @param targetProperty defines property to animate
  32400. * @param framePerSecond defines the number of frame per second to use
  32401. * @param totalFrame defines the number of frames in total
  32402. * @param from defines the initial value
  32403. * @param to defines the final value
  32404. * @param loopMode defines which loop mode you want to use (off by default)
  32405. * @param easingFunction defines the easing function to use (linear by default)
  32406. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32407. * @returns the list of animatables created for all nodes
  32408. * @example https://www.babylonjs-playground.com/#MH0VLI
  32409. */
  32410. 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[]>;
  32411. /**
  32412. * Creates a new animation, merges it with the existing animations and starts it
  32413. * @param name Name of the animation
  32414. * @param node Node which contains the scene that begins the animations
  32415. * @param targetProperty Specifies which property to animate
  32416. * @param framePerSecond The frames per second of the animation
  32417. * @param totalFrame The total number of frames
  32418. * @param from The frame at the beginning of the animation
  32419. * @param to The frame at the end of the animation
  32420. * @param loopMode Specifies the loop mode of the animation
  32421. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32422. * @param onAnimationEnd Callback to run once the animation is complete
  32423. * @returns Nullable animation
  32424. */
  32425. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32426. /**
  32427. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32428. * @param sourceAnimation defines the Animation containing keyframes to convert
  32429. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32430. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32431. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32432. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32433. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32434. */
  32435. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32436. /**
  32437. * Transition property of an host to the target Value
  32438. * @param property The property to transition
  32439. * @param targetValue The target Value of the property
  32440. * @param host The object where the property to animate belongs
  32441. * @param scene Scene used to run the animation
  32442. * @param frameRate Framerate (in frame/s) to use
  32443. * @param transition The transition type we want to use
  32444. * @param duration The duration of the animation, in milliseconds
  32445. * @param onAnimationEnd Callback trigger at the end of the animation
  32446. * @returns Nullable animation
  32447. */
  32448. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32449. /**
  32450. * Return the array of runtime animations currently using this animation
  32451. */
  32452. get runtimeAnimations(): RuntimeAnimation[];
  32453. /**
  32454. * Specifies if any of the runtime animations are currently running
  32455. */
  32456. get hasRunningRuntimeAnimations(): boolean;
  32457. /**
  32458. * Initializes the animation
  32459. * @param name Name of the animation
  32460. * @param targetProperty Property to animate
  32461. * @param framePerSecond The frames per second of the animation
  32462. * @param dataType The data type of the animation
  32463. * @param loopMode The loop mode of the animation
  32464. * @param enableBlending Specifies if blending should be enabled
  32465. */
  32466. constructor(
  32467. /**Name of the animation */
  32468. name: string,
  32469. /**Property to animate */
  32470. targetProperty: string,
  32471. /**The frames per second of the animation */
  32472. framePerSecond: number,
  32473. /**The data type of the animation */
  32474. dataType: number,
  32475. /**The loop mode of the animation */
  32476. loopMode?: number | undefined,
  32477. /**Specifies if blending should be enabled */
  32478. enableBlending?: boolean | undefined);
  32479. /**
  32480. * Converts the animation to a string
  32481. * @param fullDetails support for multiple levels of logging within scene loading
  32482. * @returns String form of the animation
  32483. */
  32484. toString(fullDetails?: boolean): string;
  32485. /**
  32486. * Add an event to this animation
  32487. * @param event Event to add
  32488. */
  32489. addEvent(event: AnimationEvent): void;
  32490. /**
  32491. * Remove all events found at the given frame
  32492. * @param frame The frame to remove events from
  32493. */
  32494. removeEvents(frame: number): void;
  32495. /**
  32496. * Retrieves all the events from the animation
  32497. * @returns Events from the animation
  32498. */
  32499. getEvents(): AnimationEvent[];
  32500. /**
  32501. * Creates an animation range
  32502. * @param name Name of the animation range
  32503. * @param from Starting frame of the animation range
  32504. * @param to Ending frame of the animation
  32505. */
  32506. createRange(name: string, from: number, to: number): void;
  32507. /**
  32508. * Deletes an animation range by name
  32509. * @param name Name of the animation range to delete
  32510. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32511. */
  32512. deleteRange(name: string, deleteFrames?: boolean): void;
  32513. /**
  32514. * Gets the animation range by name, or null if not defined
  32515. * @param name Name of the animation range
  32516. * @returns Nullable animation range
  32517. */
  32518. getRange(name: string): Nullable<AnimationRange>;
  32519. /**
  32520. * Gets the key frames from the animation
  32521. * @returns The key frames of the animation
  32522. */
  32523. getKeys(): Array<IAnimationKey>;
  32524. /**
  32525. * Gets the highest frame rate of the animation
  32526. * @returns Highest frame rate of the animation
  32527. */
  32528. getHighestFrame(): number;
  32529. /**
  32530. * Gets the easing function of the animation
  32531. * @returns Easing function of the animation
  32532. */
  32533. getEasingFunction(): IEasingFunction;
  32534. /**
  32535. * Sets the easing function of the animation
  32536. * @param easingFunction A custom mathematical formula for animation
  32537. */
  32538. setEasingFunction(easingFunction: EasingFunction): void;
  32539. /**
  32540. * Interpolates a scalar linearly
  32541. * @param startValue Start value of the animation curve
  32542. * @param endValue End value of the animation curve
  32543. * @param gradient Scalar amount to interpolate
  32544. * @returns Interpolated scalar value
  32545. */
  32546. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32547. /**
  32548. * Interpolates a scalar cubically
  32549. * @param startValue Start value of the animation curve
  32550. * @param outTangent End tangent of the animation
  32551. * @param endValue End value of the animation curve
  32552. * @param inTangent Start tangent of the animation curve
  32553. * @param gradient Scalar amount to interpolate
  32554. * @returns Interpolated scalar value
  32555. */
  32556. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32557. /**
  32558. * Interpolates a quaternion using a spherical linear interpolation
  32559. * @param startValue Start value of the animation curve
  32560. * @param endValue End value of the animation curve
  32561. * @param gradient Scalar amount to interpolate
  32562. * @returns Interpolated quaternion value
  32563. */
  32564. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32565. /**
  32566. * Interpolates a quaternion cubically
  32567. * @param startValue Start value of the animation curve
  32568. * @param outTangent End tangent of the animation curve
  32569. * @param endValue End value of the animation curve
  32570. * @param inTangent Start tangent of the animation curve
  32571. * @param gradient Scalar amount to interpolate
  32572. * @returns Interpolated quaternion value
  32573. */
  32574. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32575. /**
  32576. * Interpolates a Vector3 linearl
  32577. * @param startValue Start value of the animation curve
  32578. * @param endValue End value of the animation curve
  32579. * @param gradient Scalar amount to interpolate
  32580. * @returns Interpolated scalar value
  32581. */
  32582. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32583. /**
  32584. * Interpolates a Vector3 cubically
  32585. * @param startValue Start value of the animation curve
  32586. * @param outTangent End tangent of the animation
  32587. * @param endValue End value of the animation curve
  32588. * @param inTangent Start tangent of the animation curve
  32589. * @param gradient Scalar amount to interpolate
  32590. * @returns InterpolatedVector3 value
  32591. */
  32592. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32593. /**
  32594. * Interpolates a Vector2 linearly
  32595. * @param startValue Start value of the animation curve
  32596. * @param endValue End value of the animation curve
  32597. * @param gradient Scalar amount to interpolate
  32598. * @returns Interpolated Vector2 value
  32599. */
  32600. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32601. /**
  32602. * Interpolates a Vector2 cubically
  32603. * @param startValue Start value of the animation curve
  32604. * @param outTangent End tangent of the animation
  32605. * @param endValue End value of the animation curve
  32606. * @param inTangent Start tangent of the animation curve
  32607. * @param gradient Scalar amount to interpolate
  32608. * @returns Interpolated Vector2 value
  32609. */
  32610. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32611. /**
  32612. * Interpolates a size linearly
  32613. * @param startValue Start value of the animation curve
  32614. * @param endValue End value of the animation curve
  32615. * @param gradient Scalar amount to interpolate
  32616. * @returns Interpolated Size value
  32617. */
  32618. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32619. /**
  32620. * Interpolates a Color3 linearly
  32621. * @param startValue Start value of the animation curve
  32622. * @param endValue End value of the animation curve
  32623. * @param gradient Scalar amount to interpolate
  32624. * @returns Interpolated Color3 value
  32625. */
  32626. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32627. /**
  32628. * Interpolates a Color4 linearly
  32629. * @param startValue Start value of the animation curve
  32630. * @param endValue End value of the animation curve
  32631. * @param gradient Scalar amount to interpolate
  32632. * @returns Interpolated Color3 value
  32633. */
  32634. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32635. /**
  32636. * @hidden Internal use only
  32637. */
  32638. _getKeyValue(value: any): any;
  32639. /**
  32640. * @hidden Internal use only
  32641. */
  32642. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32643. /**
  32644. * Defines the function to use to interpolate matrices
  32645. * @param startValue defines the start matrix
  32646. * @param endValue defines the end matrix
  32647. * @param gradient defines the gradient between both matrices
  32648. * @param result defines an optional target matrix where to store the interpolation
  32649. * @returns the interpolated matrix
  32650. */
  32651. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32652. /**
  32653. * Makes a copy of the animation
  32654. * @returns Cloned animation
  32655. */
  32656. clone(): Animation;
  32657. /**
  32658. * Sets the key frames of the animation
  32659. * @param values The animation key frames to set
  32660. */
  32661. setKeys(values: Array<IAnimationKey>): void;
  32662. /**
  32663. * Serializes the animation to an object
  32664. * @returns Serialized object
  32665. */
  32666. serialize(): any;
  32667. /**
  32668. * Float animation type
  32669. */
  32670. static readonly ANIMATIONTYPE_FLOAT: number;
  32671. /**
  32672. * Vector3 animation type
  32673. */
  32674. static readonly ANIMATIONTYPE_VECTOR3: number;
  32675. /**
  32676. * Quaternion animation type
  32677. */
  32678. static readonly ANIMATIONTYPE_QUATERNION: number;
  32679. /**
  32680. * Matrix animation type
  32681. */
  32682. static readonly ANIMATIONTYPE_MATRIX: number;
  32683. /**
  32684. * Color3 animation type
  32685. */
  32686. static readonly ANIMATIONTYPE_COLOR3: number;
  32687. /**
  32688. * Color3 animation type
  32689. */
  32690. static readonly ANIMATIONTYPE_COLOR4: number;
  32691. /**
  32692. * Vector2 animation type
  32693. */
  32694. static readonly ANIMATIONTYPE_VECTOR2: number;
  32695. /**
  32696. * Size animation type
  32697. */
  32698. static readonly ANIMATIONTYPE_SIZE: number;
  32699. /**
  32700. * Relative Loop Mode
  32701. */
  32702. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32703. /**
  32704. * Cycle Loop Mode
  32705. */
  32706. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32707. /**
  32708. * Constant Loop Mode
  32709. */
  32710. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32711. /** @hidden */
  32712. static _UniversalLerp(left: any, right: any, amount: number): any;
  32713. /**
  32714. * Parses an animation object and creates an animation
  32715. * @param parsedAnimation Parsed animation object
  32716. * @returns Animation object
  32717. */
  32718. static Parse(parsedAnimation: any): Animation;
  32719. /**
  32720. * Appends the serialized animations from the source animations
  32721. * @param source Source containing the animations
  32722. * @param destination Target to store the animations
  32723. */
  32724. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32725. /**
  32726. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32727. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32728. * @param url defines the url to load from
  32729. * @returns a promise that will resolve to the new animation or an array of animations
  32730. */
  32731. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32732. /**
  32733. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32734. * @param snippetId defines the snippet to load
  32735. * @returns a promise that will resolve to the new animation or a new array of animations
  32736. */
  32737. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32738. }
  32739. }
  32740. declare module BABYLON {
  32741. /**
  32742. * Interface containing an array of animations
  32743. */
  32744. export interface IAnimatable {
  32745. /**
  32746. * Array of animations
  32747. */
  32748. animations: Nullable<Array<Animation>>;
  32749. }
  32750. }
  32751. declare module BABYLON {
  32752. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32753. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32754. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32755. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32756. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32757. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32758. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32759. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32760. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32761. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32762. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32763. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32764. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32765. /**
  32766. * Decorator used to define property that can be serialized as reference to a camera
  32767. * @param sourceName defines the name of the property to decorate
  32768. */
  32769. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32770. /**
  32771. * Class used to help serialization objects
  32772. */
  32773. export class SerializationHelper {
  32774. /** @hidden */
  32775. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32776. /** @hidden */
  32777. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32778. /** @hidden */
  32779. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32780. /** @hidden */
  32781. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32782. /**
  32783. * Appends the serialized animations from the source animations
  32784. * @param source Source containing the animations
  32785. * @param destination Target to store the animations
  32786. */
  32787. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32788. /**
  32789. * Static function used to serialized a specific entity
  32790. * @param entity defines the entity to serialize
  32791. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32792. * @returns a JSON compatible object representing the serialization of the entity
  32793. */
  32794. static Serialize<T>(entity: T, serializationObject?: any): any;
  32795. /**
  32796. * Creates a new entity from a serialization data object
  32797. * @param creationFunction defines a function used to instanciated the new entity
  32798. * @param source defines the source serialization data
  32799. * @param scene defines the hosting scene
  32800. * @param rootUrl defines the root url for resources
  32801. * @returns a new entity
  32802. */
  32803. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32804. /**
  32805. * Clones an object
  32806. * @param creationFunction defines the function used to instanciate the new object
  32807. * @param source defines the source object
  32808. * @returns the cloned object
  32809. */
  32810. static Clone<T>(creationFunction: () => T, source: T): T;
  32811. /**
  32812. * Instanciates a new object based on a source one (some data will be shared between both object)
  32813. * @param creationFunction defines the function used to instanciate the new object
  32814. * @param source defines the source object
  32815. * @returns the new object
  32816. */
  32817. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32818. }
  32819. }
  32820. declare module BABYLON {
  32821. /**
  32822. * Base class of all the textures in babylon.
  32823. * It groups all the common properties the materials, post process, lights... might need
  32824. * in order to make a correct use of the texture.
  32825. */
  32826. export class BaseTexture implements IAnimatable {
  32827. /**
  32828. * Default anisotropic filtering level for the application.
  32829. * It is set to 4 as a good tradeoff between perf and quality.
  32830. */
  32831. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32832. /**
  32833. * Gets or sets the unique id of the texture
  32834. */
  32835. uniqueId: number;
  32836. /**
  32837. * Define the name of the texture.
  32838. */
  32839. name: string;
  32840. /**
  32841. * Gets or sets an object used to store user defined information.
  32842. */
  32843. metadata: any;
  32844. /**
  32845. * For internal use only. Please do not use.
  32846. */
  32847. reservedDataStore: any;
  32848. private _hasAlpha;
  32849. /**
  32850. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32851. */
  32852. set hasAlpha(value: boolean);
  32853. get hasAlpha(): boolean;
  32854. /**
  32855. * Defines if the alpha value should be determined via the rgb values.
  32856. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32857. */
  32858. getAlphaFromRGB: boolean;
  32859. /**
  32860. * Intensity or strength of the texture.
  32861. * It is commonly used by materials to fine tune the intensity of the texture
  32862. */
  32863. level: number;
  32864. /**
  32865. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32866. * This is part of the texture as textures usually maps to one uv set.
  32867. */
  32868. coordinatesIndex: number;
  32869. private _coordinatesMode;
  32870. /**
  32871. * How a texture is mapped.
  32872. *
  32873. * | Value | Type | Description |
  32874. * | ----- | ----------------------------------- | ----------- |
  32875. * | 0 | EXPLICIT_MODE | |
  32876. * | 1 | SPHERICAL_MODE | |
  32877. * | 2 | PLANAR_MODE | |
  32878. * | 3 | CUBIC_MODE | |
  32879. * | 4 | PROJECTION_MODE | |
  32880. * | 5 | SKYBOX_MODE | |
  32881. * | 6 | INVCUBIC_MODE | |
  32882. * | 7 | EQUIRECTANGULAR_MODE | |
  32883. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32884. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32885. */
  32886. set coordinatesMode(value: number);
  32887. get coordinatesMode(): number;
  32888. /**
  32889. * | Value | Type | Description |
  32890. * | ----- | ------------------ | ----------- |
  32891. * | 0 | CLAMP_ADDRESSMODE | |
  32892. * | 1 | WRAP_ADDRESSMODE | |
  32893. * | 2 | MIRROR_ADDRESSMODE | |
  32894. */
  32895. wrapU: number;
  32896. /**
  32897. * | Value | Type | Description |
  32898. * | ----- | ------------------ | ----------- |
  32899. * | 0 | CLAMP_ADDRESSMODE | |
  32900. * | 1 | WRAP_ADDRESSMODE | |
  32901. * | 2 | MIRROR_ADDRESSMODE | |
  32902. */
  32903. wrapV: number;
  32904. /**
  32905. * | Value | Type | Description |
  32906. * | ----- | ------------------ | ----------- |
  32907. * | 0 | CLAMP_ADDRESSMODE | |
  32908. * | 1 | WRAP_ADDRESSMODE | |
  32909. * | 2 | MIRROR_ADDRESSMODE | |
  32910. */
  32911. wrapR: number;
  32912. /**
  32913. * With compliant hardware and browser (supporting anisotropic filtering)
  32914. * this defines the level of anisotropic filtering in the texture.
  32915. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32916. */
  32917. anisotropicFilteringLevel: number;
  32918. /**
  32919. * Define if the texture is a cube texture or if false a 2d texture.
  32920. */
  32921. get isCube(): boolean;
  32922. set isCube(value: boolean);
  32923. /**
  32924. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32925. */
  32926. get is3D(): boolean;
  32927. set is3D(value: boolean);
  32928. /**
  32929. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32930. */
  32931. get is2DArray(): boolean;
  32932. set is2DArray(value: boolean);
  32933. /**
  32934. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32935. * HDR texture are usually stored in linear space.
  32936. * This only impacts the PBR and Background materials
  32937. */
  32938. gammaSpace: boolean;
  32939. /**
  32940. * Gets or sets whether or not the texture contains RGBD data.
  32941. */
  32942. get isRGBD(): boolean;
  32943. set isRGBD(value: boolean);
  32944. /**
  32945. * Is Z inverted in the texture (useful in a cube texture).
  32946. */
  32947. invertZ: boolean;
  32948. /**
  32949. * Are mip maps generated for this texture or not.
  32950. */
  32951. get noMipmap(): boolean;
  32952. /**
  32953. * @hidden
  32954. */
  32955. lodLevelInAlpha: boolean;
  32956. /**
  32957. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32958. */
  32959. get lodGenerationOffset(): number;
  32960. set lodGenerationOffset(value: number);
  32961. /**
  32962. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32963. */
  32964. get lodGenerationScale(): number;
  32965. set lodGenerationScale(value: number);
  32966. /**
  32967. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32968. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32969. * average roughness values.
  32970. */
  32971. get linearSpecularLOD(): boolean;
  32972. set linearSpecularLOD(value: boolean);
  32973. /**
  32974. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32975. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32976. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32977. */
  32978. get irradianceTexture(): Nullable<BaseTexture>;
  32979. set irradianceTexture(value: Nullable<BaseTexture>);
  32980. /**
  32981. * Define if the texture is a render target.
  32982. */
  32983. isRenderTarget: boolean;
  32984. /**
  32985. * Define the unique id of the texture in the scene.
  32986. */
  32987. get uid(): string;
  32988. /** @hidden */
  32989. _prefiltered: boolean;
  32990. /**
  32991. * Return a string representation of the texture.
  32992. * @returns the texture as a string
  32993. */
  32994. toString(): string;
  32995. /**
  32996. * Get the class name of the texture.
  32997. * @returns "BaseTexture"
  32998. */
  32999. getClassName(): string;
  33000. /**
  33001. * Define the list of animation attached to the texture.
  33002. */
  33003. animations: Animation[];
  33004. /**
  33005. * An event triggered when the texture is disposed.
  33006. */
  33007. onDisposeObservable: Observable<BaseTexture>;
  33008. private _onDisposeObserver;
  33009. /**
  33010. * Callback triggered when the texture has been disposed.
  33011. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33012. */
  33013. set onDispose(callback: () => void);
  33014. /**
  33015. * Define the current state of the loading sequence when in delayed load mode.
  33016. */
  33017. delayLoadState: number;
  33018. private _scene;
  33019. private _engine;
  33020. /** @hidden */
  33021. _texture: Nullable<InternalTexture>;
  33022. private _uid;
  33023. /**
  33024. * Define if the texture is preventinga material to render or not.
  33025. * If not and the texture is not ready, the engine will use a default black texture instead.
  33026. */
  33027. get isBlocking(): boolean;
  33028. /**
  33029. * Instantiates a new BaseTexture.
  33030. * Base class of all the textures in babylon.
  33031. * It groups all the common properties the materials, post process, lights... might need
  33032. * in order to make a correct use of the texture.
  33033. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33034. */
  33035. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33036. /**
  33037. * Get the scene the texture belongs to.
  33038. * @returns the scene or null if undefined
  33039. */
  33040. getScene(): Nullable<Scene>;
  33041. /** @hidden */
  33042. protected _getEngine(): Nullable<ThinEngine>;
  33043. /**
  33044. * Get the texture transform matrix used to offset tile the texture for istance.
  33045. * @returns the transformation matrix
  33046. */
  33047. getTextureMatrix(): Matrix;
  33048. /**
  33049. * Get the texture reflection matrix used to rotate/transform the reflection.
  33050. * @returns the reflection matrix
  33051. */
  33052. getReflectionTextureMatrix(): Matrix;
  33053. /**
  33054. * Get the underlying lower level texture from Babylon.
  33055. * @returns the insternal texture
  33056. */
  33057. getInternalTexture(): Nullable<InternalTexture>;
  33058. /**
  33059. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33060. * @returns true if ready or not blocking
  33061. */
  33062. isReadyOrNotBlocking(): boolean;
  33063. /**
  33064. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33065. * @returns true if fully ready
  33066. */
  33067. isReady(): boolean;
  33068. private _cachedSize;
  33069. /**
  33070. * Get the size of the texture.
  33071. * @returns the texture size.
  33072. */
  33073. getSize(): ISize;
  33074. /**
  33075. * Get the base size of the texture.
  33076. * It can be different from the size if the texture has been resized for POT for instance
  33077. * @returns the base size
  33078. */
  33079. getBaseSize(): ISize;
  33080. /**
  33081. * Update the sampling mode of the texture.
  33082. * Default is Trilinear mode.
  33083. *
  33084. * | Value | Type | Description |
  33085. * | ----- | ------------------ | ----------- |
  33086. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33087. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33088. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33089. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33090. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33091. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33092. * | 7 | NEAREST_LINEAR | |
  33093. * | 8 | NEAREST_NEAREST | |
  33094. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33095. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33096. * | 11 | LINEAR_LINEAR | |
  33097. * | 12 | LINEAR_NEAREST | |
  33098. *
  33099. * > _mag_: magnification filter (close to the viewer)
  33100. * > _min_: minification filter (far from the viewer)
  33101. * > _mip_: filter used between mip map levels
  33102. *@param samplingMode Define the new sampling mode of the texture
  33103. */
  33104. updateSamplingMode(samplingMode: number): void;
  33105. /**
  33106. * Scales the texture if is `canRescale()`
  33107. * @param ratio the resize factor we want to use to rescale
  33108. */
  33109. scale(ratio: number): void;
  33110. /**
  33111. * Get if the texture can rescale.
  33112. */
  33113. get canRescale(): boolean;
  33114. /** @hidden */
  33115. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33116. /** @hidden */
  33117. _rebuild(): void;
  33118. /**
  33119. * Triggers the load sequence in delayed load mode.
  33120. */
  33121. delayLoad(): void;
  33122. /**
  33123. * Clones the texture.
  33124. * @returns the cloned texture
  33125. */
  33126. clone(): Nullable<BaseTexture>;
  33127. /**
  33128. * Get the texture underlying type (INT, FLOAT...)
  33129. */
  33130. get textureType(): number;
  33131. /**
  33132. * Get the texture underlying format (RGB, RGBA...)
  33133. */
  33134. get textureFormat(): number;
  33135. /**
  33136. * Indicates that textures need to be re-calculated for all materials
  33137. */
  33138. protected _markAllSubMeshesAsTexturesDirty(): void;
  33139. /**
  33140. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33141. * This will returns an RGBA array buffer containing either in values (0-255) or
  33142. * float values (0-1) depending of the underlying buffer type.
  33143. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33144. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33145. * @param buffer defines a user defined buffer to fill with data (can be null)
  33146. * @returns The Array buffer containing the pixels data.
  33147. */
  33148. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33149. /**
  33150. * Release and destroy the underlying lower level texture aka internalTexture.
  33151. */
  33152. releaseInternalTexture(): void;
  33153. /** @hidden */
  33154. get _lodTextureHigh(): Nullable<BaseTexture>;
  33155. /** @hidden */
  33156. get _lodTextureMid(): Nullable<BaseTexture>;
  33157. /** @hidden */
  33158. get _lodTextureLow(): Nullable<BaseTexture>;
  33159. /**
  33160. * Dispose the texture and release its associated resources.
  33161. */
  33162. dispose(): void;
  33163. /**
  33164. * Serialize the texture into a JSON representation that can be parsed later on.
  33165. * @returns the JSON representation of the texture
  33166. */
  33167. serialize(): any;
  33168. /**
  33169. * Helper function to be called back once a list of texture contains only ready textures.
  33170. * @param textures Define the list of textures to wait for
  33171. * @param callback Define the callback triggered once the entire list will be ready
  33172. */
  33173. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33174. private static _isScene;
  33175. }
  33176. }
  33177. declare module BABYLON {
  33178. /**
  33179. * Options to be used when creating an effect.
  33180. */
  33181. export interface IEffectCreationOptions {
  33182. /**
  33183. * Atrributes that will be used in the shader.
  33184. */
  33185. attributes: string[];
  33186. /**
  33187. * Uniform varible names that will be set in the shader.
  33188. */
  33189. uniformsNames: string[];
  33190. /**
  33191. * Uniform buffer variable names that will be set in the shader.
  33192. */
  33193. uniformBuffersNames: string[];
  33194. /**
  33195. * Sampler texture variable names that will be set in the shader.
  33196. */
  33197. samplers: string[];
  33198. /**
  33199. * Define statements that will be set in the shader.
  33200. */
  33201. defines: any;
  33202. /**
  33203. * Possible fallbacks for this effect to improve performance when needed.
  33204. */
  33205. fallbacks: Nullable<IEffectFallbacks>;
  33206. /**
  33207. * Callback that will be called when the shader is compiled.
  33208. */
  33209. onCompiled: Nullable<(effect: Effect) => void>;
  33210. /**
  33211. * Callback that will be called if an error occurs during shader compilation.
  33212. */
  33213. onError: Nullable<(effect: Effect, errors: string) => void>;
  33214. /**
  33215. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33216. */
  33217. indexParameters?: any;
  33218. /**
  33219. * Max number of lights that can be used in the shader.
  33220. */
  33221. maxSimultaneousLights?: number;
  33222. /**
  33223. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33224. */
  33225. transformFeedbackVaryings?: Nullable<string[]>;
  33226. /**
  33227. * 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
  33228. */
  33229. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33230. }
  33231. /**
  33232. * Effect containing vertex and fragment shader that can be executed on an object.
  33233. */
  33234. export class Effect implements IDisposable {
  33235. /**
  33236. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33237. */
  33238. static ShadersRepository: string;
  33239. /**
  33240. * Enable logging of the shader code when a compilation error occurs
  33241. */
  33242. static LogShaderCodeOnCompilationError: boolean;
  33243. /**
  33244. * Name of the effect.
  33245. */
  33246. name: any;
  33247. /**
  33248. * String container all the define statements that should be set on the shader.
  33249. */
  33250. defines: string;
  33251. /**
  33252. * Callback that will be called when the shader is compiled.
  33253. */
  33254. onCompiled: Nullable<(effect: Effect) => void>;
  33255. /**
  33256. * Callback that will be called if an error occurs during shader compilation.
  33257. */
  33258. onError: Nullable<(effect: Effect, errors: string) => void>;
  33259. /**
  33260. * Callback that will be called when effect is bound.
  33261. */
  33262. onBind: Nullable<(effect: Effect) => void>;
  33263. /**
  33264. * Unique ID of the effect.
  33265. */
  33266. uniqueId: number;
  33267. /**
  33268. * Observable that will be called when the shader is compiled.
  33269. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33270. */
  33271. onCompileObservable: Observable<Effect>;
  33272. /**
  33273. * Observable that will be called if an error occurs during shader compilation.
  33274. */
  33275. onErrorObservable: Observable<Effect>;
  33276. /** @hidden */
  33277. _onBindObservable: Nullable<Observable<Effect>>;
  33278. /**
  33279. * @hidden
  33280. * Specifies if the effect was previously ready
  33281. */
  33282. _wasPreviouslyReady: boolean;
  33283. /**
  33284. * Observable that will be called when effect is bound.
  33285. */
  33286. get onBindObservable(): Observable<Effect>;
  33287. /** @hidden */
  33288. _bonesComputationForcedToCPU: boolean;
  33289. private static _uniqueIdSeed;
  33290. private _engine;
  33291. private _uniformBuffersNames;
  33292. private _uniformBuffersNamesList;
  33293. private _uniformsNames;
  33294. private _samplerList;
  33295. private _samplers;
  33296. private _isReady;
  33297. private _compilationError;
  33298. private _allFallbacksProcessed;
  33299. private _attributesNames;
  33300. private _attributes;
  33301. private _attributeLocationByName;
  33302. private _uniforms;
  33303. /**
  33304. * Key for the effect.
  33305. * @hidden
  33306. */
  33307. _key: string;
  33308. private _indexParameters;
  33309. private _fallbacks;
  33310. private _vertexSourceCode;
  33311. private _fragmentSourceCode;
  33312. private _vertexSourceCodeOverride;
  33313. private _fragmentSourceCodeOverride;
  33314. private _transformFeedbackVaryings;
  33315. /**
  33316. * Compiled shader to webGL program.
  33317. * @hidden
  33318. */
  33319. _pipelineContext: Nullable<IPipelineContext>;
  33320. private _valueCache;
  33321. private static _baseCache;
  33322. /**
  33323. * Instantiates an effect.
  33324. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33325. * @param baseName Name of the effect.
  33326. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33327. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33328. * @param samplers List of sampler variables that will be passed to the shader.
  33329. * @param engine Engine to be used to render the effect
  33330. * @param defines Define statements to be added to the shader.
  33331. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33332. * @param onCompiled Callback that will be called when the shader is compiled.
  33333. * @param onError Callback that will be called if an error occurs during shader compilation.
  33334. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33335. */
  33336. 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);
  33337. private _useFinalCode;
  33338. /**
  33339. * Unique key for this effect
  33340. */
  33341. get key(): string;
  33342. /**
  33343. * If the effect has been compiled and prepared.
  33344. * @returns if the effect is compiled and prepared.
  33345. */
  33346. isReady(): boolean;
  33347. private _isReadyInternal;
  33348. /**
  33349. * The engine the effect was initialized with.
  33350. * @returns the engine.
  33351. */
  33352. getEngine(): Engine;
  33353. /**
  33354. * The pipeline context for this effect
  33355. * @returns the associated pipeline context
  33356. */
  33357. getPipelineContext(): Nullable<IPipelineContext>;
  33358. /**
  33359. * The set of names of attribute variables for the shader.
  33360. * @returns An array of attribute names.
  33361. */
  33362. getAttributesNames(): string[];
  33363. /**
  33364. * Returns the attribute at the given index.
  33365. * @param index The index of the attribute.
  33366. * @returns The location of the attribute.
  33367. */
  33368. getAttributeLocation(index: number): number;
  33369. /**
  33370. * Returns the attribute based on the name of the variable.
  33371. * @param name of the attribute to look up.
  33372. * @returns the attribute location.
  33373. */
  33374. getAttributeLocationByName(name: string): number;
  33375. /**
  33376. * The number of attributes.
  33377. * @returns the numnber of attributes.
  33378. */
  33379. getAttributesCount(): number;
  33380. /**
  33381. * Gets the index of a uniform variable.
  33382. * @param uniformName of the uniform to look up.
  33383. * @returns the index.
  33384. */
  33385. getUniformIndex(uniformName: string): number;
  33386. /**
  33387. * Returns the attribute based on the name of the variable.
  33388. * @param uniformName of the uniform to look up.
  33389. * @returns the location of the uniform.
  33390. */
  33391. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33392. /**
  33393. * Returns an array of sampler variable names
  33394. * @returns The array of sampler variable names.
  33395. */
  33396. getSamplers(): string[];
  33397. /**
  33398. * Returns an array of uniform variable names
  33399. * @returns The array of uniform variable names.
  33400. */
  33401. getUniformNames(): string[];
  33402. /**
  33403. * Returns an array of uniform buffer variable names
  33404. * @returns The array of uniform buffer variable names.
  33405. */
  33406. getUniformBuffersNames(): string[];
  33407. /**
  33408. * Returns the index parameters used to create the effect
  33409. * @returns The index parameters object
  33410. */
  33411. getIndexParameters(): any;
  33412. /**
  33413. * The error from the last compilation.
  33414. * @returns the error string.
  33415. */
  33416. getCompilationError(): string;
  33417. /**
  33418. * Gets a boolean indicating that all fallbacks were used during compilation
  33419. * @returns true if all fallbacks were used
  33420. */
  33421. allFallbacksProcessed(): boolean;
  33422. /**
  33423. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33424. * @param func The callback to be used.
  33425. */
  33426. executeWhenCompiled(func: (effect: Effect) => void): void;
  33427. private _checkIsReady;
  33428. private _loadShader;
  33429. /**
  33430. * Gets the vertex shader source code of this effect
  33431. */
  33432. get vertexSourceCode(): string;
  33433. /**
  33434. * Gets the fragment shader source code of this effect
  33435. */
  33436. get fragmentSourceCode(): string;
  33437. /**
  33438. * Recompiles the webGL program
  33439. * @param vertexSourceCode The source code for the vertex shader.
  33440. * @param fragmentSourceCode The source code for the fragment shader.
  33441. * @param onCompiled Callback called when completed.
  33442. * @param onError Callback called on error.
  33443. * @hidden
  33444. */
  33445. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33446. /**
  33447. * Prepares the effect
  33448. * @hidden
  33449. */
  33450. _prepareEffect(): void;
  33451. private _getShaderCodeAndErrorLine;
  33452. private _processCompilationErrors;
  33453. /**
  33454. * Checks if the effect is supported. (Must be called after compilation)
  33455. */
  33456. get isSupported(): boolean;
  33457. /**
  33458. * Binds a texture to the engine to be used as output of the shader.
  33459. * @param channel Name of the output variable.
  33460. * @param texture Texture to bind.
  33461. * @hidden
  33462. */
  33463. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33464. /**
  33465. * Sets a texture on the engine to be used in the shader.
  33466. * @param channel Name of the sampler variable.
  33467. * @param texture Texture to set.
  33468. */
  33469. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33470. /**
  33471. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33472. * @param channel Name of the sampler variable.
  33473. * @param texture Texture to set.
  33474. */
  33475. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33476. /**
  33477. * Sets an array of textures on the engine to be used in the shader.
  33478. * @param channel Name of the variable.
  33479. * @param textures Textures to set.
  33480. */
  33481. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33482. /**
  33483. * 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)
  33484. * @param channel Name of the sampler variable.
  33485. * @param postProcess Post process to get the input texture from.
  33486. */
  33487. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33488. /**
  33489. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33490. * 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)
  33491. * @param channel Name of the sampler variable.
  33492. * @param postProcess Post process to get the output texture from.
  33493. */
  33494. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33495. /** @hidden */
  33496. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33497. /** @hidden */
  33498. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33499. /** @hidden */
  33500. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33501. /** @hidden */
  33502. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33503. /**
  33504. * Binds a buffer to a uniform.
  33505. * @param buffer Buffer to bind.
  33506. * @param name Name of the uniform variable to bind to.
  33507. */
  33508. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33509. /**
  33510. * Binds block to a uniform.
  33511. * @param blockName Name of the block to bind.
  33512. * @param index Index to bind.
  33513. */
  33514. bindUniformBlock(blockName: string, index: number): void;
  33515. /**
  33516. * Sets an interger value on a uniform variable.
  33517. * @param uniformName Name of the variable.
  33518. * @param value Value to be set.
  33519. * @returns this effect.
  33520. */
  33521. setInt(uniformName: string, value: number): Effect;
  33522. /**
  33523. * Sets an int array on a uniform variable.
  33524. * @param uniformName Name of the variable.
  33525. * @param array array to be set.
  33526. * @returns this effect.
  33527. */
  33528. setIntArray(uniformName: string, array: Int32Array): Effect;
  33529. /**
  33530. * 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)
  33531. * @param uniformName Name of the variable.
  33532. * @param array array to be set.
  33533. * @returns this effect.
  33534. */
  33535. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33536. /**
  33537. * 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)
  33538. * @param uniformName Name of the variable.
  33539. * @param array array to be set.
  33540. * @returns this effect.
  33541. */
  33542. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33543. /**
  33544. * 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)
  33545. * @param uniformName Name of the variable.
  33546. * @param array array to be set.
  33547. * @returns this effect.
  33548. */
  33549. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33550. /**
  33551. * Sets an float array on a uniform variable.
  33552. * @param uniformName Name of the variable.
  33553. * @param array array to be set.
  33554. * @returns this effect.
  33555. */
  33556. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33557. /**
  33558. * 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)
  33559. * @param uniformName Name of the variable.
  33560. * @param array array to be set.
  33561. * @returns this effect.
  33562. */
  33563. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33564. /**
  33565. * 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)
  33566. * @param uniformName Name of the variable.
  33567. * @param array array to be set.
  33568. * @returns this effect.
  33569. */
  33570. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33571. /**
  33572. * 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)
  33573. * @param uniformName Name of the variable.
  33574. * @param array array to be set.
  33575. * @returns this effect.
  33576. */
  33577. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33578. /**
  33579. * Sets an array on a uniform variable.
  33580. * @param uniformName Name of the variable.
  33581. * @param array array to be set.
  33582. * @returns this effect.
  33583. */
  33584. setArray(uniformName: string, array: number[]): Effect;
  33585. /**
  33586. * 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)
  33587. * @param uniformName Name of the variable.
  33588. * @param array array to be set.
  33589. * @returns this effect.
  33590. */
  33591. setArray2(uniformName: string, array: number[]): Effect;
  33592. /**
  33593. * 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)
  33594. * @param uniformName Name of the variable.
  33595. * @param array array to be set.
  33596. * @returns this effect.
  33597. */
  33598. setArray3(uniformName: string, array: number[]): Effect;
  33599. /**
  33600. * 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)
  33601. * @param uniformName Name of the variable.
  33602. * @param array array to be set.
  33603. * @returns this effect.
  33604. */
  33605. setArray4(uniformName: string, array: number[]): Effect;
  33606. /**
  33607. * Sets matrices on a uniform variable.
  33608. * @param uniformName Name of the variable.
  33609. * @param matrices matrices to be set.
  33610. * @returns this effect.
  33611. */
  33612. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33613. /**
  33614. * Sets matrix on a uniform variable.
  33615. * @param uniformName Name of the variable.
  33616. * @param matrix matrix to be set.
  33617. * @returns this effect.
  33618. */
  33619. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33620. /**
  33621. * 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)
  33622. * @param uniformName Name of the variable.
  33623. * @param matrix matrix to be set.
  33624. * @returns this effect.
  33625. */
  33626. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33627. /**
  33628. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33629. * @param uniformName Name of the variable.
  33630. * @param matrix matrix to be set.
  33631. * @returns this effect.
  33632. */
  33633. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33634. /**
  33635. * Sets a float on a uniform variable.
  33636. * @param uniformName Name of the variable.
  33637. * @param value value to be set.
  33638. * @returns this effect.
  33639. */
  33640. setFloat(uniformName: string, value: number): Effect;
  33641. /**
  33642. * Sets a boolean on a uniform variable.
  33643. * @param uniformName Name of the variable.
  33644. * @param bool value to be set.
  33645. * @returns this effect.
  33646. */
  33647. setBool(uniformName: string, bool: boolean): Effect;
  33648. /**
  33649. * Sets a Vector2 on a uniform variable.
  33650. * @param uniformName Name of the variable.
  33651. * @param vector2 vector2 to be set.
  33652. * @returns this effect.
  33653. */
  33654. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33655. /**
  33656. * Sets a float2 on a uniform variable.
  33657. * @param uniformName Name of the variable.
  33658. * @param x First float in float2.
  33659. * @param y Second float in float2.
  33660. * @returns this effect.
  33661. */
  33662. setFloat2(uniformName: string, x: number, y: number): Effect;
  33663. /**
  33664. * Sets a Vector3 on a uniform variable.
  33665. * @param uniformName Name of the variable.
  33666. * @param vector3 Value to be set.
  33667. * @returns this effect.
  33668. */
  33669. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33670. /**
  33671. * Sets a float3 on a uniform variable.
  33672. * @param uniformName Name of the variable.
  33673. * @param x First float in float3.
  33674. * @param y Second float in float3.
  33675. * @param z Third float in float3.
  33676. * @returns this effect.
  33677. */
  33678. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33679. /**
  33680. * Sets a Vector4 on a uniform variable.
  33681. * @param uniformName Name of the variable.
  33682. * @param vector4 Value to be set.
  33683. * @returns this effect.
  33684. */
  33685. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33686. /**
  33687. * Sets a float4 on a uniform variable.
  33688. * @param uniformName Name of the variable.
  33689. * @param x First float in float4.
  33690. * @param y Second float in float4.
  33691. * @param z Third float in float4.
  33692. * @param w Fourth float in float4.
  33693. * @returns this effect.
  33694. */
  33695. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33696. /**
  33697. * Sets a Color3 on a uniform variable.
  33698. * @param uniformName Name of the variable.
  33699. * @param color3 Value to be set.
  33700. * @returns this effect.
  33701. */
  33702. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33703. /**
  33704. * Sets a Color4 on a uniform variable.
  33705. * @param uniformName Name of the variable.
  33706. * @param color3 Value to be set.
  33707. * @param alpha Alpha value to be set.
  33708. * @returns this effect.
  33709. */
  33710. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33711. /**
  33712. * Sets a Color4 on a uniform variable
  33713. * @param uniformName defines the name of the variable
  33714. * @param color4 defines the value to be set
  33715. * @returns this effect.
  33716. */
  33717. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33718. /** Release all associated resources */
  33719. dispose(): void;
  33720. /**
  33721. * This function will add a new shader to the shader store
  33722. * @param name the name of the shader
  33723. * @param pixelShader optional pixel shader content
  33724. * @param vertexShader optional vertex shader content
  33725. */
  33726. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33727. /**
  33728. * Store of each shader (The can be looked up using effect.key)
  33729. */
  33730. static ShadersStore: {
  33731. [key: string]: string;
  33732. };
  33733. /**
  33734. * Store of each included file for a shader (The can be looked up using effect.key)
  33735. */
  33736. static IncludesShadersStore: {
  33737. [key: string]: string;
  33738. };
  33739. /**
  33740. * Resets the cache of effects.
  33741. */
  33742. static ResetCache(): void;
  33743. }
  33744. }
  33745. declare module BABYLON {
  33746. /**
  33747. * Interface used to describe the capabilities of the engine relatively to the current browser
  33748. */
  33749. export interface EngineCapabilities {
  33750. /** Maximum textures units per fragment shader */
  33751. maxTexturesImageUnits: number;
  33752. /** Maximum texture units per vertex shader */
  33753. maxVertexTextureImageUnits: number;
  33754. /** Maximum textures units in the entire pipeline */
  33755. maxCombinedTexturesImageUnits: number;
  33756. /** Maximum texture size */
  33757. maxTextureSize: number;
  33758. /** Maximum texture samples */
  33759. maxSamples?: number;
  33760. /** Maximum cube texture size */
  33761. maxCubemapTextureSize: number;
  33762. /** Maximum render texture size */
  33763. maxRenderTextureSize: number;
  33764. /** Maximum number of vertex attributes */
  33765. maxVertexAttribs: number;
  33766. /** Maximum number of varyings */
  33767. maxVaryingVectors: number;
  33768. /** Maximum number of uniforms per vertex shader */
  33769. maxVertexUniformVectors: number;
  33770. /** Maximum number of uniforms per fragment shader */
  33771. maxFragmentUniformVectors: number;
  33772. /** Defines if standard derivates (dx/dy) are supported */
  33773. standardDerivatives: boolean;
  33774. /** Defines if s3tc texture compression is supported */
  33775. s3tc?: WEBGL_compressed_texture_s3tc;
  33776. /** Defines if pvrtc texture compression is supported */
  33777. pvrtc: any;
  33778. /** Defines if etc1 texture compression is supported */
  33779. etc1: any;
  33780. /** Defines if etc2 texture compression is supported */
  33781. etc2: any;
  33782. /** Defines if astc texture compression is supported */
  33783. astc: any;
  33784. /** Defines if float textures are supported */
  33785. textureFloat: boolean;
  33786. /** Defines if vertex array objects are supported */
  33787. vertexArrayObject: boolean;
  33788. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33789. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33790. /** Gets the maximum level of anisotropy supported */
  33791. maxAnisotropy: number;
  33792. /** Defines if instancing is supported */
  33793. instancedArrays: boolean;
  33794. /** Defines if 32 bits indices are supported */
  33795. uintIndices: boolean;
  33796. /** Defines if high precision shaders are supported */
  33797. highPrecisionShaderSupported: boolean;
  33798. /** Defines if depth reading in the fragment shader is supported */
  33799. fragmentDepthSupported: boolean;
  33800. /** Defines if float texture linear filtering is supported*/
  33801. textureFloatLinearFiltering: boolean;
  33802. /** Defines if rendering to float textures is supported */
  33803. textureFloatRender: boolean;
  33804. /** Defines if half float textures are supported*/
  33805. textureHalfFloat: boolean;
  33806. /** Defines if half float texture linear filtering is supported*/
  33807. textureHalfFloatLinearFiltering: boolean;
  33808. /** Defines if rendering to half float textures is supported */
  33809. textureHalfFloatRender: boolean;
  33810. /** Defines if textureLOD shader command is supported */
  33811. textureLOD: boolean;
  33812. /** Defines if draw buffers extension is supported */
  33813. drawBuffersExtension: boolean;
  33814. /** Defines if depth textures are supported */
  33815. depthTextureExtension: boolean;
  33816. /** Defines if float color buffer are supported */
  33817. colorBufferFloat: boolean;
  33818. /** Gets disjoint timer query extension (null if not supported) */
  33819. timerQuery?: EXT_disjoint_timer_query;
  33820. /** Defines if timestamp can be used with timer query */
  33821. canUseTimestampForTimerQuery: boolean;
  33822. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33823. multiview?: any;
  33824. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33825. oculusMultiview?: any;
  33826. /** Function used to let the system compiles shaders in background */
  33827. parallelShaderCompile?: {
  33828. COMPLETION_STATUS_KHR: number;
  33829. };
  33830. /** Max number of texture samples for MSAA */
  33831. maxMSAASamples: number;
  33832. /** Defines if the blend min max extension is supported */
  33833. blendMinMax: boolean;
  33834. }
  33835. }
  33836. declare module BABYLON {
  33837. /**
  33838. * @hidden
  33839. **/
  33840. export class DepthCullingState {
  33841. private _isDepthTestDirty;
  33842. private _isDepthMaskDirty;
  33843. private _isDepthFuncDirty;
  33844. private _isCullFaceDirty;
  33845. private _isCullDirty;
  33846. private _isZOffsetDirty;
  33847. private _isFrontFaceDirty;
  33848. private _depthTest;
  33849. private _depthMask;
  33850. private _depthFunc;
  33851. private _cull;
  33852. private _cullFace;
  33853. private _zOffset;
  33854. private _frontFace;
  33855. /**
  33856. * Initializes the state.
  33857. */
  33858. constructor();
  33859. get isDirty(): boolean;
  33860. get zOffset(): number;
  33861. set zOffset(value: number);
  33862. get cullFace(): Nullable<number>;
  33863. set cullFace(value: Nullable<number>);
  33864. get cull(): Nullable<boolean>;
  33865. set cull(value: Nullable<boolean>);
  33866. get depthFunc(): Nullable<number>;
  33867. set depthFunc(value: Nullable<number>);
  33868. get depthMask(): boolean;
  33869. set depthMask(value: boolean);
  33870. get depthTest(): boolean;
  33871. set depthTest(value: boolean);
  33872. get frontFace(): Nullable<number>;
  33873. set frontFace(value: Nullable<number>);
  33874. reset(): void;
  33875. apply(gl: WebGLRenderingContext): void;
  33876. }
  33877. }
  33878. declare module BABYLON {
  33879. /**
  33880. * @hidden
  33881. **/
  33882. export class StencilState {
  33883. /** 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 */
  33884. static readonly ALWAYS: number;
  33885. /** Passed to stencilOperation to specify that stencil value must be kept */
  33886. static readonly KEEP: number;
  33887. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33888. static readonly REPLACE: number;
  33889. private _isStencilTestDirty;
  33890. private _isStencilMaskDirty;
  33891. private _isStencilFuncDirty;
  33892. private _isStencilOpDirty;
  33893. private _stencilTest;
  33894. private _stencilMask;
  33895. private _stencilFunc;
  33896. private _stencilFuncRef;
  33897. private _stencilFuncMask;
  33898. private _stencilOpStencilFail;
  33899. private _stencilOpDepthFail;
  33900. private _stencilOpStencilDepthPass;
  33901. get isDirty(): boolean;
  33902. get stencilFunc(): number;
  33903. set stencilFunc(value: number);
  33904. get stencilFuncRef(): number;
  33905. set stencilFuncRef(value: number);
  33906. get stencilFuncMask(): number;
  33907. set stencilFuncMask(value: number);
  33908. get stencilOpStencilFail(): number;
  33909. set stencilOpStencilFail(value: number);
  33910. get stencilOpDepthFail(): number;
  33911. set stencilOpDepthFail(value: number);
  33912. get stencilOpStencilDepthPass(): number;
  33913. set stencilOpStencilDepthPass(value: number);
  33914. get stencilMask(): number;
  33915. set stencilMask(value: number);
  33916. get stencilTest(): boolean;
  33917. set stencilTest(value: boolean);
  33918. constructor();
  33919. reset(): void;
  33920. apply(gl: WebGLRenderingContext): void;
  33921. }
  33922. }
  33923. declare module BABYLON {
  33924. /**
  33925. * @hidden
  33926. **/
  33927. export class AlphaState {
  33928. private _isAlphaBlendDirty;
  33929. private _isBlendFunctionParametersDirty;
  33930. private _isBlendEquationParametersDirty;
  33931. private _isBlendConstantsDirty;
  33932. private _alphaBlend;
  33933. private _blendFunctionParameters;
  33934. private _blendEquationParameters;
  33935. private _blendConstants;
  33936. /**
  33937. * Initializes the state.
  33938. */
  33939. constructor();
  33940. get isDirty(): boolean;
  33941. get alphaBlend(): boolean;
  33942. set alphaBlend(value: boolean);
  33943. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33944. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33945. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33946. reset(): void;
  33947. apply(gl: WebGLRenderingContext): void;
  33948. }
  33949. }
  33950. declare module BABYLON {
  33951. /** @hidden */
  33952. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33953. attributeProcessor(attribute: string): string;
  33954. varyingProcessor(varying: string, isFragment: boolean): string;
  33955. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33956. }
  33957. }
  33958. declare module BABYLON {
  33959. /**
  33960. * Interface for attribute information associated with buffer instanciation
  33961. */
  33962. export interface InstancingAttributeInfo {
  33963. /**
  33964. * Name of the GLSL attribute
  33965. * if attribute index is not specified, this is used to retrieve the index from the effect
  33966. */
  33967. attributeName: string;
  33968. /**
  33969. * Index/offset of the attribute in the vertex shader
  33970. * if not specified, this will be computes from the name.
  33971. */
  33972. index?: number;
  33973. /**
  33974. * size of the attribute, 1, 2, 3 or 4
  33975. */
  33976. attributeSize: number;
  33977. /**
  33978. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33979. */
  33980. offset: number;
  33981. /**
  33982. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33983. * default to 1
  33984. */
  33985. divisor?: number;
  33986. /**
  33987. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33988. * default is FLOAT
  33989. */
  33990. attributeType?: number;
  33991. /**
  33992. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33993. */
  33994. normalized?: boolean;
  33995. }
  33996. }
  33997. declare module BABYLON {
  33998. interface ThinEngine {
  33999. /**
  34000. * Update a video texture
  34001. * @param texture defines the texture to update
  34002. * @param video defines the video element to use
  34003. * @param invertY defines if data must be stored with Y axis inverted
  34004. */
  34005. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34006. }
  34007. }
  34008. declare module BABYLON {
  34009. interface ThinEngine {
  34010. /**
  34011. * Creates a dynamic texture
  34012. * @param width defines the width of the texture
  34013. * @param height defines the height of the texture
  34014. * @param generateMipMaps defines if the engine should generate the mip levels
  34015. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34016. * @returns the dynamic texture inside an InternalTexture
  34017. */
  34018. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34019. /**
  34020. * Update the content of a dynamic texture
  34021. * @param texture defines the texture to update
  34022. * @param canvas defines the canvas containing the source
  34023. * @param invertY defines if data must be stored with Y axis inverted
  34024. * @param premulAlpha defines if alpha is stored as premultiplied
  34025. * @param format defines the format of the data
  34026. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34027. */
  34028. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34029. }
  34030. }
  34031. declare module BABYLON {
  34032. /**
  34033. * Settings for finer control over video usage
  34034. */
  34035. export interface VideoTextureSettings {
  34036. /**
  34037. * Applies `autoplay` to video, if specified
  34038. */
  34039. autoPlay?: boolean;
  34040. /**
  34041. * Applies `loop` to video, if specified
  34042. */
  34043. loop?: boolean;
  34044. /**
  34045. * Automatically updates internal texture from video at every frame in the render loop
  34046. */
  34047. autoUpdateTexture: boolean;
  34048. /**
  34049. * Image src displayed during the video loading or until the user interacts with the video.
  34050. */
  34051. poster?: string;
  34052. }
  34053. /**
  34054. * If you want to display a video in your scene, this is the special texture for that.
  34055. * This special texture works similar to other textures, with the exception of a few parameters.
  34056. * @see https://doc.babylonjs.com/how_to/video_texture
  34057. */
  34058. export class VideoTexture extends Texture {
  34059. /**
  34060. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34061. */
  34062. readonly autoUpdateTexture: boolean;
  34063. /**
  34064. * The video instance used by the texture internally
  34065. */
  34066. readonly video: HTMLVideoElement;
  34067. private _onUserActionRequestedObservable;
  34068. /**
  34069. * Event triggerd when a dom action is required by the user to play the video.
  34070. * This happens due to recent changes in browser policies preventing video to auto start.
  34071. */
  34072. get onUserActionRequestedObservable(): Observable<Texture>;
  34073. private _generateMipMaps;
  34074. private _stillImageCaptured;
  34075. private _displayingPosterTexture;
  34076. private _settings;
  34077. private _createInternalTextureOnEvent;
  34078. private _frameId;
  34079. private _currentSrc;
  34080. /**
  34081. * Creates a video texture.
  34082. * If you want to display a video in your scene, this is the special texture for that.
  34083. * This special texture works similar to other textures, with the exception of a few parameters.
  34084. * @see https://doc.babylonjs.com/how_to/video_texture
  34085. * @param name optional name, will detect from video source, if not defined
  34086. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34087. * @param scene is obviously the current scene.
  34088. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34089. * @param invertY is false by default but can be used to invert video on Y axis
  34090. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34091. * @param settings allows finer control over video usage
  34092. */
  34093. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34094. private _getName;
  34095. private _getVideo;
  34096. private _createInternalTexture;
  34097. private reset;
  34098. /**
  34099. * @hidden Internal method to initiate `update`.
  34100. */
  34101. _rebuild(): void;
  34102. /**
  34103. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34104. */
  34105. update(): void;
  34106. /**
  34107. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34108. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34109. */
  34110. updateTexture(isVisible: boolean): void;
  34111. protected _updateInternalTexture: () => void;
  34112. /**
  34113. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34114. * @param url New url.
  34115. */
  34116. updateURL(url: string): void;
  34117. /**
  34118. * Clones the texture.
  34119. * @returns the cloned texture
  34120. */
  34121. clone(): VideoTexture;
  34122. /**
  34123. * Dispose the texture and release its associated resources.
  34124. */
  34125. dispose(): void;
  34126. /**
  34127. * Creates a video texture straight from a stream.
  34128. * @param scene Define the scene the texture should be created in
  34129. * @param stream Define the stream the texture should be created from
  34130. * @returns The created video texture as a promise
  34131. */
  34132. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34133. /**
  34134. * Creates a video texture straight from your WebCam video feed.
  34135. * @param scene Define the scene the texture should be created in
  34136. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34137. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34138. * @returns The created video texture as a promise
  34139. */
  34140. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34141. minWidth: number;
  34142. maxWidth: number;
  34143. minHeight: number;
  34144. maxHeight: number;
  34145. deviceId: string;
  34146. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34147. /**
  34148. * Creates a video texture straight from your WebCam video feed.
  34149. * @param scene Define the scene the texture should be created in
  34150. * @param onReady Define a callback to triggered once the texture will be ready
  34151. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34152. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34153. */
  34154. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34155. minWidth: number;
  34156. maxWidth: number;
  34157. minHeight: number;
  34158. maxHeight: number;
  34159. deviceId: string;
  34160. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34161. }
  34162. }
  34163. declare module BABYLON {
  34164. /**
  34165. * Defines the interface used by objects working like Scene
  34166. * @hidden
  34167. */
  34168. export interface ISceneLike {
  34169. _addPendingData(data: any): void;
  34170. _removePendingData(data: any): void;
  34171. offlineProvider: IOfflineProvider;
  34172. }
  34173. /** Interface defining initialization parameters for Engine class */
  34174. export interface EngineOptions extends WebGLContextAttributes {
  34175. /**
  34176. * Defines if the engine should no exceed a specified device ratio
  34177. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34178. */
  34179. limitDeviceRatio?: number;
  34180. /**
  34181. * Defines if webvr should be enabled automatically
  34182. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34183. */
  34184. autoEnableWebVR?: boolean;
  34185. /**
  34186. * Defines if webgl2 should be turned off even if supported
  34187. * @see http://doc.babylonjs.com/features/webgl2
  34188. */
  34189. disableWebGL2Support?: boolean;
  34190. /**
  34191. * Defines if webaudio should be initialized as well
  34192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34193. */
  34194. audioEngine?: boolean;
  34195. /**
  34196. * Defines if animations should run using a deterministic lock step
  34197. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34198. */
  34199. deterministicLockstep?: boolean;
  34200. /** Defines the maximum steps to use with deterministic lock step mode */
  34201. lockstepMaxSteps?: number;
  34202. /** Defines the seconds between each deterministic lock step */
  34203. timeStep?: number;
  34204. /**
  34205. * Defines that engine should ignore context lost events
  34206. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34207. */
  34208. doNotHandleContextLost?: boolean;
  34209. /**
  34210. * Defines that engine should ignore modifying touch action attribute and style
  34211. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34212. */
  34213. doNotHandleTouchAction?: boolean;
  34214. /**
  34215. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34216. */
  34217. useHighPrecisionFloats?: boolean;
  34218. /**
  34219. * Make the canvas XR Compatible for XR sessions
  34220. */
  34221. xrCompatible?: boolean;
  34222. }
  34223. /**
  34224. * The base engine class (root of all engines)
  34225. */
  34226. export class ThinEngine {
  34227. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34228. static ExceptionList: ({
  34229. key: string;
  34230. capture: string;
  34231. captureConstraint: number;
  34232. targets: string[];
  34233. } | {
  34234. key: string;
  34235. capture: null;
  34236. captureConstraint: null;
  34237. targets: string[];
  34238. })[];
  34239. /** @hidden */
  34240. static _TextureLoaders: IInternalTextureLoader[];
  34241. /**
  34242. * Returns the current npm package of the sdk
  34243. */
  34244. static get NpmPackage(): string;
  34245. /**
  34246. * Returns the current version of the framework
  34247. */
  34248. static get Version(): string;
  34249. /**
  34250. * Returns a string describing the current engine
  34251. */
  34252. get description(): string;
  34253. /**
  34254. * Gets or sets the epsilon value used by collision engine
  34255. */
  34256. static CollisionsEpsilon: number;
  34257. /**
  34258. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34259. */
  34260. static get ShadersRepository(): string;
  34261. static set ShadersRepository(value: string);
  34262. /** @hidden */
  34263. _shaderProcessor: IShaderProcessor;
  34264. /**
  34265. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34266. */
  34267. forcePOTTextures: boolean;
  34268. /**
  34269. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34270. */
  34271. isFullscreen: boolean;
  34272. /**
  34273. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34274. */
  34275. cullBackFaces: boolean;
  34276. /**
  34277. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34278. */
  34279. renderEvenInBackground: boolean;
  34280. /**
  34281. * Gets or sets a boolean indicating that cache can be kept between frames
  34282. */
  34283. preventCacheWipeBetweenFrames: boolean;
  34284. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34285. validateShaderPrograms: boolean;
  34286. /**
  34287. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34288. * This can provide greater z depth for distant objects.
  34289. */
  34290. useReverseDepthBuffer: boolean;
  34291. /**
  34292. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34293. */
  34294. disableUniformBuffers: boolean;
  34295. /** @hidden */
  34296. _uniformBuffers: UniformBuffer[];
  34297. /**
  34298. * Gets a boolean indicating that the engine supports uniform buffers
  34299. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34300. */
  34301. get supportsUniformBuffers(): boolean;
  34302. /** @hidden */
  34303. _gl: WebGLRenderingContext;
  34304. /** @hidden */
  34305. _webGLVersion: number;
  34306. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34307. protected _windowIsBackground: boolean;
  34308. protected _creationOptions: EngineOptions;
  34309. protected _highPrecisionShadersAllowed: boolean;
  34310. /** @hidden */
  34311. get _shouldUseHighPrecisionShader(): boolean;
  34312. /**
  34313. * Gets a boolean indicating that only power of 2 textures are supported
  34314. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34315. */
  34316. get needPOTTextures(): boolean;
  34317. /** @hidden */
  34318. _badOS: boolean;
  34319. /** @hidden */
  34320. _badDesktopOS: boolean;
  34321. private _hardwareScalingLevel;
  34322. /** @hidden */
  34323. _caps: EngineCapabilities;
  34324. private _isStencilEnable;
  34325. private _glVersion;
  34326. private _glRenderer;
  34327. private _glVendor;
  34328. /** @hidden */
  34329. _videoTextureSupported: boolean;
  34330. protected _renderingQueueLaunched: boolean;
  34331. protected _activeRenderLoops: (() => void)[];
  34332. /**
  34333. * Observable signaled when a context lost event is raised
  34334. */
  34335. onContextLostObservable: Observable<ThinEngine>;
  34336. /**
  34337. * Observable signaled when a context restored event is raised
  34338. */
  34339. onContextRestoredObservable: Observable<ThinEngine>;
  34340. private _onContextLost;
  34341. private _onContextRestored;
  34342. protected _contextWasLost: boolean;
  34343. /** @hidden */
  34344. _doNotHandleContextLost: boolean;
  34345. /**
  34346. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34347. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34348. */
  34349. get doNotHandleContextLost(): boolean;
  34350. set doNotHandleContextLost(value: boolean);
  34351. /**
  34352. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34353. */
  34354. disableVertexArrayObjects: boolean;
  34355. /** @hidden */
  34356. protected _colorWrite: boolean;
  34357. /** @hidden */
  34358. protected _colorWriteChanged: boolean;
  34359. /** @hidden */
  34360. protected _depthCullingState: DepthCullingState;
  34361. /** @hidden */
  34362. protected _stencilState: StencilState;
  34363. /** @hidden */
  34364. _alphaState: AlphaState;
  34365. /** @hidden */
  34366. _alphaMode: number;
  34367. /** @hidden */
  34368. _alphaEquation: number;
  34369. /** @hidden */
  34370. _internalTexturesCache: InternalTexture[];
  34371. /** @hidden */
  34372. protected _activeChannel: number;
  34373. private _currentTextureChannel;
  34374. /** @hidden */
  34375. protected _boundTexturesCache: {
  34376. [key: string]: Nullable<InternalTexture>;
  34377. };
  34378. /** @hidden */
  34379. protected _currentEffect: Nullable<Effect>;
  34380. /** @hidden */
  34381. protected _currentProgram: Nullable<WebGLProgram>;
  34382. private _compiledEffects;
  34383. private _vertexAttribArraysEnabled;
  34384. /** @hidden */
  34385. protected _cachedViewport: Nullable<IViewportLike>;
  34386. private _cachedVertexArrayObject;
  34387. /** @hidden */
  34388. protected _cachedVertexBuffers: any;
  34389. /** @hidden */
  34390. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34391. /** @hidden */
  34392. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34393. /** @hidden */
  34394. _currentRenderTarget: Nullable<InternalTexture>;
  34395. private _uintIndicesCurrentlySet;
  34396. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34397. /** @hidden */
  34398. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34399. /** @hidden */
  34400. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34401. private _currentBufferPointers;
  34402. private _currentInstanceLocations;
  34403. private _currentInstanceBuffers;
  34404. private _textureUnits;
  34405. /** @hidden */
  34406. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34407. /** @hidden */
  34408. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34409. /** @hidden */
  34410. _boundRenderFunction: any;
  34411. private _vaoRecordInProgress;
  34412. private _mustWipeVertexAttributes;
  34413. private _emptyTexture;
  34414. private _emptyCubeTexture;
  34415. private _emptyTexture3D;
  34416. private _emptyTexture2DArray;
  34417. /** @hidden */
  34418. _frameHandler: number;
  34419. private _nextFreeTextureSlots;
  34420. private _maxSimultaneousTextures;
  34421. private _activeRequests;
  34422. /** @hidden */
  34423. _transformTextureUrl: Nullable<(url: string) => string>;
  34424. protected get _supportsHardwareTextureRescaling(): boolean;
  34425. private _framebufferDimensionsObject;
  34426. /**
  34427. * sets the object from which width and height will be taken from when getting render width and height
  34428. * Will fallback to the gl object
  34429. * @param dimensions the framebuffer width and height that will be used.
  34430. */
  34431. set framebufferDimensionsObject(dimensions: Nullable<{
  34432. framebufferWidth: number;
  34433. framebufferHeight: number;
  34434. }>);
  34435. /**
  34436. * Gets the current viewport
  34437. */
  34438. get currentViewport(): Nullable<IViewportLike>;
  34439. /**
  34440. * Gets the default empty texture
  34441. */
  34442. get emptyTexture(): InternalTexture;
  34443. /**
  34444. * Gets the default empty 3D texture
  34445. */
  34446. get emptyTexture3D(): InternalTexture;
  34447. /**
  34448. * Gets the default empty 2D array texture
  34449. */
  34450. get emptyTexture2DArray(): InternalTexture;
  34451. /**
  34452. * Gets the default empty cube texture
  34453. */
  34454. get emptyCubeTexture(): InternalTexture;
  34455. /**
  34456. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34457. */
  34458. readonly premultipliedAlpha: boolean;
  34459. /**
  34460. * Observable event triggered before each texture is initialized
  34461. */
  34462. onBeforeTextureInitObservable: Observable<Texture>;
  34463. /**
  34464. * Creates a new engine
  34465. * @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
  34466. * @param antialias defines enable antialiasing (default: false)
  34467. * @param options defines further options to be sent to the getContext() function
  34468. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34469. */
  34470. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34471. private _rebuildInternalTextures;
  34472. private _rebuildEffects;
  34473. /**
  34474. * Gets a boolean indicating if all created effects are ready
  34475. * @returns true if all effects are ready
  34476. */
  34477. areAllEffectsReady(): boolean;
  34478. protected _rebuildBuffers(): void;
  34479. protected _initGLContext(): void;
  34480. /**
  34481. * Gets version of the current webGL context
  34482. */
  34483. get webGLVersion(): number;
  34484. /**
  34485. * Gets a string idenfifying the name of the class
  34486. * @returns "Engine" string
  34487. */
  34488. getClassName(): string;
  34489. /**
  34490. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34491. */
  34492. get isStencilEnable(): boolean;
  34493. /** @hidden */
  34494. _prepareWorkingCanvas(): void;
  34495. /**
  34496. * Reset the texture cache to empty state
  34497. */
  34498. resetTextureCache(): void;
  34499. /**
  34500. * Gets an object containing information about the current webGL context
  34501. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34502. */
  34503. getGlInfo(): {
  34504. vendor: string;
  34505. renderer: string;
  34506. version: string;
  34507. };
  34508. /**
  34509. * Defines the hardware scaling level.
  34510. * By default the hardware scaling level is computed from the window device ratio.
  34511. * 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.
  34512. * @param level defines the level to use
  34513. */
  34514. setHardwareScalingLevel(level: number): void;
  34515. /**
  34516. * Gets the current hardware scaling level.
  34517. * By default the hardware scaling level is computed from the window device ratio.
  34518. * 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.
  34519. * @returns a number indicating the current hardware scaling level
  34520. */
  34521. getHardwareScalingLevel(): number;
  34522. /**
  34523. * Gets the list of loaded textures
  34524. * @returns an array containing all loaded textures
  34525. */
  34526. getLoadedTexturesCache(): InternalTexture[];
  34527. /**
  34528. * Gets the object containing all engine capabilities
  34529. * @returns the EngineCapabilities object
  34530. */
  34531. getCaps(): EngineCapabilities;
  34532. /**
  34533. * stop executing a render loop function and remove it from the execution array
  34534. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34535. */
  34536. stopRenderLoop(renderFunction?: () => void): void;
  34537. /** @hidden */
  34538. _renderLoop(): void;
  34539. /**
  34540. * Gets the HTML canvas attached with the current webGL context
  34541. * @returns a HTML canvas
  34542. */
  34543. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34544. /**
  34545. * Gets host window
  34546. * @returns the host window object
  34547. */
  34548. getHostWindow(): Nullable<Window>;
  34549. /**
  34550. * Gets the current render width
  34551. * @param useScreen defines if screen size must be used (or the current render target if any)
  34552. * @returns a number defining the current render width
  34553. */
  34554. getRenderWidth(useScreen?: boolean): number;
  34555. /**
  34556. * Gets the current render height
  34557. * @param useScreen defines if screen size must be used (or the current render target if any)
  34558. * @returns a number defining the current render height
  34559. */
  34560. getRenderHeight(useScreen?: boolean): number;
  34561. /**
  34562. * Can be used to override the current requestAnimationFrame requester.
  34563. * @hidden
  34564. */
  34565. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34566. /**
  34567. * Register and execute a render loop. The engine can have more than one render function
  34568. * @param renderFunction defines the function to continuously execute
  34569. */
  34570. runRenderLoop(renderFunction: () => void): void;
  34571. /**
  34572. * Clear the current render buffer or the current render target (if any is set up)
  34573. * @param color defines the color to use
  34574. * @param backBuffer defines if the back buffer must be cleared
  34575. * @param depth defines if the depth buffer must be cleared
  34576. * @param stencil defines if the stencil buffer must be cleared
  34577. */
  34578. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34579. private _viewportCached;
  34580. /** @hidden */
  34581. _viewport(x: number, y: number, width: number, height: number): void;
  34582. /**
  34583. * Set the WebGL's viewport
  34584. * @param viewport defines the viewport element to be used
  34585. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34586. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34587. */
  34588. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34589. /**
  34590. * Begin a new frame
  34591. */
  34592. beginFrame(): void;
  34593. /**
  34594. * Enf the current frame
  34595. */
  34596. endFrame(): void;
  34597. /**
  34598. * Resize the view according to the canvas' size
  34599. */
  34600. resize(): void;
  34601. /**
  34602. * Force a specific size of the canvas
  34603. * @param width defines the new canvas' width
  34604. * @param height defines the new canvas' height
  34605. */
  34606. setSize(width: number, height: number): void;
  34607. /**
  34608. * Binds the frame buffer to the specified texture.
  34609. * @param texture The texture to render to or null for the default canvas
  34610. * @param faceIndex The face of the texture to render to in case of cube texture
  34611. * @param requiredWidth The width of the target to render to
  34612. * @param requiredHeight The height of the target to render to
  34613. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34614. * @param lodLevel defines the lod level to bind to the frame buffer
  34615. * @param layer defines the 2d array index to bind to frame buffer to
  34616. */
  34617. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34618. /** @hidden */
  34619. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34620. /**
  34621. * Unbind the current render target texture from the webGL context
  34622. * @param texture defines the render target texture to unbind
  34623. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34624. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34625. */
  34626. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34627. /**
  34628. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34629. */
  34630. flushFramebuffer(): void;
  34631. /**
  34632. * Unbind the current render target and bind the default framebuffer
  34633. */
  34634. restoreDefaultFramebuffer(): void;
  34635. /** @hidden */
  34636. protected _resetVertexBufferBinding(): void;
  34637. /**
  34638. * Creates a vertex buffer
  34639. * @param data the data for the vertex buffer
  34640. * @returns the new WebGL static buffer
  34641. */
  34642. createVertexBuffer(data: DataArray): DataBuffer;
  34643. private _createVertexBuffer;
  34644. /**
  34645. * Creates a dynamic vertex buffer
  34646. * @param data the data for the dynamic vertex buffer
  34647. * @returns the new WebGL dynamic buffer
  34648. */
  34649. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34650. protected _resetIndexBufferBinding(): void;
  34651. /**
  34652. * Creates a new index buffer
  34653. * @param indices defines the content of the index buffer
  34654. * @param updatable defines if the index buffer must be updatable
  34655. * @returns a new webGL buffer
  34656. */
  34657. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34658. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34659. /**
  34660. * Bind a webGL buffer to the webGL context
  34661. * @param buffer defines the buffer to bind
  34662. */
  34663. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34664. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34665. private bindBuffer;
  34666. /**
  34667. * update the bound buffer with the given data
  34668. * @param data defines the data to update
  34669. */
  34670. updateArrayBuffer(data: Float32Array): void;
  34671. private _vertexAttribPointer;
  34672. /** @hidden */
  34673. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34674. private _bindVertexBuffersAttributes;
  34675. /**
  34676. * Records a vertex array object
  34677. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34678. * @param vertexBuffers defines the list of vertex buffers to store
  34679. * @param indexBuffer defines the index buffer to store
  34680. * @param effect defines the effect to store
  34681. * @returns the new vertex array object
  34682. */
  34683. recordVertexArrayObject(vertexBuffers: {
  34684. [key: string]: VertexBuffer;
  34685. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34686. /**
  34687. * Bind a specific vertex array object
  34688. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34689. * @param vertexArrayObject defines the vertex array object to bind
  34690. * @param indexBuffer defines the index buffer to bind
  34691. */
  34692. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34693. /**
  34694. * Bind webGl buffers directly to the webGL context
  34695. * @param vertexBuffer defines the vertex buffer to bind
  34696. * @param indexBuffer defines the index buffer to bind
  34697. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34698. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34699. * @param effect defines the effect associated with the vertex buffer
  34700. */
  34701. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34702. private _unbindVertexArrayObject;
  34703. /**
  34704. * Bind a list of vertex buffers to the webGL context
  34705. * @param vertexBuffers defines the list of vertex buffers to bind
  34706. * @param indexBuffer defines the index buffer to bind
  34707. * @param effect defines the effect associated with the vertex buffers
  34708. */
  34709. bindBuffers(vertexBuffers: {
  34710. [key: string]: Nullable<VertexBuffer>;
  34711. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34712. /**
  34713. * Unbind all instance attributes
  34714. */
  34715. unbindInstanceAttributes(): void;
  34716. /**
  34717. * Release and free the memory of a vertex array object
  34718. * @param vao defines the vertex array object to delete
  34719. */
  34720. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34721. /** @hidden */
  34722. _releaseBuffer(buffer: DataBuffer): boolean;
  34723. protected _deleteBuffer(buffer: DataBuffer): void;
  34724. /**
  34725. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34726. * @param instancesBuffer defines the webGL buffer to update and bind
  34727. * @param data defines the data to store in the buffer
  34728. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34729. */
  34730. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34731. /**
  34732. * Bind the content of a webGL buffer used with instantiation
  34733. * @param instancesBuffer defines the webGL buffer to bind
  34734. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34735. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34736. */
  34737. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34738. /**
  34739. * Disable the instance attribute corresponding to the name in parameter
  34740. * @param name defines the name of the attribute to disable
  34741. */
  34742. disableInstanceAttributeByName(name: string): void;
  34743. /**
  34744. * Disable the instance attribute corresponding to the location in parameter
  34745. * @param attributeLocation defines the attribute location of the attribute to disable
  34746. */
  34747. disableInstanceAttribute(attributeLocation: number): void;
  34748. /**
  34749. * Disable the attribute corresponding to the location in parameter
  34750. * @param attributeLocation defines the attribute location of the attribute to disable
  34751. */
  34752. disableAttributeByIndex(attributeLocation: number): void;
  34753. /**
  34754. * Send a draw order
  34755. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34756. * @param indexStart defines the starting index
  34757. * @param indexCount defines the number of index to draw
  34758. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34759. */
  34760. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34761. /**
  34762. * Draw a list of points
  34763. * @param verticesStart defines the index of first vertex to draw
  34764. * @param verticesCount defines the count of vertices to draw
  34765. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34766. */
  34767. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34768. /**
  34769. * Draw a list of unindexed primitives
  34770. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34771. * @param verticesStart defines the index of first vertex to draw
  34772. * @param verticesCount defines the count of vertices to draw
  34773. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34774. */
  34775. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34776. /**
  34777. * Draw a list of indexed primitives
  34778. * @param fillMode defines the primitive to use
  34779. * @param indexStart defines the starting index
  34780. * @param indexCount defines the number of index to draw
  34781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34782. */
  34783. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34784. /**
  34785. * Draw a list of unindexed primitives
  34786. * @param fillMode defines the primitive to use
  34787. * @param verticesStart defines the index of first vertex to draw
  34788. * @param verticesCount defines the count of vertices to draw
  34789. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34790. */
  34791. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34792. private _drawMode;
  34793. /** @hidden */
  34794. protected _reportDrawCall(): void;
  34795. /** @hidden */
  34796. _releaseEffect(effect: Effect): void;
  34797. /** @hidden */
  34798. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34799. /**
  34800. * Create a new effect (used to store vertex/fragment shaders)
  34801. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34802. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34803. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34804. * @param samplers defines an array of string used to represent textures
  34805. * @param defines defines the string containing the defines to use to compile the shaders
  34806. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34807. * @param onCompiled defines a function to call when the effect creation is successful
  34808. * @param onError defines a function to call when the effect creation has failed
  34809. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34810. * @returns the new Effect
  34811. */
  34812. 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;
  34813. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34814. private _compileShader;
  34815. private _compileRawShader;
  34816. /** @hidden */
  34817. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34818. /**
  34819. * Directly creates a webGL program
  34820. * @param pipelineContext defines the pipeline context to attach to
  34821. * @param vertexCode defines the vertex shader code to use
  34822. * @param fragmentCode defines the fragment shader code to use
  34823. * @param context defines the webGL context to use (if not set, the current one will be used)
  34824. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34825. * @returns the new webGL program
  34826. */
  34827. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34828. /**
  34829. * Creates a webGL program
  34830. * @param pipelineContext defines the pipeline context to attach to
  34831. * @param vertexCode defines the vertex shader code to use
  34832. * @param fragmentCode defines the fragment shader code to use
  34833. * @param defines defines the string containing the defines to use to compile the shaders
  34834. * @param context defines the webGL context to use (if not set, the current one will be used)
  34835. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34836. * @returns the new webGL program
  34837. */
  34838. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34839. /**
  34840. * Creates a new pipeline context
  34841. * @returns the new pipeline
  34842. */
  34843. createPipelineContext(): IPipelineContext;
  34844. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34845. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34846. /** @hidden */
  34847. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34848. /** @hidden */
  34849. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34850. /** @hidden */
  34851. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34852. /**
  34853. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34854. * @param pipelineContext defines the pipeline context to use
  34855. * @param uniformsNames defines the list of uniform names
  34856. * @returns an array of webGL uniform locations
  34857. */
  34858. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34859. /**
  34860. * Gets the lsit of active attributes for a given webGL program
  34861. * @param pipelineContext defines the pipeline context to use
  34862. * @param attributesNames defines the list of attribute names to get
  34863. * @returns an array of indices indicating the offset of each attribute
  34864. */
  34865. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34866. /**
  34867. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34868. * @param effect defines the effect to activate
  34869. */
  34870. enableEffect(effect: Nullable<Effect>): void;
  34871. /**
  34872. * Set the value of an uniform to a number (int)
  34873. * @param uniform defines the webGL uniform location where to store the value
  34874. * @param value defines the int number to store
  34875. */
  34876. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34877. /**
  34878. * Set the value of an uniform to an array of int32
  34879. * @param uniform defines the webGL uniform location where to store the value
  34880. * @param array defines the array of int32 to store
  34881. */
  34882. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34883. /**
  34884. * Set the value of an uniform to an array of int32 (stored as vec2)
  34885. * @param uniform defines the webGL uniform location where to store the value
  34886. * @param array defines the array of int32 to store
  34887. */
  34888. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34889. /**
  34890. * Set the value of an uniform to an array of int32 (stored as vec3)
  34891. * @param uniform defines the webGL uniform location where to store the value
  34892. * @param array defines the array of int32 to store
  34893. */
  34894. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34895. /**
  34896. * Set the value of an uniform to an array of int32 (stored as vec4)
  34897. * @param uniform defines the webGL uniform location where to store the value
  34898. * @param array defines the array of int32 to store
  34899. */
  34900. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34901. /**
  34902. * Set the value of an uniform to an array of number
  34903. * @param uniform defines the webGL uniform location where to store the value
  34904. * @param array defines the array of number to store
  34905. */
  34906. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34907. /**
  34908. * Set the value of an uniform to an array of number (stored as vec2)
  34909. * @param uniform defines the webGL uniform location where to store the value
  34910. * @param array defines the array of number to store
  34911. */
  34912. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34913. /**
  34914. * Set the value of an uniform to an array of number (stored as vec3)
  34915. * @param uniform defines the webGL uniform location where to store the value
  34916. * @param array defines the array of number to store
  34917. */
  34918. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34919. /**
  34920. * Set the value of an uniform to an array of number (stored as vec4)
  34921. * @param uniform defines the webGL uniform location where to store the value
  34922. * @param array defines the array of number to store
  34923. */
  34924. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34925. /**
  34926. * Set the value of an uniform to an array of float32 (stored as matrices)
  34927. * @param uniform defines the webGL uniform location where to store the value
  34928. * @param matrices defines the array of float32 to store
  34929. */
  34930. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34931. /**
  34932. * Set the value of an uniform to a matrix (3x3)
  34933. * @param uniform defines the webGL uniform location where to store the value
  34934. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34935. */
  34936. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34937. /**
  34938. * Set the value of an uniform to a matrix (2x2)
  34939. * @param uniform defines the webGL uniform location where to store the value
  34940. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34941. */
  34942. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34943. /**
  34944. * Set the value of an uniform to a number (float)
  34945. * @param uniform defines the webGL uniform location where to store the value
  34946. * @param value defines the float number to store
  34947. */
  34948. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34949. /**
  34950. * Set the value of an uniform to a vec2
  34951. * @param uniform defines the webGL uniform location where to store the value
  34952. * @param x defines the 1st component of the value
  34953. * @param y defines the 2nd component of the value
  34954. */
  34955. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34956. /**
  34957. * Set the value of an uniform to a vec3
  34958. * @param uniform defines the webGL uniform location where to store the value
  34959. * @param x defines the 1st component of the value
  34960. * @param y defines the 2nd component of the value
  34961. * @param z defines the 3rd component of the value
  34962. */
  34963. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34964. /**
  34965. * Set the value of an uniform to a vec4
  34966. * @param uniform defines the webGL uniform location where to store the value
  34967. * @param x defines the 1st component of the value
  34968. * @param y defines the 2nd component of the value
  34969. * @param z defines the 3rd component of the value
  34970. * @param w defines the 4th component of the value
  34971. */
  34972. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34973. /**
  34974. * Apply all cached states (depth, culling, stencil and alpha)
  34975. */
  34976. applyStates(): void;
  34977. /**
  34978. * Enable or disable color writing
  34979. * @param enable defines the state to set
  34980. */
  34981. setColorWrite(enable: boolean): void;
  34982. /**
  34983. * Gets a boolean indicating if color writing is enabled
  34984. * @returns the current color writing state
  34985. */
  34986. getColorWrite(): boolean;
  34987. /**
  34988. * Gets the depth culling state manager
  34989. */
  34990. get depthCullingState(): DepthCullingState;
  34991. /**
  34992. * Gets the alpha state manager
  34993. */
  34994. get alphaState(): AlphaState;
  34995. /**
  34996. * Gets the stencil state manager
  34997. */
  34998. get stencilState(): StencilState;
  34999. /**
  35000. * Clears the list of texture accessible through engine.
  35001. * This can help preventing texture load conflict due to name collision.
  35002. */
  35003. clearInternalTexturesCache(): void;
  35004. /**
  35005. * Force the entire cache to be cleared
  35006. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35007. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35008. */
  35009. wipeCaches(bruteForce?: boolean): void;
  35010. /** @hidden */
  35011. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35012. min: number;
  35013. mag: number;
  35014. };
  35015. /** @hidden */
  35016. _createTexture(): WebGLTexture;
  35017. /**
  35018. * Usually called from Texture.ts.
  35019. * Passed information to create a WebGLTexture
  35020. * @param url defines a value which contains one of the following:
  35021. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35022. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35023. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35024. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35025. * @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)
  35026. * @param scene needed for loading to the correct scene
  35027. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35028. * @param onLoad optional callback to be called upon successful completion
  35029. * @param onError optional callback to be called upon failure
  35030. * @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
  35031. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35032. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35033. * @param forcedExtension defines the extension to use to pick the right loader
  35034. * @param mimeType defines an optional mime type
  35035. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35036. */
  35037. 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;
  35038. /**
  35039. * Loads an image as an HTMLImageElement.
  35040. * @param input url string, ArrayBuffer, or Blob to load
  35041. * @param onLoad callback called when the image successfully loads
  35042. * @param onError callback called when the image fails to load
  35043. * @param offlineProvider offline provider for caching
  35044. * @param mimeType optional mime type
  35045. * @returns the HTMLImageElement of the loaded image
  35046. * @hidden
  35047. */
  35048. 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>;
  35049. /**
  35050. * @hidden
  35051. */
  35052. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35053. private _unpackFlipYCached;
  35054. /**
  35055. * In case you are sharing the context with other applications, it might
  35056. * be interested to not cache the unpack flip y state to ensure a consistent
  35057. * value would be set.
  35058. */
  35059. enableUnpackFlipYCached: boolean;
  35060. /** @hidden */
  35061. _unpackFlipY(value: boolean): void;
  35062. /** @hidden */
  35063. _getUnpackAlignement(): number;
  35064. private _getTextureTarget;
  35065. /**
  35066. * Update the sampling mode of a given texture
  35067. * @param samplingMode defines the required sampling mode
  35068. * @param texture defines the texture to update
  35069. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35070. */
  35071. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35072. /**
  35073. * Update the sampling mode of a given texture
  35074. * @param texture defines the texture to update
  35075. * @param wrapU defines the texture wrap mode of the u coordinates
  35076. * @param wrapV defines the texture wrap mode of the v coordinates
  35077. * @param wrapR defines the texture wrap mode of the r coordinates
  35078. */
  35079. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35080. /** @hidden */
  35081. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35082. width: number;
  35083. height: number;
  35084. layers?: number;
  35085. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35086. /** @hidden */
  35087. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35088. /** @hidden */
  35089. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35090. /**
  35091. * Update a portion of an internal texture
  35092. * @param texture defines the texture to update
  35093. * @param imageData defines the data to store into the texture
  35094. * @param xOffset defines the x coordinates of the update rectangle
  35095. * @param yOffset defines the y coordinates of the update rectangle
  35096. * @param width defines the width of the update rectangle
  35097. * @param height defines the height of the update rectangle
  35098. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35099. * @param lod defines the lod level to update (0 by default)
  35100. */
  35101. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35102. /** @hidden */
  35103. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35104. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35105. private _prepareWebGLTexture;
  35106. /** @hidden */
  35107. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35108. private _getDepthStencilBuffer;
  35109. /** @hidden */
  35110. _releaseFramebufferObjects(texture: InternalTexture): void;
  35111. /** @hidden */
  35112. _releaseTexture(texture: InternalTexture): void;
  35113. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35114. protected _setProgram(program: WebGLProgram): void;
  35115. protected _boundUniforms: {
  35116. [key: number]: WebGLUniformLocation;
  35117. };
  35118. /**
  35119. * Binds an effect to the webGL context
  35120. * @param effect defines the effect to bind
  35121. */
  35122. bindSamplers(effect: Effect): void;
  35123. private _activateCurrentTexture;
  35124. /** @hidden */
  35125. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35126. /** @hidden */
  35127. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35128. /**
  35129. * Unbind all textures from the webGL context
  35130. */
  35131. unbindAllTextures(): void;
  35132. /**
  35133. * Sets a texture to the according uniform.
  35134. * @param channel The texture channel
  35135. * @param uniform The uniform to set
  35136. * @param texture The texture to apply
  35137. */
  35138. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35139. private _bindSamplerUniformToChannel;
  35140. private _getTextureWrapMode;
  35141. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35142. /**
  35143. * Sets an array of texture to the webGL context
  35144. * @param channel defines the channel where the texture array must be set
  35145. * @param uniform defines the associated uniform location
  35146. * @param textures defines the array of textures to bind
  35147. */
  35148. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35149. /** @hidden */
  35150. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35151. private _setTextureParameterFloat;
  35152. private _setTextureParameterInteger;
  35153. /**
  35154. * Unbind all vertex attributes from the webGL context
  35155. */
  35156. unbindAllAttributes(): void;
  35157. /**
  35158. * 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
  35159. */
  35160. releaseEffects(): void;
  35161. /**
  35162. * Dispose and release all associated resources
  35163. */
  35164. dispose(): void;
  35165. /**
  35166. * Attach a new callback raised when context lost event is fired
  35167. * @param callback defines the callback to call
  35168. */
  35169. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35170. /**
  35171. * Attach a new callback raised when context restored event is fired
  35172. * @param callback defines the callback to call
  35173. */
  35174. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35175. /**
  35176. * Get the current error code of the webGL context
  35177. * @returns the error code
  35178. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35179. */
  35180. getError(): number;
  35181. private _canRenderToFloatFramebuffer;
  35182. private _canRenderToHalfFloatFramebuffer;
  35183. private _canRenderToFramebuffer;
  35184. /** @hidden */
  35185. _getWebGLTextureType(type: number): number;
  35186. /** @hidden */
  35187. _getInternalFormat(format: number): number;
  35188. /** @hidden */
  35189. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35190. /** @hidden */
  35191. _getRGBAMultiSampleBufferFormat(type: number): number;
  35192. /** @hidden */
  35193. _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;
  35194. /**
  35195. * Loads a file from a url
  35196. * @param url url to load
  35197. * @param onSuccess callback called when the file successfully loads
  35198. * @param onProgress callback called while file is loading (if the server supports this mode)
  35199. * @param offlineProvider defines the offline provider for caching
  35200. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35201. * @param onError callback called when the file fails to load
  35202. * @returns a file request object
  35203. * @hidden
  35204. */
  35205. 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;
  35206. /**
  35207. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35208. * @param x defines the x coordinate of the rectangle where pixels must be read
  35209. * @param y defines the y coordinate of the rectangle where pixels must be read
  35210. * @param width defines the width of the rectangle where pixels must be read
  35211. * @param height defines the height of the rectangle where pixels must be read
  35212. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35213. * @returns a Uint8Array containing RGBA colors
  35214. */
  35215. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35216. private static _isSupported;
  35217. /**
  35218. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35219. * @returns true if the engine can be created
  35220. * @ignorenaming
  35221. */
  35222. static isSupported(): boolean;
  35223. /**
  35224. * Find the next highest power of two.
  35225. * @param x Number to start search from.
  35226. * @return Next highest power of two.
  35227. */
  35228. static CeilingPOT(x: number): number;
  35229. /**
  35230. * Find the next lowest power of two.
  35231. * @param x Number to start search from.
  35232. * @return Next lowest power of two.
  35233. */
  35234. static FloorPOT(x: number): number;
  35235. /**
  35236. * Find the nearest power of two.
  35237. * @param x Number to start search from.
  35238. * @return Next nearest power of two.
  35239. */
  35240. static NearestPOT(x: number): number;
  35241. /**
  35242. * Get the closest exponent of two
  35243. * @param value defines the value to approximate
  35244. * @param max defines the maximum value to return
  35245. * @param mode defines how to define the closest value
  35246. * @returns closest exponent of two of the given value
  35247. */
  35248. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35249. /**
  35250. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35251. * @param func - the function to be called
  35252. * @param requester - the object that will request the next frame. Falls back to window.
  35253. * @returns frame number
  35254. */
  35255. static QueueNewFrame(func: () => void, requester?: any): number;
  35256. /**
  35257. * Gets host document
  35258. * @returns the host document object
  35259. */
  35260. getHostDocument(): Nullable<Document>;
  35261. }
  35262. }
  35263. declare module BABYLON {
  35264. /**
  35265. * Class representing spherical harmonics coefficients to the 3rd degree
  35266. */
  35267. export class SphericalHarmonics {
  35268. /**
  35269. * Defines whether or not the harmonics have been prescaled for rendering.
  35270. */
  35271. preScaled: boolean;
  35272. /**
  35273. * The l0,0 coefficients of the spherical harmonics
  35274. */
  35275. l00: Vector3;
  35276. /**
  35277. * The l1,-1 coefficients of the spherical harmonics
  35278. */
  35279. l1_1: Vector3;
  35280. /**
  35281. * The l1,0 coefficients of the spherical harmonics
  35282. */
  35283. l10: Vector3;
  35284. /**
  35285. * The l1,1 coefficients of the spherical harmonics
  35286. */
  35287. l11: Vector3;
  35288. /**
  35289. * The l2,-2 coefficients of the spherical harmonics
  35290. */
  35291. l2_2: Vector3;
  35292. /**
  35293. * The l2,-1 coefficients of the spherical harmonics
  35294. */
  35295. l2_1: Vector3;
  35296. /**
  35297. * The l2,0 coefficients of the spherical harmonics
  35298. */
  35299. l20: Vector3;
  35300. /**
  35301. * The l2,1 coefficients of the spherical harmonics
  35302. */
  35303. l21: Vector3;
  35304. /**
  35305. * The l2,2 coefficients of the spherical harmonics
  35306. */
  35307. l22: Vector3;
  35308. /**
  35309. * Adds a light to the spherical harmonics
  35310. * @param direction the direction of the light
  35311. * @param color the color of the light
  35312. * @param deltaSolidAngle the delta solid angle of the light
  35313. */
  35314. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35315. /**
  35316. * Scales the spherical harmonics by the given amount
  35317. * @param scale the amount to scale
  35318. */
  35319. scaleInPlace(scale: number): void;
  35320. /**
  35321. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35322. *
  35323. * ```
  35324. * E_lm = A_l * L_lm
  35325. * ```
  35326. *
  35327. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35328. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35329. * the scaling factors are given in equation 9.
  35330. */
  35331. convertIncidentRadianceToIrradiance(): void;
  35332. /**
  35333. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35334. *
  35335. * ```
  35336. * L = (1/pi) * E * rho
  35337. * ```
  35338. *
  35339. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35340. */
  35341. convertIrradianceToLambertianRadiance(): void;
  35342. /**
  35343. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35344. * required operations at run time.
  35345. *
  35346. * This is simply done by scaling back the SH with Ylm constants parameter.
  35347. * The trigonometric part being applied by the shader at run time.
  35348. */
  35349. preScaleForRendering(): void;
  35350. /**
  35351. * Constructs a spherical harmonics from an array.
  35352. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35353. * @returns the spherical harmonics
  35354. */
  35355. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35356. /**
  35357. * Gets the spherical harmonics from polynomial
  35358. * @param polynomial the spherical polynomial
  35359. * @returns the spherical harmonics
  35360. */
  35361. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35362. }
  35363. /**
  35364. * Class representing spherical polynomial coefficients to the 3rd degree
  35365. */
  35366. export class SphericalPolynomial {
  35367. private _harmonics;
  35368. /**
  35369. * The spherical harmonics used to create the polynomials.
  35370. */
  35371. get preScaledHarmonics(): SphericalHarmonics;
  35372. /**
  35373. * The x coefficients of the spherical polynomial
  35374. */
  35375. x: Vector3;
  35376. /**
  35377. * The y coefficients of the spherical polynomial
  35378. */
  35379. y: Vector3;
  35380. /**
  35381. * The z coefficients of the spherical polynomial
  35382. */
  35383. z: Vector3;
  35384. /**
  35385. * The xx coefficients of the spherical polynomial
  35386. */
  35387. xx: Vector3;
  35388. /**
  35389. * The yy coefficients of the spherical polynomial
  35390. */
  35391. yy: Vector3;
  35392. /**
  35393. * The zz coefficients of the spherical polynomial
  35394. */
  35395. zz: Vector3;
  35396. /**
  35397. * The xy coefficients of the spherical polynomial
  35398. */
  35399. xy: Vector3;
  35400. /**
  35401. * The yz coefficients of the spherical polynomial
  35402. */
  35403. yz: Vector3;
  35404. /**
  35405. * The zx coefficients of the spherical polynomial
  35406. */
  35407. zx: Vector3;
  35408. /**
  35409. * Adds an ambient color to the spherical polynomial
  35410. * @param color the color to add
  35411. */
  35412. addAmbient(color: Color3): void;
  35413. /**
  35414. * Scales the spherical polynomial by the given amount
  35415. * @param scale the amount to scale
  35416. */
  35417. scaleInPlace(scale: number): void;
  35418. /**
  35419. * Gets the spherical polynomial from harmonics
  35420. * @param harmonics the spherical harmonics
  35421. * @returns the spherical polynomial
  35422. */
  35423. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35424. /**
  35425. * Constructs a spherical polynomial from an array.
  35426. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35427. * @returns the spherical polynomial
  35428. */
  35429. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35430. }
  35431. }
  35432. declare module BABYLON {
  35433. /**
  35434. * Defines the source of the internal texture
  35435. */
  35436. export enum InternalTextureSource {
  35437. /**
  35438. * The source of the texture data is unknown
  35439. */
  35440. Unknown = 0,
  35441. /**
  35442. * Texture data comes from an URL
  35443. */
  35444. Url = 1,
  35445. /**
  35446. * Texture data is only used for temporary storage
  35447. */
  35448. Temp = 2,
  35449. /**
  35450. * Texture data comes from raw data (ArrayBuffer)
  35451. */
  35452. Raw = 3,
  35453. /**
  35454. * Texture content is dynamic (video or dynamic texture)
  35455. */
  35456. Dynamic = 4,
  35457. /**
  35458. * Texture content is generated by rendering to it
  35459. */
  35460. RenderTarget = 5,
  35461. /**
  35462. * Texture content is part of a multi render target process
  35463. */
  35464. MultiRenderTarget = 6,
  35465. /**
  35466. * Texture data comes from a cube data file
  35467. */
  35468. Cube = 7,
  35469. /**
  35470. * Texture data comes from a raw cube data
  35471. */
  35472. CubeRaw = 8,
  35473. /**
  35474. * Texture data come from a prefiltered cube data file
  35475. */
  35476. CubePrefiltered = 9,
  35477. /**
  35478. * Texture content is raw 3D data
  35479. */
  35480. Raw3D = 10,
  35481. /**
  35482. * Texture content is raw 2D array data
  35483. */
  35484. Raw2DArray = 11,
  35485. /**
  35486. * Texture content is a depth texture
  35487. */
  35488. Depth = 12,
  35489. /**
  35490. * Texture data comes from a raw cube data encoded with RGBD
  35491. */
  35492. CubeRawRGBD = 13
  35493. }
  35494. /**
  35495. * Class used to store data associated with WebGL texture data for the engine
  35496. * This class should not be used directly
  35497. */
  35498. export class InternalTexture {
  35499. /** @hidden */
  35500. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35501. /**
  35502. * Defines if the texture is ready
  35503. */
  35504. isReady: boolean;
  35505. /**
  35506. * Defines if the texture is a cube texture
  35507. */
  35508. isCube: boolean;
  35509. /**
  35510. * Defines if the texture contains 3D data
  35511. */
  35512. is3D: boolean;
  35513. /**
  35514. * Defines if the texture contains 2D array data
  35515. */
  35516. is2DArray: boolean;
  35517. /**
  35518. * Defines if the texture contains multiview data
  35519. */
  35520. isMultiview: boolean;
  35521. /**
  35522. * Gets the URL used to load this texture
  35523. */
  35524. url: string;
  35525. /**
  35526. * Gets the sampling mode of the texture
  35527. */
  35528. samplingMode: number;
  35529. /**
  35530. * Gets a boolean indicating if the texture needs mipmaps generation
  35531. */
  35532. generateMipMaps: boolean;
  35533. /**
  35534. * Gets the number of samples used by the texture (WebGL2+ only)
  35535. */
  35536. samples: number;
  35537. /**
  35538. * Gets the type of the texture (int, float...)
  35539. */
  35540. type: number;
  35541. /**
  35542. * Gets the format of the texture (RGB, RGBA...)
  35543. */
  35544. format: number;
  35545. /**
  35546. * Observable called when the texture is loaded
  35547. */
  35548. onLoadedObservable: Observable<InternalTexture>;
  35549. /**
  35550. * Gets the width of the texture
  35551. */
  35552. width: number;
  35553. /**
  35554. * Gets the height of the texture
  35555. */
  35556. height: number;
  35557. /**
  35558. * Gets the depth of the texture
  35559. */
  35560. depth: number;
  35561. /**
  35562. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35563. */
  35564. baseWidth: number;
  35565. /**
  35566. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35567. */
  35568. baseHeight: number;
  35569. /**
  35570. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35571. */
  35572. baseDepth: number;
  35573. /**
  35574. * Gets a boolean indicating if the texture is inverted on Y axis
  35575. */
  35576. invertY: boolean;
  35577. /** @hidden */
  35578. _invertVScale: boolean;
  35579. /** @hidden */
  35580. _associatedChannel: number;
  35581. /** @hidden */
  35582. _source: InternalTextureSource;
  35583. /** @hidden */
  35584. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35585. /** @hidden */
  35586. _bufferView: Nullable<ArrayBufferView>;
  35587. /** @hidden */
  35588. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35589. /** @hidden */
  35590. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35591. /** @hidden */
  35592. _size: number;
  35593. /** @hidden */
  35594. _extension: string;
  35595. /** @hidden */
  35596. _files: Nullable<string[]>;
  35597. /** @hidden */
  35598. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35599. /** @hidden */
  35600. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35601. /** @hidden */
  35602. _framebuffer: Nullable<WebGLFramebuffer>;
  35603. /** @hidden */
  35604. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35605. /** @hidden */
  35606. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35607. /** @hidden */
  35608. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35609. /** @hidden */
  35610. _attachments: Nullable<number[]>;
  35611. /** @hidden */
  35612. _cachedCoordinatesMode: Nullable<number>;
  35613. /** @hidden */
  35614. _cachedWrapU: Nullable<number>;
  35615. /** @hidden */
  35616. _cachedWrapV: Nullable<number>;
  35617. /** @hidden */
  35618. _cachedWrapR: Nullable<number>;
  35619. /** @hidden */
  35620. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35621. /** @hidden */
  35622. _isDisabled: boolean;
  35623. /** @hidden */
  35624. _compression: Nullable<string>;
  35625. /** @hidden */
  35626. _generateStencilBuffer: boolean;
  35627. /** @hidden */
  35628. _generateDepthBuffer: boolean;
  35629. /** @hidden */
  35630. _comparisonFunction: number;
  35631. /** @hidden */
  35632. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35633. /** @hidden */
  35634. _lodGenerationScale: number;
  35635. /** @hidden */
  35636. _lodGenerationOffset: number;
  35637. /** @hidden */
  35638. _depthStencilTexture: Nullable<InternalTexture>;
  35639. /** @hidden */
  35640. _colorTextureArray: Nullable<WebGLTexture>;
  35641. /** @hidden */
  35642. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35643. /** @hidden */
  35644. _lodTextureHigh: Nullable<BaseTexture>;
  35645. /** @hidden */
  35646. _lodTextureMid: Nullable<BaseTexture>;
  35647. /** @hidden */
  35648. _lodTextureLow: Nullable<BaseTexture>;
  35649. /** @hidden */
  35650. _isRGBD: boolean;
  35651. /** @hidden */
  35652. _linearSpecularLOD: boolean;
  35653. /** @hidden */
  35654. _irradianceTexture: Nullable<BaseTexture>;
  35655. /** @hidden */
  35656. _webGLTexture: Nullable<WebGLTexture>;
  35657. /** @hidden */
  35658. _references: number;
  35659. private _engine;
  35660. /**
  35661. * Gets the Engine the texture belongs to.
  35662. * @returns The babylon engine
  35663. */
  35664. getEngine(): ThinEngine;
  35665. /**
  35666. * Gets the data source type of the texture
  35667. */
  35668. get source(): InternalTextureSource;
  35669. /**
  35670. * Creates a new InternalTexture
  35671. * @param engine defines the engine to use
  35672. * @param source defines the type of data that will be used
  35673. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35674. */
  35675. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35676. /**
  35677. * Increments the number of references (ie. the number of Texture that point to it)
  35678. */
  35679. incrementReferences(): void;
  35680. /**
  35681. * Change the size of the texture (not the size of the content)
  35682. * @param width defines the new width
  35683. * @param height defines the new height
  35684. * @param depth defines the new depth (1 by default)
  35685. */
  35686. updateSize(width: int, height: int, depth?: int): void;
  35687. /** @hidden */
  35688. _rebuild(): void;
  35689. /** @hidden */
  35690. _swapAndDie(target: InternalTexture): void;
  35691. /**
  35692. * Dispose the current allocated resources
  35693. */
  35694. dispose(): void;
  35695. }
  35696. }
  35697. declare module BABYLON {
  35698. /**
  35699. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35701. */
  35702. export class Analyser {
  35703. /**
  35704. * Gets or sets the smoothing
  35705. * @ignorenaming
  35706. */
  35707. SMOOTHING: number;
  35708. /**
  35709. * Gets or sets the FFT table size
  35710. * @ignorenaming
  35711. */
  35712. FFT_SIZE: number;
  35713. /**
  35714. * Gets or sets the bar graph amplitude
  35715. * @ignorenaming
  35716. */
  35717. BARGRAPHAMPLITUDE: number;
  35718. /**
  35719. * Gets or sets the position of the debug canvas
  35720. * @ignorenaming
  35721. */
  35722. DEBUGCANVASPOS: {
  35723. x: number;
  35724. y: number;
  35725. };
  35726. /**
  35727. * Gets or sets the debug canvas size
  35728. * @ignorenaming
  35729. */
  35730. DEBUGCANVASSIZE: {
  35731. width: number;
  35732. height: number;
  35733. };
  35734. private _byteFreqs;
  35735. private _byteTime;
  35736. private _floatFreqs;
  35737. private _webAudioAnalyser;
  35738. private _debugCanvas;
  35739. private _debugCanvasContext;
  35740. private _scene;
  35741. private _registerFunc;
  35742. private _audioEngine;
  35743. /**
  35744. * Creates a new analyser
  35745. * @param scene defines hosting scene
  35746. */
  35747. constructor(scene: Scene);
  35748. /**
  35749. * Get the number of data values you will have to play with for the visualization
  35750. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35751. * @returns a number
  35752. */
  35753. getFrequencyBinCount(): number;
  35754. /**
  35755. * Gets the current frequency data as a byte array
  35756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35757. * @returns a Uint8Array
  35758. */
  35759. getByteFrequencyData(): Uint8Array;
  35760. /**
  35761. * Gets the current waveform as a byte array
  35762. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35763. * @returns a Uint8Array
  35764. */
  35765. getByteTimeDomainData(): Uint8Array;
  35766. /**
  35767. * Gets the current frequency data as a float array
  35768. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35769. * @returns a Float32Array
  35770. */
  35771. getFloatFrequencyData(): Float32Array;
  35772. /**
  35773. * Renders the debug canvas
  35774. */
  35775. drawDebugCanvas(): void;
  35776. /**
  35777. * Stops rendering the debug canvas and removes it
  35778. */
  35779. stopDebugCanvas(): void;
  35780. /**
  35781. * Connects two audio nodes
  35782. * @param inputAudioNode defines first node to connect
  35783. * @param outputAudioNode defines second node to connect
  35784. */
  35785. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35786. /**
  35787. * Releases all associated resources
  35788. */
  35789. dispose(): void;
  35790. }
  35791. }
  35792. declare module BABYLON {
  35793. /**
  35794. * This represents an audio engine and it is responsible
  35795. * to play, synchronize and analyse sounds throughout the application.
  35796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35797. */
  35798. export interface IAudioEngine extends IDisposable {
  35799. /**
  35800. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35801. */
  35802. readonly canUseWebAudio: boolean;
  35803. /**
  35804. * Gets the current AudioContext if available.
  35805. */
  35806. readonly audioContext: Nullable<AudioContext>;
  35807. /**
  35808. * The master gain node defines the global audio volume of your audio engine.
  35809. */
  35810. readonly masterGain: GainNode;
  35811. /**
  35812. * Gets whether or not mp3 are supported by your browser.
  35813. */
  35814. readonly isMP3supported: boolean;
  35815. /**
  35816. * Gets whether or not ogg are supported by your browser.
  35817. */
  35818. readonly isOGGsupported: boolean;
  35819. /**
  35820. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35821. * @ignoreNaming
  35822. */
  35823. WarnedWebAudioUnsupported: boolean;
  35824. /**
  35825. * Defines if the audio engine relies on a custom unlocked button.
  35826. * In this case, the embedded button will not be displayed.
  35827. */
  35828. useCustomUnlockedButton: boolean;
  35829. /**
  35830. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35831. */
  35832. readonly unlocked: boolean;
  35833. /**
  35834. * Event raised when audio has been unlocked on the browser.
  35835. */
  35836. onAudioUnlockedObservable: Observable<AudioEngine>;
  35837. /**
  35838. * Event raised when audio has been locked on the browser.
  35839. */
  35840. onAudioLockedObservable: Observable<AudioEngine>;
  35841. /**
  35842. * Flags the audio engine in Locked state.
  35843. * This happens due to new browser policies preventing audio to autoplay.
  35844. */
  35845. lock(): void;
  35846. /**
  35847. * Unlocks the audio engine once a user action has been done on the dom.
  35848. * This is helpful to resume play once browser policies have been satisfied.
  35849. */
  35850. unlock(): void;
  35851. /**
  35852. * Gets the global volume sets on the master gain.
  35853. * @returns the global volume if set or -1 otherwise
  35854. */
  35855. getGlobalVolume(): number;
  35856. /**
  35857. * Sets the global volume of your experience (sets on the master gain).
  35858. * @param newVolume Defines the new global volume of the application
  35859. */
  35860. setGlobalVolume(newVolume: number): void;
  35861. /**
  35862. * Connect the audio engine to an audio analyser allowing some amazing
  35863. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35865. * @param analyser The analyser to connect to the engine
  35866. */
  35867. connectToAnalyser(analyser: Analyser): void;
  35868. }
  35869. /**
  35870. * This represents the default audio engine used in babylon.
  35871. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35873. */
  35874. export class AudioEngine implements IAudioEngine {
  35875. private _audioContext;
  35876. private _audioContextInitialized;
  35877. private _muteButton;
  35878. private _hostElement;
  35879. /**
  35880. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35881. */
  35882. canUseWebAudio: boolean;
  35883. /**
  35884. * The master gain node defines the global audio volume of your audio engine.
  35885. */
  35886. masterGain: GainNode;
  35887. /**
  35888. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35889. * @ignoreNaming
  35890. */
  35891. WarnedWebAudioUnsupported: boolean;
  35892. /**
  35893. * Gets whether or not mp3 are supported by your browser.
  35894. */
  35895. isMP3supported: boolean;
  35896. /**
  35897. * Gets whether or not ogg are supported by your browser.
  35898. */
  35899. isOGGsupported: boolean;
  35900. /**
  35901. * Gets whether audio has been unlocked on the device.
  35902. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35903. * a user interaction has happened.
  35904. */
  35905. unlocked: boolean;
  35906. /**
  35907. * Defines if the audio engine relies on a custom unlocked button.
  35908. * In this case, the embedded button will not be displayed.
  35909. */
  35910. useCustomUnlockedButton: boolean;
  35911. /**
  35912. * Event raised when audio has been unlocked on the browser.
  35913. */
  35914. onAudioUnlockedObservable: Observable<AudioEngine>;
  35915. /**
  35916. * Event raised when audio has been locked on the browser.
  35917. */
  35918. onAudioLockedObservable: Observable<AudioEngine>;
  35919. /**
  35920. * Gets the current AudioContext if available.
  35921. */
  35922. get audioContext(): Nullable<AudioContext>;
  35923. private _connectedAnalyser;
  35924. /**
  35925. * Instantiates a new audio engine.
  35926. *
  35927. * There should be only one per page as some browsers restrict the number
  35928. * of audio contexts you can create.
  35929. * @param hostElement defines the host element where to display the mute icon if necessary
  35930. */
  35931. constructor(hostElement?: Nullable<HTMLElement>);
  35932. /**
  35933. * Flags the audio engine in Locked state.
  35934. * This happens due to new browser policies preventing audio to autoplay.
  35935. */
  35936. lock(): void;
  35937. /**
  35938. * Unlocks the audio engine once a user action has been done on the dom.
  35939. * This is helpful to resume play once browser policies have been satisfied.
  35940. */
  35941. unlock(): void;
  35942. private _resumeAudioContext;
  35943. private _initializeAudioContext;
  35944. private _tryToRun;
  35945. private _triggerRunningState;
  35946. private _triggerSuspendedState;
  35947. private _displayMuteButton;
  35948. private _moveButtonToTopLeft;
  35949. private _onResize;
  35950. private _hideMuteButton;
  35951. /**
  35952. * Destroy and release the resources associated with the audio ccontext.
  35953. */
  35954. dispose(): void;
  35955. /**
  35956. * Gets the global volume sets on the master gain.
  35957. * @returns the global volume if set or -1 otherwise
  35958. */
  35959. getGlobalVolume(): number;
  35960. /**
  35961. * Sets the global volume of your experience (sets on the master gain).
  35962. * @param newVolume Defines the new global volume of the application
  35963. */
  35964. setGlobalVolume(newVolume: number): void;
  35965. /**
  35966. * Connect the audio engine to an audio analyser allowing some amazing
  35967. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35969. * @param analyser The analyser to connect to the engine
  35970. */
  35971. connectToAnalyser(analyser: Analyser): void;
  35972. }
  35973. }
  35974. declare module BABYLON {
  35975. /**
  35976. * Interface used to present a loading screen while loading a scene
  35977. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35978. */
  35979. export interface ILoadingScreen {
  35980. /**
  35981. * Function called to display the loading screen
  35982. */
  35983. displayLoadingUI: () => void;
  35984. /**
  35985. * Function called to hide the loading screen
  35986. */
  35987. hideLoadingUI: () => void;
  35988. /**
  35989. * Gets or sets the color to use for the background
  35990. */
  35991. loadingUIBackgroundColor: string;
  35992. /**
  35993. * Gets or sets the text to display while loading
  35994. */
  35995. loadingUIText: string;
  35996. }
  35997. /**
  35998. * Class used for the default loading screen
  35999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36000. */
  36001. export class DefaultLoadingScreen implements ILoadingScreen {
  36002. private _renderingCanvas;
  36003. private _loadingText;
  36004. private _loadingDivBackgroundColor;
  36005. private _loadingDiv;
  36006. private _loadingTextDiv;
  36007. /** Gets or sets the logo url to use for the default loading screen */
  36008. static DefaultLogoUrl: string;
  36009. /** Gets or sets the spinner url to use for the default loading screen */
  36010. static DefaultSpinnerUrl: string;
  36011. /**
  36012. * Creates a new default loading screen
  36013. * @param _renderingCanvas defines the canvas used to render the scene
  36014. * @param _loadingText defines the default text to display
  36015. * @param _loadingDivBackgroundColor defines the default background color
  36016. */
  36017. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36018. /**
  36019. * Function called to display the loading screen
  36020. */
  36021. displayLoadingUI(): void;
  36022. /**
  36023. * Function called to hide the loading screen
  36024. */
  36025. hideLoadingUI(): void;
  36026. /**
  36027. * Gets or sets the text to display while loading
  36028. */
  36029. set loadingUIText(text: string);
  36030. get loadingUIText(): string;
  36031. /**
  36032. * Gets or sets the color to use for the background
  36033. */
  36034. get loadingUIBackgroundColor(): string;
  36035. set loadingUIBackgroundColor(color: string);
  36036. private _resizeLoadingUI;
  36037. }
  36038. }
  36039. declare module BABYLON {
  36040. /**
  36041. * Interface for any object that can request an animation frame
  36042. */
  36043. export interface ICustomAnimationFrameRequester {
  36044. /**
  36045. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36046. */
  36047. renderFunction?: Function;
  36048. /**
  36049. * Called to request the next frame to render to
  36050. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36051. */
  36052. requestAnimationFrame: Function;
  36053. /**
  36054. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36055. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36056. */
  36057. requestID?: number;
  36058. }
  36059. }
  36060. declare module BABYLON {
  36061. /**
  36062. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36063. */
  36064. export class PerformanceMonitor {
  36065. private _enabled;
  36066. private _rollingFrameTime;
  36067. private _lastFrameTimeMs;
  36068. /**
  36069. * constructor
  36070. * @param frameSampleSize The number of samples required to saturate the sliding window
  36071. */
  36072. constructor(frameSampleSize?: number);
  36073. /**
  36074. * Samples current frame
  36075. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36076. */
  36077. sampleFrame(timeMs?: number): void;
  36078. /**
  36079. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36080. */
  36081. get averageFrameTime(): number;
  36082. /**
  36083. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36084. */
  36085. get averageFrameTimeVariance(): number;
  36086. /**
  36087. * Returns the frame time of the most recent frame
  36088. */
  36089. get instantaneousFrameTime(): number;
  36090. /**
  36091. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36092. */
  36093. get averageFPS(): number;
  36094. /**
  36095. * Returns the average framerate in frames per second using the most recent frame time
  36096. */
  36097. get instantaneousFPS(): number;
  36098. /**
  36099. * Returns true if enough samples have been taken to completely fill the sliding window
  36100. */
  36101. get isSaturated(): boolean;
  36102. /**
  36103. * Enables contributions to the sliding window sample set
  36104. */
  36105. enable(): void;
  36106. /**
  36107. * Disables contributions to the sliding window sample set
  36108. * Samples will not be interpolated over the disabled period
  36109. */
  36110. disable(): void;
  36111. /**
  36112. * Returns true if sampling is enabled
  36113. */
  36114. get isEnabled(): boolean;
  36115. /**
  36116. * Resets performance monitor
  36117. */
  36118. reset(): void;
  36119. }
  36120. /**
  36121. * RollingAverage
  36122. *
  36123. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36124. */
  36125. export class RollingAverage {
  36126. /**
  36127. * Current average
  36128. */
  36129. average: number;
  36130. /**
  36131. * Current variance
  36132. */
  36133. variance: number;
  36134. protected _samples: Array<number>;
  36135. protected _sampleCount: number;
  36136. protected _pos: number;
  36137. protected _m2: number;
  36138. /**
  36139. * constructor
  36140. * @param length The number of samples required to saturate the sliding window
  36141. */
  36142. constructor(length: number);
  36143. /**
  36144. * Adds a sample to the sample set
  36145. * @param v The sample value
  36146. */
  36147. add(v: number): void;
  36148. /**
  36149. * Returns previously added values or null if outside of history or outside the sliding window domain
  36150. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36151. * @return Value previously recorded with add() or null if outside of range
  36152. */
  36153. history(i: number): number;
  36154. /**
  36155. * Returns true if enough samples have been taken to completely fill the sliding window
  36156. * @return true if sample-set saturated
  36157. */
  36158. isSaturated(): boolean;
  36159. /**
  36160. * Resets the rolling average (equivalent to 0 samples taken so far)
  36161. */
  36162. reset(): void;
  36163. /**
  36164. * Wraps a value around the sample range boundaries
  36165. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36166. * @return Wrapped position in sample range
  36167. */
  36168. protected _wrapPosition(i: number): number;
  36169. }
  36170. }
  36171. declare module BABYLON {
  36172. /**
  36173. * This class is used to track a performance counter which is number based.
  36174. * The user has access to many properties which give statistics of different nature.
  36175. *
  36176. * The implementer can track two kinds of Performance Counter: time and count.
  36177. * 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.
  36178. * 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.
  36179. */
  36180. export class PerfCounter {
  36181. /**
  36182. * Gets or sets a global boolean to turn on and off all the counters
  36183. */
  36184. static Enabled: boolean;
  36185. /**
  36186. * Returns the smallest value ever
  36187. */
  36188. get min(): number;
  36189. /**
  36190. * Returns the biggest value ever
  36191. */
  36192. get max(): number;
  36193. /**
  36194. * Returns the average value since the performance counter is running
  36195. */
  36196. get average(): number;
  36197. /**
  36198. * Returns the average value of the last second the counter was monitored
  36199. */
  36200. get lastSecAverage(): number;
  36201. /**
  36202. * Returns the current value
  36203. */
  36204. get current(): number;
  36205. /**
  36206. * Gets the accumulated total
  36207. */
  36208. get total(): number;
  36209. /**
  36210. * Gets the total value count
  36211. */
  36212. get count(): number;
  36213. /**
  36214. * Creates a new counter
  36215. */
  36216. constructor();
  36217. /**
  36218. * Call this method to start monitoring a new frame.
  36219. * 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.
  36220. */
  36221. fetchNewFrame(): void;
  36222. /**
  36223. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36224. * @param newCount the count value to add to the monitored count
  36225. * @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.
  36226. */
  36227. addCount(newCount: number, fetchResult: boolean): void;
  36228. /**
  36229. * Start monitoring this performance counter
  36230. */
  36231. beginMonitoring(): void;
  36232. /**
  36233. * Compute the time lapsed since the previous beginMonitoring() call.
  36234. * @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
  36235. */
  36236. endMonitoring(newFrame?: boolean): void;
  36237. private _fetchResult;
  36238. private _startMonitoringTime;
  36239. private _min;
  36240. private _max;
  36241. private _average;
  36242. private _current;
  36243. private _totalValueCount;
  36244. private _totalAccumulated;
  36245. private _lastSecAverage;
  36246. private _lastSecAccumulated;
  36247. private _lastSecTime;
  36248. private _lastSecValueCount;
  36249. }
  36250. }
  36251. declare module BABYLON {
  36252. interface ThinEngine {
  36253. /**
  36254. * Sets alpha constants used by some alpha blending modes
  36255. * @param r defines the red component
  36256. * @param g defines the green component
  36257. * @param b defines the blue component
  36258. * @param a defines the alpha component
  36259. */
  36260. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36261. /**
  36262. * Sets the current alpha mode
  36263. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36264. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36265. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36266. */
  36267. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36268. /**
  36269. * Gets the current alpha mode
  36270. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36271. * @returns the current alpha mode
  36272. */
  36273. getAlphaMode(): number;
  36274. /**
  36275. * Sets the current alpha equation
  36276. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36277. */
  36278. setAlphaEquation(equation: number): void;
  36279. /**
  36280. * Gets the current alpha equation.
  36281. * @returns the current alpha equation
  36282. */
  36283. getAlphaEquation(): number;
  36284. }
  36285. }
  36286. declare module BABYLON {
  36287. interface ThinEngine {
  36288. /** @hidden */
  36289. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36290. }
  36291. }
  36292. declare module BABYLON {
  36293. /**
  36294. * Defines the interface used by display changed events
  36295. */
  36296. export interface IDisplayChangedEventArgs {
  36297. /** Gets the vrDisplay object (if any) */
  36298. vrDisplay: Nullable<any>;
  36299. /** Gets a boolean indicating if webVR is supported */
  36300. vrSupported: boolean;
  36301. }
  36302. /**
  36303. * Defines the interface used by objects containing a viewport (like a camera)
  36304. */
  36305. interface IViewportOwnerLike {
  36306. /**
  36307. * Gets or sets the viewport
  36308. */
  36309. viewport: IViewportLike;
  36310. }
  36311. /**
  36312. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36313. */
  36314. export class Engine extends ThinEngine {
  36315. /** Defines that alpha blending is disabled */
  36316. static readonly ALPHA_DISABLE: number;
  36317. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36318. static readonly ALPHA_ADD: number;
  36319. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36320. static readonly ALPHA_COMBINE: number;
  36321. /** Defines that alpha blending to DEST - SRC * DEST */
  36322. static readonly ALPHA_SUBTRACT: number;
  36323. /** Defines that alpha blending to SRC * DEST */
  36324. static readonly ALPHA_MULTIPLY: number;
  36325. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36326. static readonly ALPHA_MAXIMIZED: number;
  36327. /** Defines that alpha blending to SRC + DEST */
  36328. static readonly ALPHA_ONEONE: number;
  36329. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36330. static readonly ALPHA_PREMULTIPLIED: number;
  36331. /**
  36332. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36333. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36334. */
  36335. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36336. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36337. static readonly ALPHA_INTERPOLATE: number;
  36338. /**
  36339. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36340. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36341. */
  36342. static readonly ALPHA_SCREENMODE: number;
  36343. /** Defines that the ressource is not delayed*/
  36344. static readonly DELAYLOADSTATE_NONE: number;
  36345. /** Defines that the ressource was successfully delay loaded */
  36346. static readonly DELAYLOADSTATE_LOADED: number;
  36347. /** Defines that the ressource is currently delay loading */
  36348. static readonly DELAYLOADSTATE_LOADING: number;
  36349. /** Defines that the ressource is delayed and has not started loading */
  36350. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36351. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36352. static readonly NEVER: number;
  36353. /** 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 */
  36354. static readonly ALWAYS: number;
  36355. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36356. static readonly LESS: number;
  36357. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36358. static readonly EQUAL: number;
  36359. /** 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 */
  36360. static readonly LEQUAL: number;
  36361. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36362. static readonly GREATER: number;
  36363. /** 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 */
  36364. static readonly GEQUAL: number;
  36365. /** 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 */
  36366. static readonly NOTEQUAL: number;
  36367. /** Passed to stencilOperation to specify that stencil value must be kept */
  36368. static readonly KEEP: number;
  36369. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36370. static readonly REPLACE: number;
  36371. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36372. static readonly INCR: number;
  36373. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36374. static readonly DECR: number;
  36375. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36376. static readonly INVERT: number;
  36377. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36378. static readonly INCR_WRAP: number;
  36379. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36380. static readonly DECR_WRAP: number;
  36381. /** Texture is not repeating outside of 0..1 UVs */
  36382. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36383. /** Texture is repeating outside of 0..1 UVs */
  36384. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36385. /** Texture is repeating and mirrored */
  36386. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36387. /** ALPHA */
  36388. static readonly TEXTUREFORMAT_ALPHA: number;
  36389. /** LUMINANCE */
  36390. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36391. /** LUMINANCE_ALPHA */
  36392. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36393. /** RGB */
  36394. static readonly TEXTUREFORMAT_RGB: number;
  36395. /** RGBA */
  36396. static readonly TEXTUREFORMAT_RGBA: number;
  36397. /** RED */
  36398. static readonly TEXTUREFORMAT_RED: number;
  36399. /** RED (2nd reference) */
  36400. static readonly TEXTUREFORMAT_R: number;
  36401. /** RG */
  36402. static readonly TEXTUREFORMAT_RG: number;
  36403. /** RED_INTEGER */
  36404. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36405. /** RED_INTEGER (2nd reference) */
  36406. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36407. /** RG_INTEGER */
  36408. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36409. /** RGB_INTEGER */
  36410. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36411. /** RGBA_INTEGER */
  36412. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36413. /** UNSIGNED_BYTE */
  36414. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36415. /** UNSIGNED_BYTE (2nd reference) */
  36416. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36417. /** FLOAT */
  36418. static readonly TEXTURETYPE_FLOAT: number;
  36419. /** HALF_FLOAT */
  36420. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36421. /** BYTE */
  36422. static readonly TEXTURETYPE_BYTE: number;
  36423. /** SHORT */
  36424. static readonly TEXTURETYPE_SHORT: number;
  36425. /** UNSIGNED_SHORT */
  36426. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36427. /** INT */
  36428. static readonly TEXTURETYPE_INT: number;
  36429. /** UNSIGNED_INT */
  36430. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36431. /** UNSIGNED_SHORT_4_4_4_4 */
  36432. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36433. /** UNSIGNED_SHORT_5_5_5_1 */
  36434. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36435. /** UNSIGNED_SHORT_5_6_5 */
  36436. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36437. /** UNSIGNED_INT_2_10_10_10_REV */
  36438. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36439. /** UNSIGNED_INT_24_8 */
  36440. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36441. /** UNSIGNED_INT_10F_11F_11F_REV */
  36442. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36443. /** UNSIGNED_INT_5_9_9_9_REV */
  36444. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36445. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36446. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36447. /** nearest is mag = nearest and min = nearest and mip = linear */
  36448. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36449. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36450. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36451. /** Trilinear is mag = linear and min = linear and mip = linear */
  36452. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36453. /** nearest is mag = nearest and min = nearest and mip = linear */
  36454. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36455. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36456. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36457. /** Trilinear is mag = linear and min = linear and mip = linear */
  36458. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36459. /** mag = nearest and min = nearest and mip = nearest */
  36460. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36461. /** mag = nearest and min = linear and mip = nearest */
  36462. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36463. /** mag = nearest and min = linear and mip = linear */
  36464. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36465. /** mag = nearest and min = linear and mip = none */
  36466. static readonly TEXTURE_NEAREST_LINEAR: number;
  36467. /** mag = nearest and min = nearest and mip = none */
  36468. static readonly TEXTURE_NEAREST_NEAREST: number;
  36469. /** mag = linear and min = nearest and mip = nearest */
  36470. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36471. /** mag = linear and min = nearest and mip = linear */
  36472. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36473. /** mag = linear and min = linear and mip = none */
  36474. static readonly TEXTURE_LINEAR_LINEAR: number;
  36475. /** mag = linear and min = nearest and mip = none */
  36476. static readonly TEXTURE_LINEAR_NEAREST: number;
  36477. /** Explicit coordinates mode */
  36478. static readonly TEXTURE_EXPLICIT_MODE: number;
  36479. /** Spherical coordinates mode */
  36480. static readonly TEXTURE_SPHERICAL_MODE: number;
  36481. /** Planar coordinates mode */
  36482. static readonly TEXTURE_PLANAR_MODE: number;
  36483. /** Cubic coordinates mode */
  36484. static readonly TEXTURE_CUBIC_MODE: number;
  36485. /** Projection coordinates mode */
  36486. static readonly TEXTURE_PROJECTION_MODE: number;
  36487. /** Skybox coordinates mode */
  36488. static readonly TEXTURE_SKYBOX_MODE: number;
  36489. /** Inverse Cubic coordinates mode */
  36490. static readonly TEXTURE_INVCUBIC_MODE: number;
  36491. /** Equirectangular coordinates mode */
  36492. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36493. /** Equirectangular Fixed coordinates mode */
  36494. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36495. /** Equirectangular Fixed Mirrored coordinates mode */
  36496. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36497. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36498. static readonly SCALEMODE_FLOOR: number;
  36499. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36500. static readonly SCALEMODE_NEAREST: number;
  36501. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36502. static readonly SCALEMODE_CEILING: number;
  36503. /**
  36504. * Returns the current npm package of the sdk
  36505. */
  36506. static get NpmPackage(): string;
  36507. /**
  36508. * Returns the current version of the framework
  36509. */
  36510. static get Version(): string;
  36511. /** Gets the list of created engines */
  36512. static get Instances(): Engine[];
  36513. /**
  36514. * Gets the latest created engine
  36515. */
  36516. static get LastCreatedEngine(): Nullable<Engine>;
  36517. /**
  36518. * Gets the latest created scene
  36519. */
  36520. static get LastCreatedScene(): Nullable<Scene>;
  36521. /**
  36522. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36523. * @param flag defines which part of the materials must be marked as dirty
  36524. * @param predicate defines a predicate used to filter which materials should be affected
  36525. */
  36526. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36527. /**
  36528. * Method called to create the default loading screen.
  36529. * This can be overriden in your own app.
  36530. * @param canvas The rendering canvas element
  36531. * @returns The loading screen
  36532. */
  36533. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36534. /**
  36535. * Method called to create the default rescale post process on each engine.
  36536. */
  36537. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36538. /**
  36539. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36540. **/
  36541. enableOfflineSupport: boolean;
  36542. /**
  36543. * 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)
  36544. **/
  36545. disableManifestCheck: boolean;
  36546. /**
  36547. * Gets the list of created scenes
  36548. */
  36549. scenes: Scene[];
  36550. /**
  36551. * Event raised when a new scene is created
  36552. */
  36553. onNewSceneAddedObservable: Observable<Scene>;
  36554. /**
  36555. * Gets the list of created postprocesses
  36556. */
  36557. postProcesses: PostProcess[];
  36558. /**
  36559. * Gets a boolean indicating if the pointer is currently locked
  36560. */
  36561. isPointerLock: boolean;
  36562. /**
  36563. * Observable event triggered each time the rendering canvas is resized
  36564. */
  36565. onResizeObservable: Observable<Engine>;
  36566. /**
  36567. * Observable event triggered each time the canvas loses focus
  36568. */
  36569. onCanvasBlurObservable: Observable<Engine>;
  36570. /**
  36571. * Observable event triggered each time the canvas gains focus
  36572. */
  36573. onCanvasFocusObservable: Observable<Engine>;
  36574. /**
  36575. * Observable event triggered each time the canvas receives pointerout event
  36576. */
  36577. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36578. /**
  36579. * Observable raised when the engine begins a new frame
  36580. */
  36581. onBeginFrameObservable: Observable<Engine>;
  36582. /**
  36583. * If set, will be used to request the next animation frame for the render loop
  36584. */
  36585. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36586. /**
  36587. * Observable raised when the engine ends the current frame
  36588. */
  36589. onEndFrameObservable: Observable<Engine>;
  36590. /**
  36591. * Observable raised when the engine is about to compile a shader
  36592. */
  36593. onBeforeShaderCompilationObservable: Observable<Engine>;
  36594. /**
  36595. * Observable raised when the engine has jsut compiled a shader
  36596. */
  36597. onAfterShaderCompilationObservable: Observable<Engine>;
  36598. /**
  36599. * Gets the audio engine
  36600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36601. * @ignorenaming
  36602. */
  36603. static audioEngine: IAudioEngine;
  36604. /**
  36605. * Default AudioEngine factory responsible of creating the Audio Engine.
  36606. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36607. */
  36608. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36609. /**
  36610. * Default offline support factory responsible of creating a tool used to store data locally.
  36611. * By default, this will create a Database object if the workload has been embedded.
  36612. */
  36613. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36614. private _loadingScreen;
  36615. private _pointerLockRequested;
  36616. private _rescalePostProcess;
  36617. private _deterministicLockstep;
  36618. private _lockstepMaxSteps;
  36619. private _timeStep;
  36620. protected get _supportsHardwareTextureRescaling(): boolean;
  36621. private _fps;
  36622. private _deltaTime;
  36623. /** @hidden */
  36624. _drawCalls: PerfCounter;
  36625. /** 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 */
  36626. canvasTabIndex: number;
  36627. /**
  36628. * Turn this value on if you want to pause FPS computation when in background
  36629. */
  36630. disablePerformanceMonitorInBackground: boolean;
  36631. private _performanceMonitor;
  36632. /**
  36633. * Gets the performance monitor attached to this engine
  36634. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36635. */
  36636. get performanceMonitor(): PerformanceMonitor;
  36637. private _onFocus;
  36638. private _onBlur;
  36639. private _onCanvasPointerOut;
  36640. private _onCanvasBlur;
  36641. private _onCanvasFocus;
  36642. private _onFullscreenChange;
  36643. private _onPointerLockChange;
  36644. /**
  36645. * Gets the HTML element used to attach event listeners
  36646. * @returns a HTML element
  36647. */
  36648. getInputElement(): Nullable<HTMLElement>;
  36649. /**
  36650. * Creates a new engine
  36651. * @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
  36652. * @param antialias defines enable antialiasing (default: false)
  36653. * @param options defines further options to be sent to the getContext() function
  36654. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36655. */
  36656. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36657. /**
  36658. * Gets current aspect ratio
  36659. * @param viewportOwner defines the camera to use to get the aspect ratio
  36660. * @param useScreen defines if screen size must be used (or the current render target if any)
  36661. * @returns a number defining the aspect ratio
  36662. */
  36663. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36664. /**
  36665. * Gets current screen aspect ratio
  36666. * @returns a number defining the aspect ratio
  36667. */
  36668. getScreenAspectRatio(): number;
  36669. /**
  36670. * Gets the client rect of the HTML canvas attached with the current webGL context
  36671. * @returns a client rectanglee
  36672. */
  36673. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36674. /**
  36675. * Gets the client rect of the HTML element used for events
  36676. * @returns a client rectanglee
  36677. */
  36678. getInputElementClientRect(): Nullable<ClientRect>;
  36679. /**
  36680. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36681. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36682. * @returns true if engine is in deterministic lock step mode
  36683. */
  36684. isDeterministicLockStep(): boolean;
  36685. /**
  36686. * Gets the max steps when engine is running in deterministic lock step
  36687. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36688. * @returns the max steps
  36689. */
  36690. getLockstepMaxSteps(): number;
  36691. /**
  36692. * Returns the time in ms between steps when using deterministic lock step.
  36693. * @returns time step in (ms)
  36694. */
  36695. getTimeStep(): number;
  36696. /**
  36697. * Force the mipmap generation for the given render target texture
  36698. * @param texture defines the render target texture to use
  36699. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36700. */
  36701. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36702. /** States */
  36703. /**
  36704. * Set various states to the webGL context
  36705. * @param culling defines backface culling state
  36706. * @param zOffset defines the value to apply to zOffset (0 by default)
  36707. * @param force defines if states must be applied even if cache is up to date
  36708. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36709. */
  36710. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36711. /**
  36712. * Set the z offset to apply to current rendering
  36713. * @param value defines the offset to apply
  36714. */
  36715. setZOffset(value: number): void;
  36716. /**
  36717. * Gets the current value of the zOffset
  36718. * @returns the current zOffset state
  36719. */
  36720. getZOffset(): number;
  36721. /**
  36722. * Enable or disable depth buffering
  36723. * @param enable defines the state to set
  36724. */
  36725. setDepthBuffer(enable: boolean): void;
  36726. /**
  36727. * Gets a boolean indicating if depth writing is enabled
  36728. * @returns the current depth writing state
  36729. */
  36730. getDepthWrite(): boolean;
  36731. /**
  36732. * Enable or disable depth writing
  36733. * @param enable defines the state to set
  36734. */
  36735. setDepthWrite(enable: boolean): void;
  36736. /**
  36737. * Gets a boolean indicating if stencil buffer is enabled
  36738. * @returns the current stencil buffer state
  36739. */
  36740. getStencilBuffer(): boolean;
  36741. /**
  36742. * Enable or disable the stencil buffer
  36743. * @param enable defines if the stencil buffer must be enabled or disabled
  36744. */
  36745. setStencilBuffer(enable: boolean): void;
  36746. /**
  36747. * Gets the current stencil mask
  36748. * @returns a number defining the new stencil mask to use
  36749. */
  36750. getStencilMask(): number;
  36751. /**
  36752. * Sets the current stencil mask
  36753. * @param mask defines the new stencil mask to use
  36754. */
  36755. setStencilMask(mask: number): void;
  36756. /**
  36757. * Gets the current stencil function
  36758. * @returns a number defining the stencil function to use
  36759. */
  36760. getStencilFunction(): number;
  36761. /**
  36762. * Gets the current stencil reference value
  36763. * @returns a number defining the stencil reference value to use
  36764. */
  36765. getStencilFunctionReference(): number;
  36766. /**
  36767. * Gets the current stencil mask
  36768. * @returns a number defining the stencil mask to use
  36769. */
  36770. getStencilFunctionMask(): number;
  36771. /**
  36772. * Sets the current stencil function
  36773. * @param stencilFunc defines the new stencil function to use
  36774. */
  36775. setStencilFunction(stencilFunc: number): void;
  36776. /**
  36777. * Sets the current stencil reference
  36778. * @param reference defines the new stencil reference to use
  36779. */
  36780. setStencilFunctionReference(reference: number): void;
  36781. /**
  36782. * Sets the current stencil mask
  36783. * @param mask defines the new stencil mask to use
  36784. */
  36785. setStencilFunctionMask(mask: number): void;
  36786. /**
  36787. * Gets the current stencil operation when stencil fails
  36788. * @returns a number defining stencil operation to use when stencil fails
  36789. */
  36790. getStencilOperationFail(): number;
  36791. /**
  36792. * Gets the current stencil operation when depth fails
  36793. * @returns a number defining stencil operation to use when depth fails
  36794. */
  36795. getStencilOperationDepthFail(): number;
  36796. /**
  36797. * Gets the current stencil operation when stencil passes
  36798. * @returns a number defining stencil operation to use when stencil passes
  36799. */
  36800. getStencilOperationPass(): number;
  36801. /**
  36802. * Sets the stencil operation to use when stencil fails
  36803. * @param operation defines the stencil operation to use when stencil fails
  36804. */
  36805. setStencilOperationFail(operation: number): void;
  36806. /**
  36807. * Sets the stencil operation to use when depth fails
  36808. * @param operation defines the stencil operation to use when depth fails
  36809. */
  36810. setStencilOperationDepthFail(operation: number): void;
  36811. /**
  36812. * Sets the stencil operation to use when stencil passes
  36813. * @param operation defines the stencil operation to use when stencil passes
  36814. */
  36815. setStencilOperationPass(operation: number): void;
  36816. /**
  36817. * Sets a boolean indicating if the dithering state is enabled or disabled
  36818. * @param value defines the dithering state
  36819. */
  36820. setDitheringState(value: boolean): void;
  36821. /**
  36822. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36823. * @param value defines the rasterizer state
  36824. */
  36825. setRasterizerState(value: boolean): void;
  36826. /**
  36827. * Gets the current depth function
  36828. * @returns a number defining the depth function
  36829. */
  36830. getDepthFunction(): Nullable<number>;
  36831. /**
  36832. * Sets the current depth function
  36833. * @param depthFunc defines the function to use
  36834. */
  36835. setDepthFunction(depthFunc: number): void;
  36836. /**
  36837. * Sets the current depth function to GREATER
  36838. */
  36839. setDepthFunctionToGreater(): void;
  36840. /**
  36841. * Sets the current depth function to GEQUAL
  36842. */
  36843. setDepthFunctionToGreaterOrEqual(): void;
  36844. /**
  36845. * Sets the current depth function to LESS
  36846. */
  36847. setDepthFunctionToLess(): void;
  36848. /**
  36849. * Sets the current depth function to LEQUAL
  36850. */
  36851. setDepthFunctionToLessOrEqual(): void;
  36852. private _cachedStencilBuffer;
  36853. private _cachedStencilFunction;
  36854. private _cachedStencilMask;
  36855. private _cachedStencilOperationPass;
  36856. private _cachedStencilOperationFail;
  36857. private _cachedStencilOperationDepthFail;
  36858. private _cachedStencilReference;
  36859. /**
  36860. * Caches the the state of the stencil buffer
  36861. */
  36862. cacheStencilState(): void;
  36863. /**
  36864. * Restores the state of the stencil buffer
  36865. */
  36866. restoreStencilState(): void;
  36867. /**
  36868. * Directly set the WebGL Viewport
  36869. * @param x defines the x coordinate of the viewport (in screen space)
  36870. * @param y defines the y coordinate of the viewport (in screen space)
  36871. * @param width defines the width of the viewport (in screen space)
  36872. * @param height defines the height of the viewport (in screen space)
  36873. * @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
  36874. */
  36875. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36876. /**
  36877. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36878. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36879. * @param y defines the y-coordinate of the corner of the clear rectangle
  36880. * @param width defines the width of the clear rectangle
  36881. * @param height defines the height of the clear rectangle
  36882. * @param clearColor defines the clear color
  36883. */
  36884. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36885. /**
  36886. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36887. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36888. * @param y defines the y-coordinate of the corner of the clear rectangle
  36889. * @param width defines the width of the clear rectangle
  36890. * @param height defines the height of the clear rectangle
  36891. */
  36892. enableScissor(x: number, y: number, width: number, height: number): void;
  36893. /**
  36894. * Disable previously set scissor test rectangle
  36895. */
  36896. disableScissor(): void;
  36897. protected _reportDrawCall(): void;
  36898. /**
  36899. * Initializes a webVR display and starts listening to display change events
  36900. * The onVRDisplayChangedObservable will be notified upon these changes
  36901. * @returns The onVRDisplayChangedObservable
  36902. */
  36903. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36904. /** @hidden */
  36905. _prepareVRComponent(): void;
  36906. /** @hidden */
  36907. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36908. /** @hidden */
  36909. _submitVRFrame(): void;
  36910. /**
  36911. * Call this function to leave webVR mode
  36912. * Will do nothing if webVR is not supported or if there is no webVR device
  36913. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36914. */
  36915. disableVR(): void;
  36916. /**
  36917. * Gets a boolean indicating that the system is in VR mode and is presenting
  36918. * @returns true if VR mode is engaged
  36919. */
  36920. isVRPresenting(): boolean;
  36921. /** @hidden */
  36922. _requestVRFrame(): void;
  36923. /** @hidden */
  36924. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36925. /**
  36926. * Gets the source code of the vertex shader associated with a specific webGL program
  36927. * @param program defines the program to use
  36928. * @returns a string containing the source code of the vertex shader associated with the program
  36929. */
  36930. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36931. /**
  36932. * Gets the source code of the fragment shader associated with a specific webGL program
  36933. * @param program defines the program to use
  36934. * @returns a string containing the source code of the fragment shader associated with the program
  36935. */
  36936. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36937. /**
  36938. * Sets a depth stencil texture from a render target to the according uniform.
  36939. * @param channel The texture channel
  36940. * @param uniform The uniform to set
  36941. * @param texture The render target texture containing the depth stencil texture to apply
  36942. */
  36943. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36944. /**
  36945. * Sets a texture to the webGL context from a postprocess
  36946. * @param channel defines the channel to use
  36947. * @param postProcess defines the source postprocess
  36948. */
  36949. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36950. /**
  36951. * Binds the output of the passed in post process to the texture channel specified
  36952. * @param channel The channel the texture should be bound to
  36953. * @param postProcess The post process which's output should be bound
  36954. */
  36955. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36956. protected _rebuildBuffers(): void;
  36957. /** @hidden */
  36958. _renderFrame(): void;
  36959. _renderLoop(): void;
  36960. /** @hidden */
  36961. _renderViews(): boolean;
  36962. /**
  36963. * Toggle full screen mode
  36964. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36965. */
  36966. switchFullscreen(requestPointerLock: boolean): void;
  36967. /**
  36968. * Enters full screen mode
  36969. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36970. */
  36971. enterFullscreen(requestPointerLock: boolean): void;
  36972. /**
  36973. * Exits full screen mode
  36974. */
  36975. exitFullscreen(): void;
  36976. /**
  36977. * Enters Pointerlock mode
  36978. */
  36979. enterPointerlock(): void;
  36980. /**
  36981. * Exits Pointerlock mode
  36982. */
  36983. exitPointerlock(): void;
  36984. /**
  36985. * Begin a new frame
  36986. */
  36987. beginFrame(): void;
  36988. /**
  36989. * Enf the current frame
  36990. */
  36991. endFrame(): void;
  36992. resize(): void;
  36993. /**
  36994. * Force a specific size of the canvas
  36995. * @param width defines the new canvas' width
  36996. * @param height defines the new canvas' height
  36997. */
  36998. setSize(width: number, height: number): void;
  36999. /**
  37000. * Updates a dynamic vertex buffer.
  37001. * @param vertexBuffer the vertex buffer to update
  37002. * @param data the data used to update the vertex buffer
  37003. * @param byteOffset the byte offset of the data
  37004. * @param byteLength the byte length of the data
  37005. */
  37006. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37007. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37008. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37009. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37010. _releaseTexture(texture: InternalTexture): void;
  37011. /**
  37012. * @hidden
  37013. * Rescales a texture
  37014. * @param source input texutre
  37015. * @param destination destination texture
  37016. * @param scene scene to use to render the resize
  37017. * @param internalFormat format to use when resizing
  37018. * @param onComplete callback to be called when resize has completed
  37019. */
  37020. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37021. /**
  37022. * Gets the current framerate
  37023. * @returns a number representing the framerate
  37024. */
  37025. getFps(): number;
  37026. /**
  37027. * Gets the time spent between current and previous frame
  37028. * @returns a number representing the delta time in ms
  37029. */
  37030. getDeltaTime(): number;
  37031. private _measureFps;
  37032. /** @hidden */
  37033. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37034. /**
  37035. * Update a dynamic index buffer
  37036. * @param indexBuffer defines the target index buffer
  37037. * @param indices defines the data to update
  37038. * @param offset defines the offset in the target index buffer where update should start
  37039. */
  37040. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37041. /**
  37042. * Updates the sample count of a render target texture
  37043. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37044. * @param texture defines the texture to update
  37045. * @param samples defines the sample count to set
  37046. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37047. */
  37048. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37049. /**
  37050. * Updates a depth texture Comparison Mode and Function.
  37051. * If the comparison Function is equal to 0, the mode will be set to none.
  37052. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37053. * @param texture The texture to set the comparison function for
  37054. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37055. */
  37056. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37057. /**
  37058. * Creates a webGL buffer to use with instanciation
  37059. * @param capacity defines the size of the buffer
  37060. * @returns the webGL buffer
  37061. */
  37062. createInstancesBuffer(capacity: number): DataBuffer;
  37063. /**
  37064. * Delete a webGL buffer used with instanciation
  37065. * @param buffer defines the webGL buffer to delete
  37066. */
  37067. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37068. private _clientWaitAsync;
  37069. /** @hidden */
  37070. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37071. dispose(): void;
  37072. private _disableTouchAction;
  37073. /**
  37074. * Display the loading screen
  37075. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37076. */
  37077. displayLoadingUI(): void;
  37078. /**
  37079. * Hide the loading screen
  37080. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37081. */
  37082. hideLoadingUI(): void;
  37083. /**
  37084. * Gets the current loading screen object
  37085. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37086. */
  37087. get loadingScreen(): ILoadingScreen;
  37088. /**
  37089. * Sets the current loading screen object
  37090. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37091. */
  37092. set loadingScreen(loadingScreen: ILoadingScreen);
  37093. /**
  37094. * Sets the current loading screen text
  37095. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37096. */
  37097. set loadingUIText(text: string);
  37098. /**
  37099. * Sets the current loading screen background color
  37100. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37101. */
  37102. set loadingUIBackgroundColor(color: string);
  37103. /** Pointerlock and fullscreen */
  37104. /**
  37105. * Ask the browser to promote the current element to pointerlock mode
  37106. * @param element defines the DOM element to promote
  37107. */
  37108. static _RequestPointerlock(element: HTMLElement): void;
  37109. /**
  37110. * Asks the browser to exit pointerlock mode
  37111. */
  37112. static _ExitPointerlock(): void;
  37113. /**
  37114. * Ask the browser to promote the current element to fullscreen rendering mode
  37115. * @param element defines the DOM element to promote
  37116. */
  37117. static _RequestFullscreen(element: HTMLElement): void;
  37118. /**
  37119. * Asks the browser to exit fullscreen mode
  37120. */
  37121. static _ExitFullscreen(): void;
  37122. }
  37123. }
  37124. declare module BABYLON {
  37125. /**
  37126. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37127. * during the life time of the application.
  37128. */
  37129. export class EngineStore {
  37130. /** Gets the list of created engines */
  37131. static Instances: Engine[];
  37132. /** @hidden */
  37133. static _LastCreatedScene: Nullable<Scene>;
  37134. /**
  37135. * Gets the latest created engine
  37136. */
  37137. static get LastCreatedEngine(): Nullable<Engine>;
  37138. /**
  37139. * Gets the latest created scene
  37140. */
  37141. static get LastCreatedScene(): Nullable<Scene>;
  37142. /**
  37143. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37144. * @ignorenaming
  37145. */
  37146. static UseFallbackTexture: boolean;
  37147. /**
  37148. * Texture content used if a texture cannot loaded
  37149. * @ignorenaming
  37150. */
  37151. static FallbackTexture: string;
  37152. }
  37153. }
  37154. declare module BABYLON {
  37155. /**
  37156. * Helper class that provides a small promise polyfill
  37157. */
  37158. export class PromisePolyfill {
  37159. /**
  37160. * Static function used to check if the polyfill is required
  37161. * If this is the case then the function will inject the polyfill to window.Promise
  37162. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37163. */
  37164. static Apply(force?: boolean): void;
  37165. }
  37166. }
  37167. declare module BABYLON {
  37168. /**
  37169. * Interface for screenshot methods with describe argument called `size` as object with options
  37170. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37171. */
  37172. export interface IScreenshotSize {
  37173. /**
  37174. * number in pixels for canvas height
  37175. */
  37176. height?: number;
  37177. /**
  37178. * multiplier allowing render at a higher or lower resolution
  37179. * If value is defined then height and width will be ignored and taken from camera
  37180. */
  37181. precision?: number;
  37182. /**
  37183. * number in pixels for canvas width
  37184. */
  37185. width?: number;
  37186. }
  37187. }
  37188. declare module BABYLON {
  37189. interface IColor4Like {
  37190. r: float;
  37191. g: float;
  37192. b: float;
  37193. a: float;
  37194. }
  37195. /**
  37196. * Class containing a set of static utilities functions
  37197. */
  37198. export class Tools {
  37199. /**
  37200. * Gets or sets the base URL to use to load assets
  37201. */
  37202. static get BaseUrl(): string;
  37203. static set BaseUrl(value: string);
  37204. /**
  37205. * Enable/Disable Custom HTTP Request Headers globally.
  37206. * default = false
  37207. * @see CustomRequestHeaders
  37208. */
  37209. static UseCustomRequestHeaders: boolean;
  37210. /**
  37211. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37212. * i.e. when loading files, where the server/service expects an Authorization header
  37213. */
  37214. static CustomRequestHeaders: {
  37215. [key: string]: string;
  37216. };
  37217. /**
  37218. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37219. */
  37220. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37221. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37222. /**
  37223. * Default behaviour for cors in the application.
  37224. * It can be a string if the expected behavior is identical in the entire app.
  37225. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37226. */
  37227. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37228. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37229. /**
  37230. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37231. * @ignorenaming
  37232. */
  37233. static get UseFallbackTexture(): boolean;
  37234. static set UseFallbackTexture(value: boolean);
  37235. /**
  37236. * Use this object to register external classes like custom textures or material
  37237. * to allow the laoders to instantiate them
  37238. */
  37239. static get RegisteredExternalClasses(): {
  37240. [key: string]: Object;
  37241. };
  37242. static set RegisteredExternalClasses(classes: {
  37243. [key: string]: Object;
  37244. });
  37245. /**
  37246. * Texture content used if a texture cannot loaded
  37247. * @ignorenaming
  37248. */
  37249. static get fallbackTexture(): string;
  37250. static set fallbackTexture(value: string);
  37251. /**
  37252. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37253. * @param u defines the coordinate on X axis
  37254. * @param v defines the coordinate on Y axis
  37255. * @param width defines the width of the source data
  37256. * @param height defines the height of the source data
  37257. * @param pixels defines the source byte array
  37258. * @param color defines the output color
  37259. */
  37260. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37261. /**
  37262. * Interpolates between a and b via alpha
  37263. * @param a The lower value (returned when alpha = 0)
  37264. * @param b The upper value (returned when alpha = 1)
  37265. * @param alpha The interpolation-factor
  37266. * @return The mixed value
  37267. */
  37268. static Mix(a: number, b: number, alpha: number): number;
  37269. /**
  37270. * Tries to instantiate a new object from a given class name
  37271. * @param className defines the class name to instantiate
  37272. * @returns the new object or null if the system was not able to do the instantiation
  37273. */
  37274. static Instantiate(className: string): any;
  37275. /**
  37276. * Provides a slice function that will work even on IE
  37277. * @param data defines the array to slice
  37278. * @param start defines the start of the data (optional)
  37279. * @param end defines the end of the data (optional)
  37280. * @returns the new sliced array
  37281. */
  37282. static Slice<T>(data: T, start?: number, end?: number): T;
  37283. /**
  37284. * Polyfill for setImmediate
  37285. * @param action defines the action to execute after the current execution block
  37286. */
  37287. static SetImmediate(action: () => void): void;
  37288. /**
  37289. * Function indicating if a number is an exponent of 2
  37290. * @param value defines the value to test
  37291. * @returns true if the value is an exponent of 2
  37292. */
  37293. static IsExponentOfTwo(value: number): boolean;
  37294. private static _tmpFloatArray;
  37295. /**
  37296. * Returns the nearest 32-bit single precision float representation of a Number
  37297. * @param value A Number. If the parameter is of a different type, it will get converted
  37298. * to a number or to NaN if it cannot be converted
  37299. * @returns number
  37300. */
  37301. static FloatRound(value: number): number;
  37302. /**
  37303. * Extracts the filename from a path
  37304. * @param path defines the path to use
  37305. * @returns the filename
  37306. */
  37307. static GetFilename(path: string): string;
  37308. /**
  37309. * Extracts the "folder" part of a path (everything before the filename).
  37310. * @param uri The URI to extract the info from
  37311. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37312. * @returns The "folder" part of the path
  37313. */
  37314. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37315. /**
  37316. * Extracts text content from a DOM element hierarchy
  37317. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37318. */
  37319. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37320. /**
  37321. * Convert an angle in radians to degrees
  37322. * @param angle defines the angle to convert
  37323. * @returns the angle in degrees
  37324. */
  37325. static ToDegrees(angle: number): number;
  37326. /**
  37327. * Convert an angle in degrees to radians
  37328. * @param angle defines the angle to convert
  37329. * @returns the angle in radians
  37330. */
  37331. static ToRadians(angle: number): number;
  37332. /**
  37333. * Returns an array if obj is not an array
  37334. * @param obj defines the object to evaluate as an array
  37335. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37336. * @returns either obj directly if obj is an array or a new array containing obj
  37337. */
  37338. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37339. /**
  37340. * Gets the pointer prefix to use
  37341. * @param engine defines the engine we are finding the prefix for
  37342. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37343. */
  37344. static GetPointerPrefix(engine: Engine): string;
  37345. /**
  37346. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37347. * @param url define the url we are trying
  37348. * @param element define the dom element where to configure the cors policy
  37349. */
  37350. static SetCorsBehavior(url: string | string[], element: {
  37351. crossOrigin: string | null;
  37352. }): void;
  37353. /**
  37354. * Removes unwanted characters from an url
  37355. * @param url defines the url to clean
  37356. * @returns the cleaned url
  37357. */
  37358. static CleanUrl(url: string): string;
  37359. /**
  37360. * Gets or sets a function used to pre-process url before using them to load assets
  37361. */
  37362. static get PreprocessUrl(): (url: string) => string;
  37363. static set PreprocessUrl(processor: (url: string) => string);
  37364. /**
  37365. * Loads an image as an HTMLImageElement.
  37366. * @param input url string, ArrayBuffer, or Blob to load
  37367. * @param onLoad callback called when the image successfully loads
  37368. * @param onError callback called when the image fails to load
  37369. * @param offlineProvider offline provider for caching
  37370. * @param mimeType optional mime type
  37371. * @returns the HTMLImageElement of the loaded image
  37372. */
  37373. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37374. /**
  37375. * Loads a file from a url
  37376. * @param url url string, ArrayBuffer, or Blob to load
  37377. * @param onSuccess callback called when the file successfully loads
  37378. * @param onProgress callback called while file is loading (if the server supports this mode)
  37379. * @param offlineProvider defines the offline provider for caching
  37380. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37381. * @param onError callback called when the file fails to load
  37382. * @returns a file request object
  37383. */
  37384. 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;
  37385. /**
  37386. * Loads a file from a url
  37387. * @param url the file url to load
  37388. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37389. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37390. */
  37391. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37392. /**
  37393. * Load a script (identified by an url). When the url returns, the
  37394. * content of this file is added into a new script element, attached to the DOM (body element)
  37395. * @param scriptUrl defines the url of the script to laod
  37396. * @param onSuccess defines the callback called when the script is loaded
  37397. * @param onError defines the callback to call if an error occurs
  37398. * @param scriptId defines the id of the script element
  37399. */
  37400. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37401. /**
  37402. * Load an asynchronous script (identified by an url). When the url returns, the
  37403. * content of this file is added into a new script element, attached to the DOM (body element)
  37404. * @param scriptUrl defines the url of the script to laod
  37405. * @param scriptId defines the id of the script element
  37406. * @returns a promise request object
  37407. */
  37408. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37409. /**
  37410. * Loads a file from a blob
  37411. * @param fileToLoad defines the blob to use
  37412. * @param callback defines the callback to call when data is loaded
  37413. * @param progressCallback defines the callback to call during loading process
  37414. * @returns a file request object
  37415. */
  37416. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37417. /**
  37418. * Reads a file from a File object
  37419. * @param file defines the file to load
  37420. * @param onSuccess defines the callback to call when data is loaded
  37421. * @param onProgress defines the callback to call during loading process
  37422. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37423. * @param onError defines the callback to call when an error occurs
  37424. * @returns a file request object
  37425. */
  37426. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37427. /**
  37428. * Creates a data url from a given string content
  37429. * @param content defines the content to convert
  37430. * @returns the new data url link
  37431. */
  37432. static FileAsURL(content: string): string;
  37433. /**
  37434. * Format the given number to a specific decimal format
  37435. * @param value defines the number to format
  37436. * @param decimals defines the number of decimals to use
  37437. * @returns the formatted string
  37438. */
  37439. static Format(value: number, decimals?: number): string;
  37440. /**
  37441. * Tries to copy an object by duplicating every property
  37442. * @param source defines the source object
  37443. * @param destination defines the target object
  37444. * @param doNotCopyList defines a list of properties to avoid
  37445. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37446. */
  37447. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37448. /**
  37449. * Gets a boolean indicating if the given object has no own property
  37450. * @param obj defines the object to test
  37451. * @returns true if object has no own property
  37452. */
  37453. static IsEmpty(obj: any): boolean;
  37454. /**
  37455. * Function used to register events at window level
  37456. * @param windowElement defines the Window object to use
  37457. * @param events defines the events to register
  37458. */
  37459. static RegisterTopRootEvents(windowElement: Window, events: {
  37460. name: string;
  37461. handler: Nullable<(e: FocusEvent) => any>;
  37462. }[]): void;
  37463. /**
  37464. * Function used to unregister events from window level
  37465. * @param windowElement defines the Window object to use
  37466. * @param events defines the events to unregister
  37467. */
  37468. static UnregisterTopRootEvents(windowElement: Window, events: {
  37469. name: string;
  37470. handler: Nullable<(e: FocusEvent) => any>;
  37471. }[]): void;
  37472. /**
  37473. * @ignore
  37474. */
  37475. static _ScreenshotCanvas: HTMLCanvasElement;
  37476. /**
  37477. * Dumps the current bound framebuffer
  37478. * @param width defines the rendering width
  37479. * @param height defines the rendering height
  37480. * @param engine defines the hosting engine
  37481. * @param successCallback defines the callback triggered once the data are available
  37482. * @param mimeType defines the mime type of the result
  37483. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37484. */
  37485. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37486. /**
  37487. * Converts the canvas data to blob.
  37488. * This acts as a polyfill for browsers not supporting the to blob function.
  37489. * @param canvas Defines the canvas to extract the data from
  37490. * @param successCallback Defines the callback triggered once the data are available
  37491. * @param mimeType Defines the mime type of the result
  37492. */
  37493. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37494. /**
  37495. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37496. * @param successCallback defines the callback triggered once the data are available
  37497. * @param mimeType defines the mime type of the result
  37498. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37499. */
  37500. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37501. /**
  37502. * Downloads a blob in the browser
  37503. * @param blob defines the blob to download
  37504. * @param fileName defines the name of the downloaded file
  37505. */
  37506. static Download(blob: Blob, fileName: string): void;
  37507. /**
  37508. * Captures a screenshot of the current rendering
  37509. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37510. * @param engine defines the rendering engine
  37511. * @param camera defines the source camera
  37512. * @param size This parameter can be set to a single number or to an object with the
  37513. * following (optional) properties: precision, width, height. If a single number is passed,
  37514. * it will be used for both width and height. If an object is passed, the screenshot size
  37515. * will be derived from the parameters. The precision property is a multiplier allowing
  37516. * rendering at a higher or lower resolution
  37517. * @param successCallback defines the callback receives a single parameter which contains the
  37518. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37519. * src parameter of an <img> to display it
  37520. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37521. * Check your browser for supported MIME types
  37522. */
  37523. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37524. /**
  37525. * Captures a screenshot of the current rendering
  37526. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37527. * @param engine defines the rendering engine
  37528. * @param camera defines the source camera
  37529. * @param size This parameter can be set to a single number or to an object with the
  37530. * following (optional) properties: precision, width, height. If a single number is passed,
  37531. * it will be used for both width and height. If an object is passed, the screenshot size
  37532. * will be derived from the parameters. The precision property is a multiplier allowing
  37533. * rendering at a higher or lower resolution
  37534. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37535. * Check your browser for supported MIME types
  37536. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37537. * to the src parameter of an <img> to display it
  37538. */
  37539. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37540. /**
  37541. * Generates an image screenshot from the specified camera.
  37542. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37543. * @param engine The engine to use for rendering
  37544. * @param camera The camera to use for rendering
  37545. * @param size This parameter can be set to a single number or to an object with the
  37546. * following (optional) properties: precision, width, height. If a single number is passed,
  37547. * it will be used for both width and height. If an object is passed, the screenshot size
  37548. * will be derived from the parameters. The precision property is a multiplier allowing
  37549. * rendering at a higher or lower resolution
  37550. * @param successCallback The callback receives a single parameter which contains the
  37551. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37552. * src parameter of an <img> to display it
  37553. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37554. * Check your browser for supported MIME types
  37555. * @param samples Texture samples (default: 1)
  37556. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37557. * @param fileName A name for for the downloaded file.
  37558. */
  37559. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37560. /**
  37561. * Generates an image screenshot from the specified camera.
  37562. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37563. * @param engine The engine to use for rendering
  37564. * @param camera The camera to use for rendering
  37565. * @param size This parameter can be set to a single number or to an object with the
  37566. * following (optional) properties: precision, width, height. If a single number is passed,
  37567. * it will be used for both width and height. If an object is passed, the screenshot size
  37568. * will be derived from the parameters. The precision property is a multiplier allowing
  37569. * rendering at a higher or lower resolution
  37570. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37571. * Check your browser for supported MIME types
  37572. * @param samples Texture samples (default: 1)
  37573. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37574. * @param fileName A name for for the downloaded file.
  37575. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37576. * to the src parameter of an <img> to display it
  37577. */
  37578. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37579. /**
  37580. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37581. * Be aware Math.random() could cause collisions, but:
  37582. * "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"
  37583. * @returns a pseudo random id
  37584. */
  37585. static RandomId(): string;
  37586. /**
  37587. * Test if the given uri is a base64 string
  37588. * @param uri The uri to test
  37589. * @return True if the uri is a base64 string or false otherwise
  37590. */
  37591. static IsBase64(uri: string): boolean;
  37592. /**
  37593. * Decode the given base64 uri.
  37594. * @param uri The uri to decode
  37595. * @return The decoded base64 data.
  37596. */
  37597. static DecodeBase64(uri: string): ArrayBuffer;
  37598. /**
  37599. * Gets the absolute url.
  37600. * @param url the input url
  37601. * @return the absolute url
  37602. */
  37603. static GetAbsoluteUrl(url: string): string;
  37604. /**
  37605. * No log
  37606. */
  37607. static readonly NoneLogLevel: number;
  37608. /**
  37609. * Only message logs
  37610. */
  37611. static readonly MessageLogLevel: number;
  37612. /**
  37613. * Only warning logs
  37614. */
  37615. static readonly WarningLogLevel: number;
  37616. /**
  37617. * Only error logs
  37618. */
  37619. static readonly ErrorLogLevel: number;
  37620. /**
  37621. * All logs
  37622. */
  37623. static readonly AllLogLevel: number;
  37624. /**
  37625. * Gets a value indicating the number of loading errors
  37626. * @ignorenaming
  37627. */
  37628. static get errorsCount(): number;
  37629. /**
  37630. * Callback called when a new log is added
  37631. */
  37632. static OnNewCacheEntry: (entry: string) => void;
  37633. /**
  37634. * Log a message to the console
  37635. * @param message defines the message to log
  37636. */
  37637. static Log(message: string): void;
  37638. /**
  37639. * Write a warning message to the console
  37640. * @param message defines the message to log
  37641. */
  37642. static Warn(message: string): void;
  37643. /**
  37644. * Write an error message to the console
  37645. * @param message defines the message to log
  37646. */
  37647. static Error(message: string): void;
  37648. /**
  37649. * Gets current log cache (list of logs)
  37650. */
  37651. static get LogCache(): string;
  37652. /**
  37653. * Clears the log cache
  37654. */
  37655. static ClearLogCache(): void;
  37656. /**
  37657. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37658. */
  37659. static set LogLevels(level: number);
  37660. /**
  37661. * Checks if the window object exists
  37662. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37663. */
  37664. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37665. /**
  37666. * No performance log
  37667. */
  37668. static readonly PerformanceNoneLogLevel: number;
  37669. /**
  37670. * Use user marks to log performance
  37671. */
  37672. static readonly PerformanceUserMarkLogLevel: number;
  37673. /**
  37674. * Log performance to the console
  37675. */
  37676. static readonly PerformanceConsoleLogLevel: number;
  37677. private static _performance;
  37678. /**
  37679. * Sets the current performance log level
  37680. */
  37681. static set PerformanceLogLevel(level: number);
  37682. private static _StartPerformanceCounterDisabled;
  37683. private static _EndPerformanceCounterDisabled;
  37684. private static _StartUserMark;
  37685. private static _EndUserMark;
  37686. private static _StartPerformanceConsole;
  37687. private static _EndPerformanceConsole;
  37688. /**
  37689. * Starts a performance counter
  37690. */
  37691. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37692. /**
  37693. * Ends a specific performance coutner
  37694. */
  37695. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37696. /**
  37697. * Gets either window.performance.now() if supported or Date.now() else
  37698. */
  37699. static get Now(): number;
  37700. /**
  37701. * This method will return the name of the class used to create the instance of the given object.
  37702. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37703. * @param object the object to get the class name from
  37704. * @param isType defines if the object is actually a type
  37705. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37706. */
  37707. static GetClassName(object: any, isType?: boolean): string;
  37708. /**
  37709. * Gets the first element of an array satisfying a given predicate
  37710. * @param array defines the array to browse
  37711. * @param predicate defines the predicate to use
  37712. * @returns null if not found or the element
  37713. */
  37714. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37715. /**
  37716. * This method will return the name of the full name of the class, including its owning module (if any).
  37717. * 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).
  37718. * @param object the object to get the class name from
  37719. * @param isType defines if the object is actually a type
  37720. * @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.
  37721. * @ignorenaming
  37722. */
  37723. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37724. /**
  37725. * Returns a promise that resolves after the given amount of time.
  37726. * @param delay Number of milliseconds to delay
  37727. * @returns Promise that resolves after the given amount of time
  37728. */
  37729. static DelayAsync(delay: number): Promise<void>;
  37730. /**
  37731. * Utility function to detect if the current user agent is Safari
  37732. * @returns whether or not the current user agent is safari
  37733. */
  37734. static IsSafari(): boolean;
  37735. }
  37736. /**
  37737. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37738. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37739. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37740. * @param name The name of the class, case should be preserved
  37741. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37742. */
  37743. export function className(name: string, module?: string): (target: Object) => void;
  37744. /**
  37745. * An implementation of a loop for asynchronous functions.
  37746. */
  37747. export class AsyncLoop {
  37748. /**
  37749. * Defines the number of iterations for the loop
  37750. */
  37751. iterations: number;
  37752. /**
  37753. * Defines the current index of the loop.
  37754. */
  37755. index: number;
  37756. private _done;
  37757. private _fn;
  37758. private _successCallback;
  37759. /**
  37760. * Constructor.
  37761. * @param iterations the number of iterations.
  37762. * @param func the function to run each iteration
  37763. * @param successCallback the callback that will be called upon succesful execution
  37764. * @param offset starting offset.
  37765. */
  37766. constructor(
  37767. /**
  37768. * Defines the number of iterations for the loop
  37769. */
  37770. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37771. /**
  37772. * Execute the next iteration. Must be called after the last iteration was finished.
  37773. */
  37774. executeNext(): void;
  37775. /**
  37776. * Break the loop and run the success callback.
  37777. */
  37778. breakLoop(): void;
  37779. /**
  37780. * Create and run an async loop.
  37781. * @param iterations the number of iterations.
  37782. * @param fn the function to run each iteration
  37783. * @param successCallback the callback that will be called upon succesful execution
  37784. * @param offset starting offset.
  37785. * @returns the created async loop object
  37786. */
  37787. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37788. /**
  37789. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37790. * @param iterations total number of iterations
  37791. * @param syncedIterations number of synchronous iterations in each async iteration.
  37792. * @param fn the function to call each iteration.
  37793. * @param callback a success call back that will be called when iterating stops.
  37794. * @param breakFunction a break condition (optional)
  37795. * @param timeout timeout settings for the setTimeout function. default - 0.
  37796. * @returns the created async loop object
  37797. */
  37798. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37799. }
  37800. }
  37801. declare module BABYLON {
  37802. /**
  37803. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37804. * The underlying implementation relies on an associative array to ensure the best performances.
  37805. * The value can be anything including 'null' but except 'undefined'
  37806. */
  37807. export class StringDictionary<T> {
  37808. /**
  37809. * This will clear this dictionary and copy the content from the 'source' one.
  37810. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37811. * @param source the dictionary to take the content from and copy to this dictionary
  37812. */
  37813. copyFrom(source: StringDictionary<T>): void;
  37814. /**
  37815. * Get a value based from its key
  37816. * @param key the given key to get the matching value from
  37817. * @return the value if found, otherwise undefined is returned
  37818. */
  37819. get(key: string): T | undefined;
  37820. /**
  37821. * Get a value from its key or add it if it doesn't exist.
  37822. * This method will ensure you that a given key/data will be present in the dictionary.
  37823. * @param key the given key to get the matching value from
  37824. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37825. * The factory will only be invoked if there's no data for the given key.
  37826. * @return the value corresponding to the key.
  37827. */
  37828. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37829. /**
  37830. * Get a value from its key if present in the dictionary otherwise add it
  37831. * @param key the key to get the value from
  37832. * @param val if there's no such key/value pair in the dictionary add it with this value
  37833. * @return the value corresponding to the key
  37834. */
  37835. getOrAdd(key: string, val: T): T;
  37836. /**
  37837. * Check if there's a given key in the dictionary
  37838. * @param key the key to check for
  37839. * @return true if the key is present, false otherwise
  37840. */
  37841. contains(key: string): boolean;
  37842. /**
  37843. * Add a new key and its corresponding value
  37844. * @param key the key to add
  37845. * @param value the value corresponding to the key
  37846. * @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
  37847. */
  37848. add(key: string, value: T): boolean;
  37849. /**
  37850. * Update a specific value associated to a key
  37851. * @param key defines the key to use
  37852. * @param value defines the value to store
  37853. * @returns true if the value was updated (or false if the key was not found)
  37854. */
  37855. set(key: string, value: T): boolean;
  37856. /**
  37857. * Get the element of the given key and remove it from the dictionary
  37858. * @param key defines the key to search
  37859. * @returns the value associated with the key or null if not found
  37860. */
  37861. getAndRemove(key: string): Nullable<T>;
  37862. /**
  37863. * Remove a key/value from the dictionary.
  37864. * @param key the key to remove
  37865. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37866. */
  37867. remove(key: string): boolean;
  37868. /**
  37869. * Clear the whole content of the dictionary
  37870. */
  37871. clear(): void;
  37872. /**
  37873. * Gets the current count
  37874. */
  37875. get count(): number;
  37876. /**
  37877. * Execute a callback on each key/val of the dictionary.
  37878. * Note that you can remove any element in this dictionary in the callback implementation
  37879. * @param callback the callback to execute on a given key/value pair
  37880. */
  37881. forEach(callback: (key: string, val: T) => void): void;
  37882. /**
  37883. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37884. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37885. * Note that you can remove any element in this dictionary in the callback implementation
  37886. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37887. * @returns the first item
  37888. */
  37889. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37890. private _count;
  37891. private _data;
  37892. }
  37893. }
  37894. declare module BABYLON {
  37895. /** @hidden */
  37896. export interface ICollisionCoordinator {
  37897. createCollider(): Collider;
  37898. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37899. init(scene: Scene): void;
  37900. }
  37901. /** @hidden */
  37902. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37903. private _scene;
  37904. private _scaledPosition;
  37905. private _scaledVelocity;
  37906. private _finalPosition;
  37907. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37908. createCollider(): Collider;
  37909. init(scene: Scene): void;
  37910. private _collideWithWorld;
  37911. }
  37912. }
  37913. declare module BABYLON {
  37914. /**
  37915. * Class used to manage all inputs for the scene.
  37916. */
  37917. export class InputManager {
  37918. /** The distance in pixel that you have to move to prevent some events */
  37919. static DragMovementThreshold: number;
  37920. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37921. static LongPressDelay: number;
  37922. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37923. static DoubleClickDelay: number;
  37924. /** If you need to check double click without raising a single click at first click, enable this flag */
  37925. static ExclusiveDoubleClickMode: boolean;
  37926. private _wheelEventName;
  37927. private _onPointerMove;
  37928. private _onPointerDown;
  37929. private _onPointerUp;
  37930. private _initClickEvent;
  37931. private _initActionManager;
  37932. private _delayedSimpleClick;
  37933. private _delayedSimpleClickTimeout;
  37934. private _previousDelayedSimpleClickTimeout;
  37935. private _meshPickProceed;
  37936. private _previousButtonPressed;
  37937. private _currentPickResult;
  37938. private _previousPickResult;
  37939. private _totalPointersPressed;
  37940. private _doubleClickOccured;
  37941. private _pointerOverMesh;
  37942. private _pickedDownMesh;
  37943. private _pickedUpMesh;
  37944. private _pointerX;
  37945. private _pointerY;
  37946. private _unTranslatedPointerX;
  37947. private _unTranslatedPointerY;
  37948. private _startingPointerPosition;
  37949. private _previousStartingPointerPosition;
  37950. private _startingPointerTime;
  37951. private _previousStartingPointerTime;
  37952. private _pointerCaptures;
  37953. private _onKeyDown;
  37954. private _onKeyUp;
  37955. private _onCanvasFocusObserver;
  37956. private _onCanvasBlurObserver;
  37957. private _scene;
  37958. /**
  37959. * Creates a new InputManager
  37960. * @param scene defines the hosting scene
  37961. */
  37962. constructor(scene: Scene);
  37963. /**
  37964. * Gets the mesh that is currently under the pointer
  37965. */
  37966. get meshUnderPointer(): Nullable<AbstractMesh>;
  37967. /**
  37968. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37969. */
  37970. get unTranslatedPointer(): Vector2;
  37971. /**
  37972. * Gets or sets the current on-screen X position of the pointer
  37973. */
  37974. get pointerX(): number;
  37975. set pointerX(value: number);
  37976. /**
  37977. * Gets or sets the current on-screen Y position of the pointer
  37978. */
  37979. get pointerY(): number;
  37980. set pointerY(value: number);
  37981. private _updatePointerPosition;
  37982. private _processPointerMove;
  37983. private _setRayOnPointerInfo;
  37984. private _checkPrePointerObservable;
  37985. /**
  37986. * Use this method to simulate a pointer move on a mesh
  37987. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37988. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37989. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37990. */
  37991. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37992. /**
  37993. * Use this method to simulate a pointer down on a mesh
  37994. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37995. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37996. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37997. */
  37998. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37999. private _processPointerDown;
  38000. /** @hidden */
  38001. _isPointerSwiping(): boolean;
  38002. /**
  38003. * Use this method to simulate a pointer up on a mesh
  38004. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38005. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38006. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38007. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38008. */
  38009. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38010. private _processPointerUp;
  38011. /**
  38012. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38013. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38014. * @returns true if the pointer was captured
  38015. */
  38016. isPointerCaptured(pointerId?: number): boolean;
  38017. /**
  38018. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38019. * @param attachUp defines if you want to attach events to pointerup
  38020. * @param attachDown defines if you want to attach events to pointerdown
  38021. * @param attachMove defines if you want to attach events to pointermove
  38022. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38023. */
  38024. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38025. /**
  38026. * Detaches all event handlers
  38027. */
  38028. detachControl(): void;
  38029. /**
  38030. * Force the value of meshUnderPointer
  38031. * @param mesh defines the mesh to use
  38032. */
  38033. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38034. /**
  38035. * Gets the mesh under the pointer
  38036. * @returns a Mesh or null if no mesh is under the pointer
  38037. */
  38038. getPointerOverMesh(): Nullable<AbstractMesh>;
  38039. }
  38040. }
  38041. declare module BABYLON {
  38042. /**
  38043. * This class defines the direct association between an animation and a target
  38044. */
  38045. export class TargetedAnimation {
  38046. /**
  38047. * Animation to perform
  38048. */
  38049. animation: Animation;
  38050. /**
  38051. * Target to animate
  38052. */
  38053. target: any;
  38054. /**
  38055. * Returns the string "TargetedAnimation"
  38056. * @returns "TargetedAnimation"
  38057. */
  38058. getClassName(): string;
  38059. /**
  38060. * Serialize the object
  38061. * @returns the JSON object representing the current entity
  38062. */
  38063. serialize(): any;
  38064. }
  38065. /**
  38066. * Use this class to create coordinated animations on multiple targets
  38067. */
  38068. export class AnimationGroup implements IDisposable {
  38069. /** The name of the animation group */
  38070. name: string;
  38071. private _scene;
  38072. private _targetedAnimations;
  38073. private _animatables;
  38074. private _from;
  38075. private _to;
  38076. private _isStarted;
  38077. private _isPaused;
  38078. private _speedRatio;
  38079. private _loopAnimation;
  38080. private _isAdditive;
  38081. /**
  38082. * Gets or sets the unique id of the node
  38083. */
  38084. uniqueId: number;
  38085. /**
  38086. * This observable will notify when one animation have ended
  38087. */
  38088. onAnimationEndObservable: Observable<TargetedAnimation>;
  38089. /**
  38090. * Observer raised when one animation loops
  38091. */
  38092. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38093. /**
  38094. * Observer raised when all animations have looped
  38095. */
  38096. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38097. /**
  38098. * This observable will notify when all animations have ended.
  38099. */
  38100. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38101. /**
  38102. * This observable will notify when all animations have paused.
  38103. */
  38104. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38105. /**
  38106. * This observable will notify when all animations are playing.
  38107. */
  38108. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38109. /**
  38110. * Gets the first frame
  38111. */
  38112. get from(): number;
  38113. /**
  38114. * Gets the last frame
  38115. */
  38116. get to(): number;
  38117. /**
  38118. * Define if the animations are started
  38119. */
  38120. get isStarted(): boolean;
  38121. /**
  38122. * Gets a value indicating that the current group is playing
  38123. */
  38124. get isPlaying(): boolean;
  38125. /**
  38126. * Gets or sets the speed ratio to use for all animations
  38127. */
  38128. get speedRatio(): number;
  38129. /**
  38130. * Gets or sets the speed ratio to use for all animations
  38131. */
  38132. set speedRatio(value: number);
  38133. /**
  38134. * Gets or sets if all animations should loop or not
  38135. */
  38136. get loopAnimation(): boolean;
  38137. set loopAnimation(value: boolean);
  38138. /**
  38139. * Gets or sets if all animations should be evaluated additively
  38140. */
  38141. get isAdditive(): boolean;
  38142. set isAdditive(value: boolean);
  38143. /**
  38144. * Gets the targeted animations for this animation group
  38145. */
  38146. get targetedAnimations(): Array<TargetedAnimation>;
  38147. /**
  38148. * returning the list of animatables controlled by this animation group.
  38149. */
  38150. get animatables(): Array<Animatable>;
  38151. /**
  38152. * Gets the list of target animations
  38153. */
  38154. get children(): TargetedAnimation[];
  38155. /**
  38156. * Instantiates a new Animation Group.
  38157. * This helps managing several animations at once.
  38158. * @see http://doc.babylonjs.com/how_to/group
  38159. * @param name Defines the name of the group
  38160. * @param scene Defines the scene the group belongs to
  38161. */
  38162. constructor(
  38163. /** The name of the animation group */
  38164. name: string, scene?: Nullable<Scene>);
  38165. /**
  38166. * Add an animation (with its target) in the group
  38167. * @param animation defines the animation we want to add
  38168. * @param target defines the target of the animation
  38169. * @returns the TargetedAnimation object
  38170. */
  38171. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38172. /**
  38173. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38174. * It can add constant keys at begin or end
  38175. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38176. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38177. * @returns the animation group
  38178. */
  38179. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38180. private _animationLoopCount;
  38181. private _animationLoopFlags;
  38182. private _processLoop;
  38183. /**
  38184. * Start all animations on given targets
  38185. * @param loop defines if animations must loop
  38186. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38187. * @param from defines the from key (optional)
  38188. * @param to defines the to key (optional)
  38189. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38190. * @returns the current animation group
  38191. */
  38192. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38193. /**
  38194. * Pause all animations
  38195. * @returns the animation group
  38196. */
  38197. pause(): AnimationGroup;
  38198. /**
  38199. * Play all animations to initial state
  38200. * This function will start() the animations if they were not started or will restart() them if they were paused
  38201. * @param loop defines if animations must loop
  38202. * @returns the animation group
  38203. */
  38204. play(loop?: boolean): AnimationGroup;
  38205. /**
  38206. * Reset all animations to initial state
  38207. * @returns the animation group
  38208. */
  38209. reset(): AnimationGroup;
  38210. /**
  38211. * Restart animations from key 0
  38212. * @returns the animation group
  38213. */
  38214. restart(): AnimationGroup;
  38215. /**
  38216. * Stop all animations
  38217. * @returns the animation group
  38218. */
  38219. stop(): AnimationGroup;
  38220. /**
  38221. * Set animation weight for all animatables
  38222. * @param weight defines the weight to use
  38223. * @return the animationGroup
  38224. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38225. */
  38226. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38227. /**
  38228. * Synchronize and normalize all animatables with a source animatable
  38229. * @param root defines the root animatable to synchronize with
  38230. * @return the animationGroup
  38231. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38232. */
  38233. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38234. /**
  38235. * Goes to a specific frame in this animation group
  38236. * @param frame the frame number to go to
  38237. * @return the animationGroup
  38238. */
  38239. goToFrame(frame: number): AnimationGroup;
  38240. /**
  38241. * Dispose all associated resources
  38242. */
  38243. dispose(): void;
  38244. private _checkAnimationGroupEnded;
  38245. /**
  38246. * Clone the current animation group and returns a copy
  38247. * @param newName defines the name of the new group
  38248. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38249. * @returns the new aniamtion group
  38250. */
  38251. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38252. /**
  38253. * Serializes the animationGroup to an object
  38254. * @returns Serialized object
  38255. */
  38256. serialize(): any;
  38257. /**
  38258. * Returns a new AnimationGroup object parsed from the source provided.
  38259. * @param parsedAnimationGroup defines the source
  38260. * @param scene defines the scene that will receive the animationGroup
  38261. * @returns a new AnimationGroup
  38262. */
  38263. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38264. /**
  38265. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38266. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38267. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38268. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38269. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38270. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38271. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38272. */
  38273. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38274. /**
  38275. * Returns the string "AnimationGroup"
  38276. * @returns "AnimationGroup"
  38277. */
  38278. getClassName(): string;
  38279. /**
  38280. * Creates a detailled string about the object
  38281. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38282. * @returns a string representing the object
  38283. */
  38284. toString(fullDetails?: boolean): string;
  38285. }
  38286. }
  38287. declare module BABYLON {
  38288. /**
  38289. * Define an interface for all classes that will hold resources
  38290. */
  38291. export interface IDisposable {
  38292. /**
  38293. * Releases all held resources
  38294. */
  38295. dispose(): void;
  38296. }
  38297. /** Interface defining initialization parameters for Scene class */
  38298. export interface SceneOptions {
  38299. /**
  38300. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38301. * It will improve performance when the number of geometries becomes important.
  38302. */
  38303. useGeometryUniqueIdsMap?: boolean;
  38304. /**
  38305. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38306. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38307. */
  38308. useMaterialMeshMap?: boolean;
  38309. /**
  38310. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38311. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38312. */
  38313. useClonedMeshMap?: boolean;
  38314. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38315. virtual?: boolean;
  38316. }
  38317. /**
  38318. * Represents a scene to be rendered by the engine.
  38319. * @see http://doc.babylonjs.com/features/scene
  38320. */
  38321. export class Scene extends AbstractScene implements IAnimatable {
  38322. /** The fog is deactivated */
  38323. static readonly FOGMODE_NONE: number;
  38324. /** The fog density is following an exponential function */
  38325. static readonly FOGMODE_EXP: number;
  38326. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38327. static readonly FOGMODE_EXP2: number;
  38328. /** The fog density is following a linear function. */
  38329. static readonly FOGMODE_LINEAR: number;
  38330. /**
  38331. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38332. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38333. */
  38334. static MinDeltaTime: number;
  38335. /**
  38336. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38338. */
  38339. static MaxDeltaTime: number;
  38340. /**
  38341. * Factory used to create the default material.
  38342. * @param name The name of the material to create
  38343. * @param scene The scene to create the material for
  38344. * @returns The default material
  38345. */
  38346. static DefaultMaterialFactory(scene: Scene): Material;
  38347. /**
  38348. * Factory used to create the a collision coordinator.
  38349. * @returns The collision coordinator
  38350. */
  38351. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38352. /** @hidden */
  38353. _inputManager: InputManager;
  38354. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38355. cameraToUseForPointers: Nullable<Camera>;
  38356. /** @hidden */
  38357. readonly _isScene: boolean;
  38358. /** @hidden */
  38359. _blockEntityCollection: boolean;
  38360. /**
  38361. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38362. */
  38363. autoClear: boolean;
  38364. /**
  38365. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38366. */
  38367. autoClearDepthAndStencil: boolean;
  38368. /**
  38369. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38370. */
  38371. clearColor: Color4;
  38372. /**
  38373. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38374. */
  38375. ambientColor: Color3;
  38376. /**
  38377. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38378. * It should only be one of the following (if not the default embedded one):
  38379. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38380. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38381. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38382. * The material properties need to be setup according to the type of texture in use.
  38383. */
  38384. environmentBRDFTexture: BaseTexture;
  38385. /** @hidden */
  38386. protected _environmentTexture: Nullable<BaseTexture>;
  38387. /**
  38388. * Texture used in all pbr material as the reflection texture.
  38389. * As in the majority of the scene they are the same (exception for multi room and so on),
  38390. * this is easier to reference from here than from all the materials.
  38391. */
  38392. get environmentTexture(): Nullable<BaseTexture>;
  38393. /**
  38394. * Texture used in all pbr material as the reflection texture.
  38395. * As in the majority of the scene they are the same (exception for multi room and so on),
  38396. * this is easier to set here than in all the materials.
  38397. */
  38398. set environmentTexture(value: Nullable<BaseTexture>);
  38399. /** @hidden */
  38400. protected _environmentIntensity: number;
  38401. /**
  38402. * Intensity of the environment in all pbr material.
  38403. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38404. * As in the majority of the scene they are the same (exception for multi room and so on),
  38405. * this is easier to reference from here than from all the materials.
  38406. */
  38407. get environmentIntensity(): number;
  38408. /**
  38409. * Intensity of the environment in all pbr material.
  38410. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38411. * As in the majority of the scene they are the same (exception for multi room and so on),
  38412. * this is easier to set here than in all the materials.
  38413. */
  38414. set environmentIntensity(value: number);
  38415. /** @hidden */
  38416. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38417. /**
  38418. * Default image processing configuration used either in the rendering
  38419. * Forward main pass or through the imageProcessingPostProcess if present.
  38420. * As in the majority of the scene they are the same (exception for multi camera),
  38421. * this is easier to reference from here than from all the materials and post process.
  38422. *
  38423. * No setter as we it is a shared configuration, you can set the values instead.
  38424. */
  38425. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38426. private _forceWireframe;
  38427. /**
  38428. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38429. */
  38430. set forceWireframe(value: boolean);
  38431. get forceWireframe(): boolean;
  38432. private _skipFrustumClipping;
  38433. /**
  38434. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38435. */
  38436. set skipFrustumClipping(value: boolean);
  38437. get skipFrustumClipping(): boolean;
  38438. private _forcePointsCloud;
  38439. /**
  38440. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38441. */
  38442. set forcePointsCloud(value: boolean);
  38443. get forcePointsCloud(): boolean;
  38444. /**
  38445. * Gets or sets the active clipplane 1
  38446. */
  38447. clipPlane: Nullable<Plane>;
  38448. /**
  38449. * Gets or sets the active clipplane 2
  38450. */
  38451. clipPlane2: Nullable<Plane>;
  38452. /**
  38453. * Gets or sets the active clipplane 3
  38454. */
  38455. clipPlane3: Nullable<Plane>;
  38456. /**
  38457. * Gets or sets the active clipplane 4
  38458. */
  38459. clipPlane4: Nullable<Plane>;
  38460. /**
  38461. * Gets or sets the active clipplane 5
  38462. */
  38463. clipPlane5: Nullable<Plane>;
  38464. /**
  38465. * Gets or sets the active clipplane 6
  38466. */
  38467. clipPlane6: Nullable<Plane>;
  38468. /**
  38469. * Gets or sets a boolean indicating if animations are enabled
  38470. */
  38471. animationsEnabled: boolean;
  38472. private _animationPropertiesOverride;
  38473. /**
  38474. * Gets or sets the animation properties override
  38475. */
  38476. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38477. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38478. /**
  38479. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38480. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38481. */
  38482. useConstantAnimationDeltaTime: boolean;
  38483. /**
  38484. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38485. * Please note that it requires to run a ray cast through the scene on every frame
  38486. */
  38487. constantlyUpdateMeshUnderPointer: boolean;
  38488. /**
  38489. * Defines the HTML cursor to use when hovering over interactive elements
  38490. */
  38491. hoverCursor: string;
  38492. /**
  38493. * Defines the HTML default cursor to use (empty by default)
  38494. */
  38495. defaultCursor: string;
  38496. /**
  38497. * Defines whether cursors are handled by the scene.
  38498. */
  38499. doNotHandleCursors: boolean;
  38500. /**
  38501. * This is used to call preventDefault() on pointer down
  38502. * in order to block unwanted artifacts like system double clicks
  38503. */
  38504. preventDefaultOnPointerDown: boolean;
  38505. /**
  38506. * This is used to call preventDefault() on pointer up
  38507. * in order to block unwanted artifacts like system double clicks
  38508. */
  38509. preventDefaultOnPointerUp: boolean;
  38510. /**
  38511. * Gets or sets user defined metadata
  38512. */
  38513. metadata: any;
  38514. /**
  38515. * For internal use only. Please do not use.
  38516. */
  38517. reservedDataStore: any;
  38518. /**
  38519. * Gets the name of the plugin used to load this scene (null by default)
  38520. */
  38521. loadingPluginName: string;
  38522. /**
  38523. * Use this array to add regular expressions used to disable offline support for specific urls
  38524. */
  38525. disableOfflineSupportExceptionRules: RegExp[];
  38526. /**
  38527. * An event triggered when the scene is disposed.
  38528. */
  38529. onDisposeObservable: Observable<Scene>;
  38530. private _onDisposeObserver;
  38531. /** Sets a function to be executed when this scene is disposed. */
  38532. set onDispose(callback: () => void);
  38533. /**
  38534. * An event triggered before rendering the scene (right after animations and physics)
  38535. */
  38536. onBeforeRenderObservable: Observable<Scene>;
  38537. private _onBeforeRenderObserver;
  38538. /** Sets a function to be executed before rendering this scene */
  38539. set beforeRender(callback: Nullable<() => void>);
  38540. /**
  38541. * An event triggered after rendering the scene
  38542. */
  38543. onAfterRenderObservable: Observable<Scene>;
  38544. /**
  38545. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38546. */
  38547. onAfterRenderCameraObservable: Observable<Camera>;
  38548. private _onAfterRenderObserver;
  38549. /** Sets a function to be executed after rendering this scene */
  38550. set afterRender(callback: Nullable<() => void>);
  38551. /**
  38552. * An event triggered before animating the scene
  38553. */
  38554. onBeforeAnimationsObservable: Observable<Scene>;
  38555. /**
  38556. * An event triggered after animations processing
  38557. */
  38558. onAfterAnimationsObservable: Observable<Scene>;
  38559. /**
  38560. * An event triggered before draw calls are ready to be sent
  38561. */
  38562. onBeforeDrawPhaseObservable: Observable<Scene>;
  38563. /**
  38564. * An event triggered after draw calls have been sent
  38565. */
  38566. onAfterDrawPhaseObservable: Observable<Scene>;
  38567. /**
  38568. * An event triggered when the scene is ready
  38569. */
  38570. onReadyObservable: Observable<Scene>;
  38571. /**
  38572. * An event triggered before rendering a camera
  38573. */
  38574. onBeforeCameraRenderObservable: Observable<Camera>;
  38575. private _onBeforeCameraRenderObserver;
  38576. /** Sets a function to be executed before rendering a camera*/
  38577. set beforeCameraRender(callback: () => void);
  38578. /**
  38579. * An event triggered after rendering a camera
  38580. */
  38581. onAfterCameraRenderObservable: Observable<Camera>;
  38582. private _onAfterCameraRenderObserver;
  38583. /** Sets a function to be executed after rendering a camera*/
  38584. set afterCameraRender(callback: () => void);
  38585. /**
  38586. * An event triggered when active meshes evaluation is about to start
  38587. */
  38588. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38589. /**
  38590. * An event triggered when active meshes evaluation is done
  38591. */
  38592. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38593. /**
  38594. * An event triggered when particles rendering is about to start
  38595. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38596. */
  38597. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38598. /**
  38599. * An event triggered when particles rendering is done
  38600. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38601. */
  38602. onAfterParticlesRenderingObservable: Observable<Scene>;
  38603. /**
  38604. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38605. */
  38606. onDataLoadedObservable: Observable<Scene>;
  38607. /**
  38608. * An event triggered when a camera is created
  38609. */
  38610. onNewCameraAddedObservable: Observable<Camera>;
  38611. /**
  38612. * An event triggered when a camera is removed
  38613. */
  38614. onCameraRemovedObservable: Observable<Camera>;
  38615. /**
  38616. * An event triggered when a light is created
  38617. */
  38618. onNewLightAddedObservable: Observable<Light>;
  38619. /**
  38620. * An event triggered when a light is removed
  38621. */
  38622. onLightRemovedObservable: Observable<Light>;
  38623. /**
  38624. * An event triggered when a geometry is created
  38625. */
  38626. onNewGeometryAddedObservable: Observable<Geometry>;
  38627. /**
  38628. * An event triggered when a geometry is removed
  38629. */
  38630. onGeometryRemovedObservable: Observable<Geometry>;
  38631. /**
  38632. * An event triggered when a transform node is created
  38633. */
  38634. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38635. /**
  38636. * An event triggered when a transform node is removed
  38637. */
  38638. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38639. /**
  38640. * An event triggered when a mesh is created
  38641. */
  38642. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38643. /**
  38644. * An event triggered when a mesh is removed
  38645. */
  38646. onMeshRemovedObservable: Observable<AbstractMesh>;
  38647. /**
  38648. * An event triggered when a skeleton is created
  38649. */
  38650. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38651. /**
  38652. * An event triggered when a skeleton is removed
  38653. */
  38654. onSkeletonRemovedObservable: Observable<Skeleton>;
  38655. /**
  38656. * An event triggered when a material is created
  38657. */
  38658. onNewMaterialAddedObservable: Observable<Material>;
  38659. /**
  38660. * An event triggered when a material is removed
  38661. */
  38662. onMaterialRemovedObservable: Observable<Material>;
  38663. /**
  38664. * An event triggered when a texture is created
  38665. */
  38666. onNewTextureAddedObservable: Observable<BaseTexture>;
  38667. /**
  38668. * An event triggered when a texture is removed
  38669. */
  38670. onTextureRemovedObservable: Observable<BaseTexture>;
  38671. /**
  38672. * An event triggered when render targets are about to be rendered
  38673. * Can happen multiple times per frame.
  38674. */
  38675. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38676. /**
  38677. * An event triggered when render targets were rendered.
  38678. * Can happen multiple times per frame.
  38679. */
  38680. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38681. /**
  38682. * An event triggered before calculating deterministic simulation step
  38683. */
  38684. onBeforeStepObservable: Observable<Scene>;
  38685. /**
  38686. * An event triggered after calculating deterministic simulation step
  38687. */
  38688. onAfterStepObservable: Observable<Scene>;
  38689. /**
  38690. * An event triggered when the activeCamera property is updated
  38691. */
  38692. onActiveCameraChanged: Observable<Scene>;
  38693. /**
  38694. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38695. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38696. * 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)
  38697. */
  38698. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38699. /**
  38700. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38701. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38702. * 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)
  38703. */
  38704. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38705. /**
  38706. * This Observable will when a mesh has been imported into the scene.
  38707. */
  38708. onMeshImportedObservable: Observable<AbstractMesh>;
  38709. /**
  38710. * This Observable will when an animation file has been imported into the scene.
  38711. */
  38712. onAnimationFileImportedObservable: Observable<Scene>;
  38713. /**
  38714. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38715. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38716. */
  38717. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38718. /** @hidden */
  38719. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38720. /**
  38721. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38722. */
  38723. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38724. /**
  38725. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38726. */
  38727. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38728. /**
  38729. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38730. */
  38731. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38732. /** Callback called when a pointer move is detected */
  38733. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38734. /** Callback called when a pointer down is detected */
  38735. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38736. /** Callback called when a pointer up is detected */
  38737. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38738. /** Callback called when a pointer pick is detected */
  38739. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38740. /**
  38741. * 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).
  38742. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38743. */
  38744. onPrePointerObservable: Observable<PointerInfoPre>;
  38745. /**
  38746. * Observable event triggered each time an input event is received from the rendering canvas
  38747. */
  38748. onPointerObservable: Observable<PointerInfo>;
  38749. /**
  38750. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38751. */
  38752. get unTranslatedPointer(): Vector2;
  38753. /**
  38754. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38755. */
  38756. static get DragMovementThreshold(): number;
  38757. static set DragMovementThreshold(value: number);
  38758. /**
  38759. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38760. */
  38761. static get LongPressDelay(): number;
  38762. static set LongPressDelay(value: number);
  38763. /**
  38764. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38765. */
  38766. static get DoubleClickDelay(): number;
  38767. static set DoubleClickDelay(value: number);
  38768. /** If you need to check double click without raising a single click at first click, enable this flag */
  38769. static get ExclusiveDoubleClickMode(): boolean;
  38770. static set ExclusiveDoubleClickMode(value: boolean);
  38771. /** @hidden */
  38772. _mirroredCameraPosition: Nullable<Vector3>;
  38773. /**
  38774. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38775. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38776. */
  38777. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38778. /**
  38779. * Observable event triggered each time an keyboard event is received from the hosting window
  38780. */
  38781. onKeyboardObservable: Observable<KeyboardInfo>;
  38782. private _useRightHandedSystem;
  38783. /**
  38784. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38785. */
  38786. set useRightHandedSystem(value: boolean);
  38787. get useRightHandedSystem(): boolean;
  38788. private _timeAccumulator;
  38789. private _currentStepId;
  38790. private _currentInternalStep;
  38791. /**
  38792. * Sets the step Id used by deterministic lock step
  38793. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38794. * @param newStepId defines the step Id
  38795. */
  38796. setStepId(newStepId: number): void;
  38797. /**
  38798. * Gets the step Id used by deterministic lock step
  38799. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38800. * @returns the step Id
  38801. */
  38802. getStepId(): number;
  38803. /**
  38804. * Gets the internal step used by deterministic lock step
  38805. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38806. * @returns the internal step
  38807. */
  38808. getInternalStep(): number;
  38809. private _fogEnabled;
  38810. /**
  38811. * Gets or sets a boolean indicating if fog is enabled on this scene
  38812. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38813. * (Default is true)
  38814. */
  38815. set fogEnabled(value: boolean);
  38816. get fogEnabled(): boolean;
  38817. private _fogMode;
  38818. /**
  38819. * Gets or sets the fog mode to use
  38820. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38821. * | mode | value |
  38822. * | --- | --- |
  38823. * | FOGMODE_NONE | 0 |
  38824. * | FOGMODE_EXP | 1 |
  38825. * | FOGMODE_EXP2 | 2 |
  38826. * | FOGMODE_LINEAR | 3 |
  38827. */
  38828. set fogMode(value: number);
  38829. get fogMode(): number;
  38830. /**
  38831. * Gets or sets the fog color to use
  38832. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38833. * (Default is Color3(0.2, 0.2, 0.3))
  38834. */
  38835. fogColor: Color3;
  38836. /**
  38837. * Gets or sets the fog density to use
  38838. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38839. * (Default is 0.1)
  38840. */
  38841. fogDensity: number;
  38842. /**
  38843. * Gets or sets the fog start distance to use
  38844. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38845. * (Default is 0)
  38846. */
  38847. fogStart: number;
  38848. /**
  38849. * Gets or sets the fog end distance to use
  38850. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38851. * (Default is 1000)
  38852. */
  38853. fogEnd: number;
  38854. private _shadowsEnabled;
  38855. /**
  38856. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38857. */
  38858. set shadowsEnabled(value: boolean);
  38859. get shadowsEnabled(): boolean;
  38860. private _lightsEnabled;
  38861. /**
  38862. * Gets or sets a boolean indicating if lights are enabled on this scene
  38863. */
  38864. set lightsEnabled(value: boolean);
  38865. get lightsEnabled(): boolean;
  38866. /** All of the active cameras added to this scene. */
  38867. activeCameras: Camera[];
  38868. /** @hidden */
  38869. _activeCamera: Nullable<Camera>;
  38870. /** Gets or sets the current active camera */
  38871. get activeCamera(): Nullable<Camera>;
  38872. set activeCamera(value: Nullable<Camera>);
  38873. private _defaultMaterial;
  38874. /** The default material used on meshes when no material is affected */
  38875. get defaultMaterial(): Material;
  38876. /** The default material used on meshes when no material is affected */
  38877. set defaultMaterial(value: Material);
  38878. private _texturesEnabled;
  38879. /**
  38880. * Gets or sets a boolean indicating if textures are enabled on this scene
  38881. */
  38882. set texturesEnabled(value: boolean);
  38883. get texturesEnabled(): boolean;
  38884. /**
  38885. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38886. */
  38887. physicsEnabled: boolean;
  38888. /**
  38889. * Gets or sets a boolean indicating if particles are enabled on this scene
  38890. */
  38891. particlesEnabled: boolean;
  38892. /**
  38893. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38894. */
  38895. spritesEnabled: boolean;
  38896. private _skeletonsEnabled;
  38897. /**
  38898. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38899. */
  38900. set skeletonsEnabled(value: boolean);
  38901. get skeletonsEnabled(): boolean;
  38902. /**
  38903. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38904. */
  38905. lensFlaresEnabled: boolean;
  38906. /**
  38907. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38908. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38909. */
  38910. collisionsEnabled: boolean;
  38911. private _collisionCoordinator;
  38912. /** @hidden */
  38913. get collisionCoordinator(): ICollisionCoordinator;
  38914. /**
  38915. * Defines the gravity applied to this scene (used only for collisions)
  38916. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38917. */
  38918. gravity: Vector3;
  38919. /**
  38920. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38921. */
  38922. postProcessesEnabled: boolean;
  38923. /**
  38924. * The list of postprocesses added to the scene
  38925. */
  38926. postProcesses: PostProcess[];
  38927. /**
  38928. * Gets the current postprocess manager
  38929. */
  38930. postProcessManager: PostProcessManager;
  38931. /**
  38932. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38933. */
  38934. renderTargetsEnabled: boolean;
  38935. /**
  38936. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38937. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38938. */
  38939. dumpNextRenderTargets: boolean;
  38940. /**
  38941. * The list of user defined render targets added to the scene
  38942. */
  38943. customRenderTargets: RenderTargetTexture[];
  38944. /**
  38945. * Defines if texture loading must be delayed
  38946. * If true, textures will only be loaded when they need to be rendered
  38947. */
  38948. useDelayedTextureLoading: boolean;
  38949. /**
  38950. * Gets the list of meshes imported to the scene through SceneLoader
  38951. */
  38952. importedMeshesFiles: String[];
  38953. /**
  38954. * Gets or sets a boolean indicating if probes are enabled on this scene
  38955. */
  38956. probesEnabled: boolean;
  38957. /**
  38958. * Gets or sets the current offline provider to use to store scene data
  38959. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38960. */
  38961. offlineProvider: IOfflineProvider;
  38962. /**
  38963. * Gets or sets the action manager associated with the scene
  38964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38965. */
  38966. actionManager: AbstractActionManager;
  38967. private _meshesForIntersections;
  38968. /**
  38969. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38970. */
  38971. proceduralTexturesEnabled: boolean;
  38972. private _engine;
  38973. private _totalVertices;
  38974. /** @hidden */
  38975. _activeIndices: PerfCounter;
  38976. /** @hidden */
  38977. _activeParticles: PerfCounter;
  38978. /** @hidden */
  38979. _activeBones: PerfCounter;
  38980. private _animationRatio;
  38981. /** @hidden */
  38982. _animationTimeLast: number;
  38983. /** @hidden */
  38984. _animationTime: number;
  38985. /**
  38986. * Gets or sets a general scale for animation speed
  38987. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38988. */
  38989. animationTimeScale: number;
  38990. /** @hidden */
  38991. _cachedMaterial: Nullable<Material>;
  38992. /** @hidden */
  38993. _cachedEffect: Nullable<Effect>;
  38994. /** @hidden */
  38995. _cachedVisibility: Nullable<number>;
  38996. private _renderId;
  38997. private _frameId;
  38998. private _executeWhenReadyTimeoutId;
  38999. private _intermediateRendering;
  39000. private _viewUpdateFlag;
  39001. private _projectionUpdateFlag;
  39002. /** @hidden */
  39003. _toBeDisposed: Nullable<IDisposable>[];
  39004. private _activeRequests;
  39005. /** @hidden */
  39006. _pendingData: any[];
  39007. private _isDisposed;
  39008. /**
  39009. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39010. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39011. */
  39012. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39013. private _activeMeshes;
  39014. private _processedMaterials;
  39015. private _renderTargets;
  39016. /** @hidden */
  39017. _activeParticleSystems: SmartArray<IParticleSystem>;
  39018. private _activeSkeletons;
  39019. private _softwareSkinnedMeshes;
  39020. private _renderingManager;
  39021. /** @hidden */
  39022. _activeAnimatables: Animatable[];
  39023. private _transformMatrix;
  39024. private _sceneUbo;
  39025. /** @hidden */
  39026. _viewMatrix: Matrix;
  39027. private _projectionMatrix;
  39028. /** @hidden */
  39029. _forcedViewPosition: Nullable<Vector3>;
  39030. /** @hidden */
  39031. _frustumPlanes: Plane[];
  39032. /**
  39033. * Gets the list of frustum planes (built from the active camera)
  39034. */
  39035. get frustumPlanes(): Plane[];
  39036. /**
  39037. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39038. * This is useful if there are more lights that the maximum simulteanous authorized
  39039. */
  39040. requireLightSorting: boolean;
  39041. /** @hidden */
  39042. readonly useMaterialMeshMap: boolean;
  39043. /** @hidden */
  39044. readonly useClonedMeshMap: boolean;
  39045. private _externalData;
  39046. private _uid;
  39047. /**
  39048. * @hidden
  39049. * Backing store of defined scene components.
  39050. */
  39051. _components: ISceneComponent[];
  39052. /**
  39053. * @hidden
  39054. * Backing store of defined scene components.
  39055. */
  39056. _serializableComponents: ISceneSerializableComponent[];
  39057. /**
  39058. * List of components to register on the next registration step.
  39059. */
  39060. private _transientComponents;
  39061. /**
  39062. * Registers the transient components if needed.
  39063. */
  39064. private _registerTransientComponents;
  39065. /**
  39066. * @hidden
  39067. * Add a component to the scene.
  39068. * Note that the ccomponent could be registered on th next frame if this is called after
  39069. * the register component stage.
  39070. * @param component Defines the component to add to the scene
  39071. */
  39072. _addComponent(component: ISceneComponent): void;
  39073. /**
  39074. * @hidden
  39075. * Gets a component from the scene.
  39076. * @param name defines the name of the component to retrieve
  39077. * @returns the component or null if not present
  39078. */
  39079. _getComponent(name: string): Nullable<ISceneComponent>;
  39080. /**
  39081. * @hidden
  39082. * Defines the actions happening before camera updates.
  39083. */
  39084. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39085. /**
  39086. * @hidden
  39087. * Defines the actions happening before clear the canvas.
  39088. */
  39089. _beforeClearStage: Stage<SimpleStageAction>;
  39090. /**
  39091. * @hidden
  39092. * Defines the actions when collecting render targets for the frame.
  39093. */
  39094. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39095. /**
  39096. * @hidden
  39097. * Defines the actions happening for one camera in the frame.
  39098. */
  39099. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39100. /**
  39101. * @hidden
  39102. * Defines the actions happening during the per mesh ready checks.
  39103. */
  39104. _isReadyForMeshStage: Stage<MeshStageAction>;
  39105. /**
  39106. * @hidden
  39107. * Defines the actions happening before evaluate active mesh checks.
  39108. */
  39109. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39110. /**
  39111. * @hidden
  39112. * Defines the actions happening during the evaluate sub mesh checks.
  39113. */
  39114. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39115. /**
  39116. * @hidden
  39117. * Defines the actions happening during the active mesh stage.
  39118. */
  39119. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39120. /**
  39121. * @hidden
  39122. * Defines the actions happening during the per camera render target step.
  39123. */
  39124. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39125. /**
  39126. * @hidden
  39127. * Defines the actions happening just before the active camera is drawing.
  39128. */
  39129. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39130. /**
  39131. * @hidden
  39132. * Defines the actions happening just before a render target is drawing.
  39133. */
  39134. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39135. /**
  39136. * @hidden
  39137. * Defines the actions happening just before a rendering group is drawing.
  39138. */
  39139. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39140. /**
  39141. * @hidden
  39142. * Defines the actions happening just before a mesh is drawing.
  39143. */
  39144. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39145. /**
  39146. * @hidden
  39147. * Defines the actions happening just after a mesh has been drawn.
  39148. */
  39149. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39150. /**
  39151. * @hidden
  39152. * Defines the actions happening just after a rendering group has been drawn.
  39153. */
  39154. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39155. /**
  39156. * @hidden
  39157. * Defines the actions happening just after the active camera has been drawn.
  39158. */
  39159. _afterCameraDrawStage: Stage<CameraStageAction>;
  39160. /**
  39161. * @hidden
  39162. * Defines the actions happening just after a render target has been drawn.
  39163. */
  39164. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39165. /**
  39166. * @hidden
  39167. * Defines the actions happening just after rendering all cameras and computing intersections.
  39168. */
  39169. _afterRenderStage: Stage<SimpleStageAction>;
  39170. /**
  39171. * @hidden
  39172. * Defines the actions happening when a pointer move event happens.
  39173. */
  39174. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39175. /**
  39176. * @hidden
  39177. * Defines the actions happening when a pointer down event happens.
  39178. */
  39179. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39180. /**
  39181. * @hidden
  39182. * Defines the actions happening when a pointer up event happens.
  39183. */
  39184. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39185. /**
  39186. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39187. */
  39188. private geometriesByUniqueId;
  39189. /**
  39190. * Creates a new Scene
  39191. * @param engine defines the engine to use to render this scene
  39192. * @param options defines the scene options
  39193. */
  39194. constructor(engine: Engine, options?: SceneOptions);
  39195. /**
  39196. * Gets a string idenfifying the name of the class
  39197. * @returns "Scene" string
  39198. */
  39199. getClassName(): string;
  39200. private _defaultMeshCandidates;
  39201. /**
  39202. * @hidden
  39203. */
  39204. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39205. private _defaultSubMeshCandidates;
  39206. /**
  39207. * @hidden
  39208. */
  39209. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39210. /**
  39211. * Sets the default candidate providers for the scene.
  39212. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39213. * and getCollidingSubMeshCandidates to their default function
  39214. */
  39215. setDefaultCandidateProviders(): void;
  39216. /**
  39217. * Gets the mesh that is currently under the pointer
  39218. */
  39219. get meshUnderPointer(): Nullable<AbstractMesh>;
  39220. /**
  39221. * Gets or sets the current on-screen X position of the pointer
  39222. */
  39223. get pointerX(): number;
  39224. set pointerX(value: number);
  39225. /**
  39226. * Gets or sets the current on-screen Y position of the pointer
  39227. */
  39228. get pointerY(): number;
  39229. set pointerY(value: number);
  39230. /**
  39231. * Gets the cached material (ie. the latest rendered one)
  39232. * @returns the cached material
  39233. */
  39234. getCachedMaterial(): Nullable<Material>;
  39235. /**
  39236. * Gets the cached effect (ie. the latest rendered one)
  39237. * @returns the cached effect
  39238. */
  39239. getCachedEffect(): Nullable<Effect>;
  39240. /**
  39241. * Gets the cached visibility state (ie. the latest rendered one)
  39242. * @returns the cached visibility state
  39243. */
  39244. getCachedVisibility(): Nullable<number>;
  39245. /**
  39246. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39247. * @param material defines the current material
  39248. * @param effect defines the current effect
  39249. * @param visibility defines the current visibility state
  39250. * @returns true if one parameter is not cached
  39251. */
  39252. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39253. /**
  39254. * Gets the engine associated with the scene
  39255. * @returns an Engine
  39256. */
  39257. getEngine(): Engine;
  39258. /**
  39259. * Gets the total number of vertices rendered per frame
  39260. * @returns the total number of vertices rendered per frame
  39261. */
  39262. getTotalVertices(): number;
  39263. /**
  39264. * Gets the performance counter for total vertices
  39265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39266. */
  39267. get totalVerticesPerfCounter(): PerfCounter;
  39268. /**
  39269. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39270. * @returns the total number of active indices rendered per frame
  39271. */
  39272. getActiveIndices(): number;
  39273. /**
  39274. * Gets the performance counter for active indices
  39275. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39276. */
  39277. get totalActiveIndicesPerfCounter(): PerfCounter;
  39278. /**
  39279. * Gets the total number of active particles rendered per frame
  39280. * @returns the total number of active particles rendered per frame
  39281. */
  39282. getActiveParticles(): number;
  39283. /**
  39284. * Gets the performance counter for active particles
  39285. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39286. */
  39287. get activeParticlesPerfCounter(): PerfCounter;
  39288. /**
  39289. * Gets the total number of active bones rendered per frame
  39290. * @returns the total number of active bones rendered per frame
  39291. */
  39292. getActiveBones(): number;
  39293. /**
  39294. * Gets the performance counter for active bones
  39295. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39296. */
  39297. get activeBonesPerfCounter(): PerfCounter;
  39298. /**
  39299. * Gets the array of active meshes
  39300. * @returns an array of AbstractMesh
  39301. */
  39302. getActiveMeshes(): SmartArray<AbstractMesh>;
  39303. /**
  39304. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39305. * @returns a number
  39306. */
  39307. getAnimationRatio(): number;
  39308. /**
  39309. * Gets an unique Id for the current render phase
  39310. * @returns a number
  39311. */
  39312. getRenderId(): number;
  39313. /**
  39314. * Gets an unique Id for the current frame
  39315. * @returns a number
  39316. */
  39317. getFrameId(): number;
  39318. /** Call this function if you want to manually increment the render Id*/
  39319. incrementRenderId(): void;
  39320. private _createUbo;
  39321. /**
  39322. * Use this method to simulate a pointer move on a mesh
  39323. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39324. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39325. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39326. * @returns the current scene
  39327. */
  39328. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39329. /**
  39330. * Use this method to simulate a pointer down on a mesh
  39331. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39332. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39333. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39334. * @returns the current scene
  39335. */
  39336. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39337. /**
  39338. * Use this method to simulate a pointer up on a mesh
  39339. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39340. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39341. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39342. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39343. * @returns the current scene
  39344. */
  39345. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39346. /**
  39347. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39348. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39349. * @returns true if the pointer was captured
  39350. */
  39351. isPointerCaptured(pointerId?: number): boolean;
  39352. /**
  39353. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39354. * @param attachUp defines if you want to attach events to pointerup
  39355. * @param attachDown defines if you want to attach events to pointerdown
  39356. * @param attachMove defines if you want to attach events to pointermove
  39357. */
  39358. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39359. /** Detaches all event handlers*/
  39360. detachControl(): void;
  39361. /**
  39362. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39363. * Delay loaded resources are not taking in account
  39364. * @return true if all required resources are ready
  39365. */
  39366. isReady(): boolean;
  39367. /** Resets all cached information relative to material (including effect and visibility) */
  39368. resetCachedMaterial(): void;
  39369. /**
  39370. * Registers a function to be called before every frame render
  39371. * @param func defines the function to register
  39372. */
  39373. registerBeforeRender(func: () => void): void;
  39374. /**
  39375. * Unregisters a function called before every frame render
  39376. * @param func defines the function to unregister
  39377. */
  39378. unregisterBeforeRender(func: () => void): void;
  39379. /**
  39380. * Registers a function to be called after every frame render
  39381. * @param func defines the function to register
  39382. */
  39383. registerAfterRender(func: () => void): void;
  39384. /**
  39385. * Unregisters a function called after every frame render
  39386. * @param func defines the function to unregister
  39387. */
  39388. unregisterAfterRender(func: () => void): void;
  39389. private _executeOnceBeforeRender;
  39390. /**
  39391. * The provided function will run before render once and will be disposed afterwards.
  39392. * A timeout delay can be provided so that the function will be executed in N ms.
  39393. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39394. * @param func The function to be executed.
  39395. * @param timeout optional delay in ms
  39396. */
  39397. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39398. /** @hidden */
  39399. _addPendingData(data: any): void;
  39400. /** @hidden */
  39401. _removePendingData(data: any): void;
  39402. /**
  39403. * Returns the number of items waiting to be loaded
  39404. * @returns the number of items waiting to be loaded
  39405. */
  39406. getWaitingItemsCount(): number;
  39407. /**
  39408. * Returns a boolean indicating if the scene is still loading data
  39409. */
  39410. get isLoading(): boolean;
  39411. /**
  39412. * Registers a function to be executed when the scene is ready
  39413. * @param {Function} func - the function to be executed
  39414. */
  39415. executeWhenReady(func: () => void): void;
  39416. /**
  39417. * Returns a promise that resolves when the scene is ready
  39418. * @returns A promise that resolves when the scene is ready
  39419. */
  39420. whenReadyAsync(): Promise<void>;
  39421. /** @hidden */
  39422. _checkIsReady(): void;
  39423. /**
  39424. * Gets all animatable attached to the scene
  39425. */
  39426. get animatables(): Animatable[];
  39427. /**
  39428. * Resets the last animation time frame.
  39429. * Useful to override when animations start running when loading a scene for the first time.
  39430. */
  39431. resetLastAnimationTimeFrame(): void;
  39432. /**
  39433. * Gets the current view matrix
  39434. * @returns a Matrix
  39435. */
  39436. getViewMatrix(): Matrix;
  39437. /**
  39438. * Gets the current projection matrix
  39439. * @returns a Matrix
  39440. */
  39441. getProjectionMatrix(): Matrix;
  39442. /**
  39443. * Gets the current transform matrix
  39444. * @returns a Matrix made of View * Projection
  39445. */
  39446. getTransformMatrix(): Matrix;
  39447. /**
  39448. * Sets the current transform matrix
  39449. * @param viewL defines the View matrix to use
  39450. * @param projectionL defines the Projection matrix to use
  39451. * @param viewR defines the right View matrix to use (if provided)
  39452. * @param projectionR defines the right Projection matrix to use (if provided)
  39453. */
  39454. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39455. /**
  39456. * Gets the uniform buffer used to store scene data
  39457. * @returns a UniformBuffer
  39458. */
  39459. getSceneUniformBuffer(): UniformBuffer;
  39460. /**
  39461. * Gets an unique (relatively to the current scene) Id
  39462. * @returns an unique number for the scene
  39463. */
  39464. getUniqueId(): number;
  39465. /**
  39466. * Add a mesh to the list of scene's meshes
  39467. * @param newMesh defines the mesh to add
  39468. * @param recursive if all child meshes should also be added to the scene
  39469. */
  39470. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39471. /**
  39472. * Remove a mesh for the list of scene's meshes
  39473. * @param toRemove defines the mesh to remove
  39474. * @param recursive if all child meshes should also be removed from the scene
  39475. * @returns the index where the mesh was in the mesh list
  39476. */
  39477. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39478. /**
  39479. * Add a transform node to the list of scene's transform nodes
  39480. * @param newTransformNode defines the transform node to add
  39481. */
  39482. addTransformNode(newTransformNode: TransformNode): void;
  39483. /**
  39484. * Remove a transform node for the list of scene's transform nodes
  39485. * @param toRemove defines the transform node to remove
  39486. * @returns the index where the transform node was in the transform node list
  39487. */
  39488. removeTransformNode(toRemove: TransformNode): number;
  39489. /**
  39490. * Remove a skeleton for the list of scene's skeletons
  39491. * @param toRemove defines the skeleton to remove
  39492. * @returns the index where the skeleton was in the skeleton list
  39493. */
  39494. removeSkeleton(toRemove: Skeleton): number;
  39495. /**
  39496. * Remove a morph target for the list of scene's morph targets
  39497. * @param toRemove defines the morph target to remove
  39498. * @returns the index where the morph target was in the morph target list
  39499. */
  39500. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39501. /**
  39502. * Remove a light for the list of scene's lights
  39503. * @param toRemove defines the light to remove
  39504. * @returns the index where the light was in the light list
  39505. */
  39506. removeLight(toRemove: Light): number;
  39507. /**
  39508. * Remove a camera for the list of scene's cameras
  39509. * @param toRemove defines the camera to remove
  39510. * @returns the index where the camera was in the camera list
  39511. */
  39512. removeCamera(toRemove: Camera): number;
  39513. /**
  39514. * Remove a particle system for the list of scene's particle systems
  39515. * @param toRemove defines the particle system to remove
  39516. * @returns the index where the particle system was in the particle system list
  39517. */
  39518. removeParticleSystem(toRemove: IParticleSystem): number;
  39519. /**
  39520. * Remove a animation for the list of scene's animations
  39521. * @param toRemove defines the animation to remove
  39522. * @returns the index where the animation was in the animation list
  39523. */
  39524. removeAnimation(toRemove: Animation): number;
  39525. /**
  39526. * Will stop the animation of the given target
  39527. * @param target - the target
  39528. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39529. * @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)
  39530. */
  39531. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39532. /**
  39533. * Removes the given animation group from this scene.
  39534. * @param toRemove The animation group to remove
  39535. * @returns The index of the removed animation group
  39536. */
  39537. removeAnimationGroup(toRemove: AnimationGroup): number;
  39538. /**
  39539. * Removes the given multi-material from this scene.
  39540. * @param toRemove The multi-material to remove
  39541. * @returns The index of the removed multi-material
  39542. */
  39543. removeMultiMaterial(toRemove: MultiMaterial): number;
  39544. /**
  39545. * Removes the given material from this scene.
  39546. * @param toRemove The material to remove
  39547. * @returns The index of the removed material
  39548. */
  39549. removeMaterial(toRemove: Material): number;
  39550. /**
  39551. * Removes the given action manager from this scene.
  39552. * @param toRemove The action manager to remove
  39553. * @returns The index of the removed action manager
  39554. */
  39555. removeActionManager(toRemove: AbstractActionManager): number;
  39556. /**
  39557. * Removes the given texture from this scene.
  39558. * @param toRemove The texture to remove
  39559. * @returns The index of the removed texture
  39560. */
  39561. removeTexture(toRemove: BaseTexture): number;
  39562. /**
  39563. * Adds the given light to this scene
  39564. * @param newLight The light to add
  39565. */
  39566. addLight(newLight: Light): void;
  39567. /**
  39568. * Sorts the list list based on light priorities
  39569. */
  39570. sortLightsByPriority(): void;
  39571. /**
  39572. * Adds the given camera to this scene
  39573. * @param newCamera The camera to add
  39574. */
  39575. addCamera(newCamera: Camera): void;
  39576. /**
  39577. * Adds the given skeleton to this scene
  39578. * @param newSkeleton The skeleton to add
  39579. */
  39580. addSkeleton(newSkeleton: Skeleton): void;
  39581. /**
  39582. * Adds the given particle system to this scene
  39583. * @param newParticleSystem The particle system to add
  39584. */
  39585. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39586. /**
  39587. * Adds the given animation to this scene
  39588. * @param newAnimation The animation to add
  39589. */
  39590. addAnimation(newAnimation: Animation): void;
  39591. /**
  39592. * Adds the given animation group to this scene.
  39593. * @param newAnimationGroup The animation group to add
  39594. */
  39595. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39596. /**
  39597. * Adds the given multi-material to this scene
  39598. * @param newMultiMaterial The multi-material to add
  39599. */
  39600. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39601. /**
  39602. * Adds the given material to this scene
  39603. * @param newMaterial The material to add
  39604. */
  39605. addMaterial(newMaterial: Material): void;
  39606. /**
  39607. * Adds the given morph target to this scene
  39608. * @param newMorphTargetManager The morph target to add
  39609. */
  39610. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39611. /**
  39612. * Adds the given geometry to this scene
  39613. * @param newGeometry The geometry to add
  39614. */
  39615. addGeometry(newGeometry: Geometry): void;
  39616. /**
  39617. * Adds the given action manager to this scene
  39618. * @param newActionManager The action manager to add
  39619. */
  39620. addActionManager(newActionManager: AbstractActionManager): void;
  39621. /**
  39622. * Adds the given texture to this scene.
  39623. * @param newTexture The texture to add
  39624. */
  39625. addTexture(newTexture: BaseTexture): void;
  39626. /**
  39627. * Switch active camera
  39628. * @param newCamera defines the new active camera
  39629. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39630. */
  39631. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39632. /**
  39633. * sets the active camera of the scene using its ID
  39634. * @param id defines the camera's ID
  39635. * @return the new active camera or null if none found.
  39636. */
  39637. setActiveCameraByID(id: string): Nullable<Camera>;
  39638. /**
  39639. * sets the active camera of the scene using its name
  39640. * @param name defines the camera's name
  39641. * @returns the new active camera or null if none found.
  39642. */
  39643. setActiveCameraByName(name: string): Nullable<Camera>;
  39644. /**
  39645. * get an animation group using its name
  39646. * @param name defines the material's name
  39647. * @return the animation group or null if none found.
  39648. */
  39649. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39650. /**
  39651. * Get a material using its unique id
  39652. * @param uniqueId defines the material's unique id
  39653. * @return the material or null if none found.
  39654. */
  39655. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39656. /**
  39657. * get a material using its id
  39658. * @param id defines the material's ID
  39659. * @return the material or null if none found.
  39660. */
  39661. getMaterialByID(id: string): Nullable<Material>;
  39662. /**
  39663. * Gets a the last added material using a given id
  39664. * @param id defines the material's ID
  39665. * @return the last material with the given id or null if none found.
  39666. */
  39667. getLastMaterialByID(id: string): Nullable<Material>;
  39668. /**
  39669. * Gets a material using its name
  39670. * @param name defines the material's name
  39671. * @return the material or null if none found.
  39672. */
  39673. getMaterialByName(name: string): Nullable<Material>;
  39674. /**
  39675. * Get a texture using its unique id
  39676. * @param uniqueId defines the texture's unique id
  39677. * @return the texture or null if none found.
  39678. */
  39679. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39680. /**
  39681. * Gets a camera using its id
  39682. * @param id defines the id to look for
  39683. * @returns the camera or null if not found
  39684. */
  39685. getCameraByID(id: string): Nullable<Camera>;
  39686. /**
  39687. * Gets a camera using its unique id
  39688. * @param uniqueId defines the unique id to look for
  39689. * @returns the camera or null if not found
  39690. */
  39691. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39692. /**
  39693. * Gets a camera using its name
  39694. * @param name defines the camera's name
  39695. * @return the camera or null if none found.
  39696. */
  39697. getCameraByName(name: string): Nullable<Camera>;
  39698. /**
  39699. * Gets a bone using its id
  39700. * @param id defines the bone's id
  39701. * @return the bone or null if not found
  39702. */
  39703. getBoneByID(id: string): Nullable<Bone>;
  39704. /**
  39705. * Gets a bone using its id
  39706. * @param name defines the bone's name
  39707. * @return the bone or null if not found
  39708. */
  39709. getBoneByName(name: string): Nullable<Bone>;
  39710. /**
  39711. * Gets a light node using its name
  39712. * @param name defines the the light's name
  39713. * @return the light or null if none found.
  39714. */
  39715. getLightByName(name: string): Nullable<Light>;
  39716. /**
  39717. * Gets a light node using its id
  39718. * @param id defines the light's id
  39719. * @return the light or null if none found.
  39720. */
  39721. getLightByID(id: string): Nullable<Light>;
  39722. /**
  39723. * Gets a light node using its scene-generated unique ID
  39724. * @param uniqueId defines the light's unique id
  39725. * @return the light or null if none found.
  39726. */
  39727. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39728. /**
  39729. * Gets a particle system by id
  39730. * @param id defines the particle system id
  39731. * @return the corresponding system or null if none found
  39732. */
  39733. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39734. /**
  39735. * Gets a geometry using its ID
  39736. * @param id defines the geometry's id
  39737. * @return the geometry or null if none found.
  39738. */
  39739. getGeometryByID(id: string): Nullable<Geometry>;
  39740. private _getGeometryByUniqueID;
  39741. /**
  39742. * Add a new geometry to this scene
  39743. * @param geometry defines the geometry to be added to the scene.
  39744. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39745. * @return a boolean defining if the geometry was added or not
  39746. */
  39747. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39748. /**
  39749. * Removes an existing geometry
  39750. * @param geometry defines the geometry to be removed from the scene
  39751. * @return a boolean defining if the geometry was removed or not
  39752. */
  39753. removeGeometry(geometry: Geometry): boolean;
  39754. /**
  39755. * Gets the list of geometries attached to the scene
  39756. * @returns an array of Geometry
  39757. */
  39758. getGeometries(): Geometry[];
  39759. /**
  39760. * Gets the first added mesh found of a given ID
  39761. * @param id defines the id to search for
  39762. * @return the mesh found or null if not found at all
  39763. */
  39764. getMeshByID(id: string): Nullable<AbstractMesh>;
  39765. /**
  39766. * Gets a list of meshes using their id
  39767. * @param id defines the id to search for
  39768. * @returns a list of meshes
  39769. */
  39770. getMeshesByID(id: string): Array<AbstractMesh>;
  39771. /**
  39772. * Gets the first added transform node found of a given ID
  39773. * @param id defines the id to search for
  39774. * @return the found transform node or null if not found at all.
  39775. */
  39776. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39777. /**
  39778. * Gets a transform node with its auto-generated unique id
  39779. * @param uniqueId efines the unique id to search for
  39780. * @return the found transform node or null if not found at all.
  39781. */
  39782. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39783. /**
  39784. * Gets a list of transform nodes using their id
  39785. * @param id defines the id to search for
  39786. * @returns a list of transform nodes
  39787. */
  39788. getTransformNodesByID(id: string): Array<TransformNode>;
  39789. /**
  39790. * Gets a mesh with its auto-generated unique id
  39791. * @param uniqueId defines the unique id to search for
  39792. * @return the found mesh or null if not found at all.
  39793. */
  39794. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39795. /**
  39796. * Gets a the last added mesh using a given id
  39797. * @param id defines the id to search for
  39798. * @return the found mesh or null if not found at all.
  39799. */
  39800. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39801. /**
  39802. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39803. * @param id defines the id to search for
  39804. * @return the found node or null if not found at all
  39805. */
  39806. getLastEntryByID(id: string): Nullable<Node>;
  39807. /**
  39808. * Gets a node (Mesh, Camera, Light) using a given id
  39809. * @param id defines the id to search for
  39810. * @return the found node or null if not found at all
  39811. */
  39812. getNodeByID(id: string): Nullable<Node>;
  39813. /**
  39814. * Gets a node (Mesh, Camera, Light) using a given name
  39815. * @param name defines the name to search for
  39816. * @return the found node or null if not found at all.
  39817. */
  39818. getNodeByName(name: string): Nullable<Node>;
  39819. /**
  39820. * Gets a mesh using a given name
  39821. * @param name defines the name to search for
  39822. * @return the found mesh or null if not found at all.
  39823. */
  39824. getMeshByName(name: string): Nullable<AbstractMesh>;
  39825. /**
  39826. * Gets a transform node using a given name
  39827. * @param name defines the name to search for
  39828. * @return the found transform node or null if not found at all.
  39829. */
  39830. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39831. /**
  39832. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39833. * @param id defines the id to search for
  39834. * @return the found skeleton or null if not found at all.
  39835. */
  39836. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39837. /**
  39838. * Gets a skeleton using a given auto generated unique id
  39839. * @param uniqueId defines the unique id to search for
  39840. * @return the found skeleton or null if not found at all.
  39841. */
  39842. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39843. /**
  39844. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39845. * @param id defines the id to search for
  39846. * @return the found skeleton or null if not found at all.
  39847. */
  39848. getSkeletonById(id: string): Nullable<Skeleton>;
  39849. /**
  39850. * Gets a skeleton using a given name
  39851. * @param name defines the name to search for
  39852. * @return the found skeleton or null if not found at all.
  39853. */
  39854. getSkeletonByName(name: string): Nullable<Skeleton>;
  39855. /**
  39856. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39857. * @param id defines the id to search for
  39858. * @return the found morph target manager or null if not found at all.
  39859. */
  39860. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39861. /**
  39862. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39863. * @param id defines the id to search for
  39864. * @return the found morph target or null if not found at all.
  39865. */
  39866. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39867. /**
  39868. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39869. * @param name defines the name to search for
  39870. * @return the found morph target or null if not found at all.
  39871. */
  39872. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39873. /**
  39874. * Gets a boolean indicating if the given mesh is active
  39875. * @param mesh defines the mesh to look for
  39876. * @returns true if the mesh is in the active list
  39877. */
  39878. isActiveMesh(mesh: AbstractMesh): boolean;
  39879. /**
  39880. * Return a unique id as a string which can serve as an identifier for the scene
  39881. */
  39882. get uid(): string;
  39883. /**
  39884. * Add an externaly attached data from its key.
  39885. * This method call will fail and return false, if such key already exists.
  39886. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39887. * @param key the unique key that identifies the data
  39888. * @param data the data object to associate to the key for this Engine instance
  39889. * @return true if no such key were already present and the data was added successfully, false otherwise
  39890. */
  39891. addExternalData<T>(key: string, data: T): boolean;
  39892. /**
  39893. * Get an externaly attached data from its key
  39894. * @param key the unique key that identifies the data
  39895. * @return the associated data, if present (can be null), or undefined if not present
  39896. */
  39897. getExternalData<T>(key: string): Nullable<T>;
  39898. /**
  39899. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39900. * @param key the unique key that identifies the data
  39901. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39902. * @return the associated data, can be null if the factory returned null.
  39903. */
  39904. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39905. /**
  39906. * Remove an externaly attached data from the Engine instance
  39907. * @param key the unique key that identifies the data
  39908. * @return true if the data was successfully removed, false if it doesn't exist
  39909. */
  39910. removeExternalData(key: string): boolean;
  39911. private _evaluateSubMesh;
  39912. /**
  39913. * Clear the processed materials smart array preventing retention point in material dispose.
  39914. */
  39915. freeProcessedMaterials(): void;
  39916. private _preventFreeActiveMeshesAndRenderingGroups;
  39917. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39918. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39919. * when disposing several meshes in a row or a hierarchy of meshes.
  39920. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39921. */
  39922. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39923. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39924. /**
  39925. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39926. */
  39927. freeActiveMeshes(): void;
  39928. /**
  39929. * Clear the info related to rendering groups preventing retention points during dispose.
  39930. */
  39931. freeRenderingGroups(): void;
  39932. /** @hidden */
  39933. _isInIntermediateRendering(): boolean;
  39934. /**
  39935. * Lambda returning the list of potentially active meshes.
  39936. */
  39937. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39938. /**
  39939. * Lambda returning the list of potentially active sub meshes.
  39940. */
  39941. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39942. /**
  39943. * Lambda returning the list of potentially intersecting sub meshes.
  39944. */
  39945. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39946. /**
  39947. * Lambda returning the list of potentially colliding sub meshes.
  39948. */
  39949. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39950. private _activeMeshesFrozen;
  39951. private _skipEvaluateActiveMeshesCompletely;
  39952. /**
  39953. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39954. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39955. * @returns the current scene
  39956. */
  39957. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39958. /**
  39959. * Use this function to restart evaluating active meshes on every frame
  39960. * @returns the current scene
  39961. */
  39962. unfreezeActiveMeshes(): Scene;
  39963. private _evaluateActiveMeshes;
  39964. private _activeMesh;
  39965. /**
  39966. * Update the transform matrix to update from the current active camera
  39967. * @param force defines a boolean used to force the update even if cache is up to date
  39968. */
  39969. updateTransformMatrix(force?: boolean): void;
  39970. private _bindFrameBuffer;
  39971. /** @hidden */
  39972. _allowPostProcessClearColor: boolean;
  39973. /** @hidden */
  39974. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39975. private _processSubCameras;
  39976. private _checkIntersections;
  39977. /** @hidden */
  39978. _advancePhysicsEngineStep(step: number): void;
  39979. /**
  39980. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39981. */
  39982. getDeterministicFrameTime: () => number;
  39983. /** @hidden */
  39984. _animate(): void;
  39985. /** Execute all animations (for a frame) */
  39986. animate(): void;
  39987. /**
  39988. * Render the scene
  39989. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39990. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39991. */
  39992. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39993. /**
  39994. * Freeze all materials
  39995. * A frozen material will not be updatable but should be faster to render
  39996. */
  39997. freezeMaterials(): void;
  39998. /**
  39999. * Unfreeze all materials
  40000. * A frozen material will not be updatable but should be faster to render
  40001. */
  40002. unfreezeMaterials(): void;
  40003. /**
  40004. * Releases all held ressources
  40005. */
  40006. dispose(): void;
  40007. /**
  40008. * Gets if the scene is already disposed
  40009. */
  40010. get isDisposed(): boolean;
  40011. /**
  40012. * Call this function to reduce memory footprint of the scene.
  40013. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40014. */
  40015. clearCachedVertexData(): void;
  40016. /**
  40017. * This function will remove the local cached buffer data from texture.
  40018. * It will save memory but will prevent the texture from being rebuilt
  40019. */
  40020. cleanCachedTextureBuffer(): void;
  40021. /**
  40022. * Get the world extend vectors with an optional filter
  40023. *
  40024. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40025. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40026. */
  40027. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40028. min: Vector3;
  40029. max: Vector3;
  40030. };
  40031. /**
  40032. * Creates a ray that can be used to pick in the scene
  40033. * @param x defines the x coordinate of the origin (on-screen)
  40034. * @param y defines the y coordinate of the origin (on-screen)
  40035. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40036. * @param camera defines the camera to use for the picking
  40037. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40038. * @returns a Ray
  40039. */
  40040. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40041. /**
  40042. * Creates a ray that can be used to pick in the scene
  40043. * @param x defines the x coordinate of the origin (on-screen)
  40044. * @param y defines the y coordinate of the origin (on-screen)
  40045. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40046. * @param result defines the ray where to store the picking ray
  40047. * @param camera defines the camera to use for the picking
  40048. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40049. * @returns the current scene
  40050. */
  40051. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40052. /**
  40053. * Creates a ray that can be used to pick in the scene
  40054. * @param x defines the x coordinate of the origin (on-screen)
  40055. * @param y defines the y coordinate of the origin (on-screen)
  40056. * @param camera defines the camera to use for the picking
  40057. * @returns a Ray
  40058. */
  40059. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40060. /**
  40061. * Creates a ray that can be used to pick in the scene
  40062. * @param x defines the x coordinate of the origin (on-screen)
  40063. * @param y defines the y coordinate of the origin (on-screen)
  40064. * @param result defines the ray where to store the picking ray
  40065. * @param camera defines the camera to use for the picking
  40066. * @returns the current scene
  40067. */
  40068. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40069. /** Launch a ray to try to pick a mesh in the scene
  40070. * @param x position on screen
  40071. * @param y position on screen
  40072. * @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
  40073. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40074. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40075. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40076. * @returns a PickingInfo
  40077. */
  40078. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40079. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40080. * @param x position on screen
  40081. * @param y position on screen
  40082. * @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
  40083. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40084. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40085. * @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)
  40086. */
  40087. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40088. /** Use the given ray to pick a mesh in the scene
  40089. * @param ray The ray to use to pick meshes
  40090. * @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
  40091. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40092. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40093. * @returns a PickingInfo
  40094. */
  40095. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40096. /**
  40097. * Launch a ray to try to pick a mesh in the scene
  40098. * @param x X position on screen
  40099. * @param y Y position on screen
  40100. * @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
  40101. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40102. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40103. * @returns an array of PickingInfo
  40104. */
  40105. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40106. /**
  40107. * Launch a ray to try to pick a mesh in the scene
  40108. * @param ray Ray to use
  40109. * @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
  40110. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40111. * @returns an array of PickingInfo
  40112. */
  40113. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40114. /**
  40115. * Force the value of meshUnderPointer
  40116. * @param mesh defines the mesh to use
  40117. */
  40118. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40119. /**
  40120. * Gets the mesh under the pointer
  40121. * @returns a Mesh or null if no mesh is under the pointer
  40122. */
  40123. getPointerOverMesh(): Nullable<AbstractMesh>;
  40124. /** @hidden */
  40125. _rebuildGeometries(): void;
  40126. /** @hidden */
  40127. _rebuildTextures(): void;
  40128. private _getByTags;
  40129. /**
  40130. * Get a list of meshes by tags
  40131. * @param tagsQuery defines the tags query to use
  40132. * @param forEach defines a predicate used to filter results
  40133. * @returns an array of Mesh
  40134. */
  40135. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40136. /**
  40137. * Get a list of cameras by tags
  40138. * @param tagsQuery defines the tags query to use
  40139. * @param forEach defines a predicate used to filter results
  40140. * @returns an array of Camera
  40141. */
  40142. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40143. /**
  40144. * Get a list of lights by tags
  40145. * @param tagsQuery defines the tags query to use
  40146. * @param forEach defines a predicate used to filter results
  40147. * @returns an array of Light
  40148. */
  40149. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40150. /**
  40151. * Get a list of materials by tags
  40152. * @param tagsQuery defines the tags query to use
  40153. * @param forEach defines a predicate used to filter results
  40154. * @returns an array of Material
  40155. */
  40156. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40157. /**
  40158. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40159. * This allowed control for front to back rendering or reversly depending of the special needs.
  40160. *
  40161. * @param renderingGroupId The rendering group id corresponding to its index
  40162. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40163. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40164. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40165. */
  40166. 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;
  40167. /**
  40168. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40169. *
  40170. * @param renderingGroupId The rendering group id corresponding to its index
  40171. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40172. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40173. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40174. */
  40175. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40176. /**
  40177. * Gets the current auto clear configuration for one rendering group of the rendering
  40178. * manager.
  40179. * @param index the rendering group index to get the information for
  40180. * @returns The auto clear setup for the requested rendering group
  40181. */
  40182. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40183. private _blockMaterialDirtyMechanism;
  40184. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40185. get blockMaterialDirtyMechanism(): boolean;
  40186. set blockMaterialDirtyMechanism(value: boolean);
  40187. /**
  40188. * Will flag all materials as dirty to trigger new shader compilation
  40189. * @param flag defines the flag used to specify which material part must be marked as dirty
  40190. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40191. */
  40192. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40193. /** @hidden */
  40194. _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;
  40195. /** @hidden */
  40196. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40197. /** @hidden */
  40198. _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;
  40199. /** @hidden */
  40200. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40201. /** @hidden */
  40202. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40203. /** @hidden */
  40204. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40205. }
  40206. }
  40207. declare module BABYLON {
  40208. /**
  40209. * Set of assets to keep when moving a scene into an asset container.
  40210. */
  40211. export class KeepAssets extends AbstractScene {
  40212. }
  40213. /**
  40214. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40215. */
  40216. export class InstantiatedEntries {
  40217. /**
  40218. * List of new root nodes (eg. nodes with no parent)
  40219. */
  40220. rootNodes: TransformNode[];
  40221. /**
  40222. * List of new skeletons
  40223. */
  40224. skeletons: Skeleton[];
  40225. /**
  40226. * List of new animation groups
  40227. */
  40228. animationGroups: AnimationGroup[];
  40229. }
  40230. /**
  40231. * Container with a set of assets that can be added or removed from a scene.
  40232. */
  40233. export class AssetContainer extends AbstractScene {
  40234. private _wasAddedToScene;
  40235. /**
  40236. * The scene the AssetContainer belongs to.
  40237. */
  40238. scene: Scene;
  40239. /**
  40240. * Instantiates an AssetContainer.
  40241. * @param scene The scene the AssetContainer belongs to.
  40242. */
  40243. constructor(scene: Scene);
  40244. /**
  40245. * Instantiate or clone all meshes and add the new ones to the scene.
  40246. * Skeletons and animation groups will all be cloned
  40247. * @param nameFunction defines an optional function used to get new names for clones
  40248. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40249. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40250. */
  40251. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40252. /**
  40253. * Adds all the assets from the container to the scene.
  40254. */
  40255. addAllToScene(): void;
  40256. /**
  40257. * Removes all the assets in the container from the scene
  40258. */
  40259. removeAllFromScene(): void;
  40260. /**
  40261. * Disposes all the assets in the container
  40262. */
  40263. dispose(): void;
  40264. private _moveAssets;
  40265. /**
  40266. * Removes all the assets contained in the scene and adds them to the container.
  40267. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40268. */
  40269. moveAllFromScene(keepAssets?: KeepAssets): void;
  40270. /**
  40271. * 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.
  40272. * @returns the root mesh
  40273. */
  40274. createRootMesh(): Mesh;
  40275. /**
  40276. * Merge animations (direct and animation groups) from this asset container into a scene
  40277. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40278. * @param animatables set of animatables to retarget to a node from the scene
  40279. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40280. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40281. */
  40282. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40283. }
  40284. }
  40285. declare module BABYLON {
  40286. /**
  40287. * Defines how the parser contract is defined.
  40288. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40289. */
  40290. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40291. /**
  40292. * Defines how the individual parser contract is defined.
  40293. * These parser can parse an individual asset
  40294. */
  40295. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40296. /**
  40297. * Base class of the scene acting as a container for the different elements composing a scene.
  40298. * This class is dynamically extended by the different components of the scene increasing
  40299. * flexibility and reducing coupling
  40300. */
  40301. export abstract class AbstractScene {
  40302. /**
  40303. * Stores the list of available parsers in the application.
  40304. */
  40305. private static _BabylonFileParsers;
  40306. /**
  40307. * Stores the list of available individual parsers in the application.
  40308. */
  40309. private static _IndividualBabylonFileParsers;
  40310. /**
  40311. * Adds a parser in the list of available ones
  40312. * @param name Defines the name of the parser
  40313. * @param parser Defines the parser to add
  40314. */
  40315. static AddParser(name: string, parser: BabylonFileParser): void;
  40316. /**
  40317. * Gets a general parser from the list of avaialble ones
  40318. * @param name Defines the name of the parser
  40319. * @returns the requested parser or null
  40320. */
  40321. static GetParser(name: string): Nullable<BabylonFileParser>;
  40322. /**
  40323. * Adds n individual parser in the list of available ones
  40324. * @param name Defines the name of the parser
  40325. * @param parser Defines the parser to add
  40326. */
  40327. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40328. /**
  40329. * Gets an individual parser from the list of avaialble ones
  40330. * @param name Defines the name of the parser
  40331. * @returns the requested parser or null
  40332. */
  40333. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40334. /**
  40335. * Parser json data and populate both a scene and its associated container object
  40336. * @param jsonData Defines the data to parse
  40337. * @param scene Defines the scene to parse the data for
  40338. * @param container Defines the container attached to the parsing sequence
  40339. * @param rootUrl Defines the root url of the data
  40340. */
  40341. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40342. /**
  40343. * Gets the list of root nodes (ie. nodes with no parent)
  40344. */
  40345. rootNodes: Node[];
  40346. /** All of the cameras added to this scene
  40347. * @see http://doc.babylonjs.com/babylon101/cameras
  40348. */
  40349. cameras: Camera[];
  40350. /**
  40351. * All of the lights added to this scene
  40352. * @see http://doc.babylonjs.com/babylon101/lights
  40353. */
  40354. lights: Light[];
  40355. /**
  40356. * All of the (abstract) meshes added to this scene
  40357. */
  40358. meshes: AbstractMesh[];
  40359. /**
  40360. * The list of skeletons added to the scene
  40361. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40362. */
  40363. skeletons: Skeleton[];
  40364. /**
  40365. * All of the particle systems added to this scene
  40366. * @see http://doc.babylonjs.com/babylon101/particles
  40367. */
  40368. particleSystems: IParticleSystem[];
  40369. /**
  40370. * Gets a list of Animations associated with the scene
  40371. */
  40372. animations: Animation[];
  40373. /**
  40374. * All of the animation groups added to this scene
  40375. * @see http://doc.babylonjs.com/how_to/group
  40376. */
  40377. animationGroups: AnimationGroup[];
  40378. /**
  40379. * All of the multi-materials added to this scene
  40380. * @see http://doc.babylonjs.com/how_to/multi_materials
  40381. */
  40382. multiMaterials: MultiMaterial[];
  40383. /**
  40384. * All of the materials added to this scene
  40385. * In the context of a Scene, it is not supposed to be modified manually.
  40386. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40387. * Note also that the order of the Material within the array is not significant and might change.
  40388. * @see http://doc.babylonjs.com/babylon101/materials
  40389. */
  40390. materials: Material[];
  40391. /**
  40392. * The list of morph target managers added to the scene
  40393. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40394. */
  40395. morphTargetManagers: MorphTargetManager[];
  40396. /**
  40397. * The list of geometries used in the scene.
  40398. */
  40399. geometries: Geometry[];
  40400. /**
  40401. * All of the tranform nodes added to this scene
  40402. * In the context of a Scene, it is not supposed to be modified manually.
  40403. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40404. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40405. * @see http://doc.babylonjs.com/how_to/transformnode
  40406. */
  40407. transformNodes: TransformNode[];
  40408. /**
  40409. * ActionManagers available on the scene.
  40410. */
  40411. actionManagers: AbstractActionManager[];
  40412. /**
  40413. * Textures to keep.
  40414. */
  40415. textures: BaseTexture[];
  40416. /**
  40417. * Environment texture for the scene
  40418. */
  40419. environmentTexture: Nullable<BaseTexture>;
  40420. /**
  40421. * @returns all meshes, lights, cameras, transformNodes and bones
  40422. */
  40423. getNodes(): Array<Node>;
  40424. }
  40425. }
  40426. declare module BABYLON {
  40427. /**
  40428. * Interface used to define options for Sound class
  40429. */
  40430. export interface ISoundOptions {
  40431. /**
  40432. * Does the sound autoplay once loaded.
  40433. */
  40434. autoplay?: boolean;
  40435. /**
  40436. * Does the sound loop after it finishes playing once.
  40437. */
  40438. loop?: boolean;
  40439. /**
  40440. * Sound's volume
  40441. */
  40442. volume?: number;
  40443. /**
  40444. * Is it a spatial sound?
  40445. */
  40446. spatialSound?: boolean;
  40447. /**
  40448. * Maximum distance to hear that sound
  40449. */
  40450. maxDistance?: number;
  40451. /**
  40452. * Uses user defined attenuation function
  40453. */
  40454. useCustomAttenuation?: boolean;
  40455. /**
  40456. * Define the roll off factor of spatial sounds.
  40457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40458. */
  40459. rolloffFactor?: number;
  40460. /**
  40461. * Define the reference distance the sound should be heard perfectly.
  40462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40463. */
  40464. refDistance?: number;
  40465. /**
  40466. * Define the distance attenuation model the sound will follow.
  40467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40468. */
  40469. distanceModel?: string;
  40470. /**
  40471. * Defines the playback speed (1 by default)
  40472. */
  40473. playbackRate?: number;
  40474. /**
  40475. * Defines if the sound is from a streaming source
  40476. */
  40477. streaming?: boolean;
  40478. /**
  40479. * Defines an optional length (in seconds) inside the sound file
  40480. */
  40481. length?: number;
  40482. /**
  40483. * Defines an optional offset (in seconds) inside the sound file
  40484. */
  40485. offset?: number;
  40486. /**
  40487. * If true, URLs will not be required to state the audio file codec to use.
  40488. */
  40489. skipCodecCheck?: boolean;
  40490. }
  40491. /**
  40492. * Defines a sound that can be played in the application.
  40493. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40495. */
  40496. export class Sound {
  40497. /**
  40498. * The name of the sound in the scene.
  40499. */
  40500. name: string;
  40501. /**
  40502. * Does the sound autoplay once loaded.
  40503. */
  40504. autoplay: boolean;
  40505. /**
  40506. * Does the sound loop after it finishes playing once.
  40507. */
  40508. loop: boolean;
  40509. /**
  40510. * Does the sound use a custom attenuation curve to simulate the falloff
  40511. * happening when the source gets further away from the camera.
  40512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40513. */
  40514. useCustomAttenuation: boolean;
  40515. /**
  40516. * The sound track id this sound belongs to.
  40517. */
  40518. soundTrackId: number;
  40519. /**
  40520. * Is this sound currently played.
  40521. */
  40522. isPlaying: boolean;
  40523. /**
  40524. * Is this sound currently paused.
  40525. */
  40526. isPaused: boolean;
  40527. /**
  40528. * Does this sound enables spatial sound.
  40529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40530. */
  40531. spatialSound: boolean;
  40532. /**
  40533. * Define the reference distance the sound should be heard perfectly.
  40534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40535. */
  40536. refDistance: number;
  40537. /**
  40538. * Define the roll off factor of spatial sounds.
  40539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40540. */
  40541. rolloffFactor: number;
  40542. /**
  40543. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40545. */
  40546. maxDistance: number;
  40547. /**
  40548. * Define the distance attenuation model the sound will follow.
  40549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40550. */
  40551. distanceModel: string;
  40552. /**
  40553. * @hidden
  40554. * Back Compat
  40555. **/
  40556. onended: () => any;
  40557. /**
  40558. * Gets or sets an object used to store user defined information for the sound.
  40559. */
  40560. metadata: any;
  40561. /**
  40562. * Observable event when the current playing sound finishes.
  40563. */
  40564. onEndedObservable: Observable<Sound>;
  40565. private _panningModel;
  40566. private _playbackRate;
  40567. private _streaming;
  40568. private _startTime;
  40569. private _startOffset;
  40570. private _position;
  40571. /** @hidden */
  40572. _positionInEmitterSpace: boolean;
  40573. private _localDirection;
  40574. private _volume;
  40575. private _isReadyToPlay;
  40576. private _isDirectional;
  40577. private _readyToPlayCallback;
  40578. private _audioBuffer;
  40579. private _soundSource;
  40580. private _streamingSource;
  40581. private _soundPanner;
  40582. private _soundGain;
  40583. private _inputAudioNode;
  40584. private _outputAudioNode;
  40585. private _coneInnerAngle;
  40586. private _coneOuterAngle;
  40587. private _coneOuterGain;
  40588. private _scene;
  40589. private _connectedTransformNode;
  40590. private _customAttenuationFunction;
  40591. private _registerFunc;
  40592. private _isOutputConnected;
  40593. private _htmlAudioElement;
  40594. private _urlType;
  40595. private _length?;
  40596. private _offset?;
  40597. /** @hidden */
  40598. static _SceneComponentInitialization: (scene: Scene) => void;
  40599. /**
  40600. * Create a sound and attach it to a scene
  40601. * @param name Name of your sound
  40602. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40603. * @param scene defines the scene the sound belongs to
  40604. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40605. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40606. */
  40607. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40608. /**
  40609. * Release the sound and its associated resources
  40610. */
  40611. dispose(): void;
  40612. /**
  40613. * Gets if the sounds is ready to be played or not.
  40614. * @returns true if ready, otherwise false
  40615. */
  40616. isReady(): boolean;
  40617. private _soundLoaded;
  40618. /**
  40619. * Sets the data of the sound from an audiobuffer
  40620. * @param audioBuffer The audioBuffer containing the data
  40621. */
  40622. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40623. /**
  40624. * Updates the current sounds options such as maxdistance, loop...
  40625. * @param options A JSON object containing values named as the object properties
  40626. */
  40627. updateOptions(options: ISoundOptions): void;
  40628. private _createSpatialParameters;
  40629. private _updateSpatialParameters;
  40630. /**
  40631. * Switch the panning model to HRTF:
  40632. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40634. */
  40635. switchPanningModelToHRTF(): void;
  40636. /**
  40637. * Switch the panning model to Equal Power:
  40638. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40640. */
  40641. switchPanningModelToEqualPower(): void;
  40642. private _switchPanningModel;
  40643. /**
  40644. * Connect this sound to a sound track audio node like gain...
  40645. * @param soundTrackAudioNode the sound track audio node to connect to
  40646. */
  40647. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40648. /**
  40649. * Transform this sound into a directional source
  40650. * @param coneInnerAngle Size of the inner cone in degree
  40651. * @param coneOuterAngle Size of the outer cone in degree
  40652. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40653. */
  40654. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40655. /**
  40656. * Gets or sets the inner angle for the directional cone.
  40657. */
  40658. get directionalConeInnerAngle(): number;
  40659. /**
  40660. * Gets or sets the inner angle for the directional cone.
  40661. */
  40662. set directionalConeInnerAngle(value: number);
  40663. /**
  40664. * Gets or sets the outer angle for the directional cone.
  40665. */
  40666. get directionalConeOuterAngle(): number;
  40667. /**
  40668. * Gets or sets the outer angle for the directional cone.
  40669. */
  40670. set directionalConeOuterAngle(value: number);
  40671. /**
  40672. * Sets the position of the emitter if spatial sound is enabled
  40673. * @param newPosition Defines the new posisiton
  40674. */
  40675. setPosition(newPosition: Vector3): void;
  40676. /**
  40677. * Sets the local direction of the emitter if spatial sound is enabled
  40678. * @param newLocalDirection Defines the new local direction
  40679. */
  40680. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40681. private _updateDirection;
  40682. /** @hidden */
  40683. updateDistanceFromListener(): void;
  40684. /**
  40685. * Sets a new custom attenuation function for the sound.
  40686. * @param callback Defines the function used for the attenuation
  40687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40688. */
  40689. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40690. /**
  40691. * Play the sound
  40692. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40693. * @param offset (optional) Start the sound at a specific time in seconds
  40694. * @param length (optional) Sound duration (in seconds)
  40695. */
  40696. play(time?: number, offset?: number, length?: number): void;
  40697. private _onended;
  40698. /**
  40699. * Stop the sound
  40700. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40701. */
  40702. stop(time?: number): void;
  40703. /**
  40704. * Put the sound in pause
  40705. */
  40706. pause(): void;
  40707. /**
  40708. * Sets a dedicated volume for this sounds
  40709. * @param newVolume Define the new volume of the sound
  40710. * @param time Define time for gradual change to new volume
  40711. */
  40712. setVolume(newVolume: number, time?: number): void;
  40713. /**
  40714. * Set the sound play back rate
  40715. * @param newPlaybackRate Define the playback rate the sound should be played at
  40716. */
  40717. setPlaybackRate(newPlaybackRate: number): void;
  40718. /**
  40719. * Gets the volume of the sound.
  40720. * @returns the volume of the sound
  40721. */
  40722. getVolume(): number;
  40723. /**
  40724. * Attach the sound to a dedicated mesh
  40725. * @param transformNode The transform node to connect the sound with
  40726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40727. */
  40728. attachToMesh(transformNode: TransformNode): void;
  40729. /**
  40730. * Detach the sound from the previously attached mesh
  40731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40732. */
  40733. detachFromMesh(): void;
  40734. private _onRegisterAfterWorldMatrixUpdate;
  40735. /**
  40736. * Clone the current sound in the scene.
  40737. * @returns the new sound clone
  40738. */
  40739. clone(): Nullable<Sound>;
  40740. /**
  40741. * Gets the current underlying audio buffer containing the data
  40742. * @returns the audio buffer
  40743. */
  40744. getAudioBuffer(): Nullable<AudioBuffer>;
  40745. /**
  40746. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40747. * @returns the source node
  40748. */
  40749. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40750. /**
  40751. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40752. * @returns the gain node
  40753. */
  40754. getSoundGain(): Nullable<GainNode>;
  40755. /**
  40756. * Serializes the Sound in a JSON representation
  40757. * @returns the JSON representation of the sound
  40758. */
  40759. serialize(): any;
  40760. /**
  40761. * Parse a JSON representation of a sound to innstantiate in a given scene
  40762. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40763. * @param scene Define the scene the new parsed sound should be created in
  40764. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40765. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40766. * @returns the newly parsed sound
  40767. */
  40768. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40769. }
  40770. }
  40771. declare module BABYLON {
  40772. /**
  40773. * This defines an action helpful to play a defined sound on a triggered action.
  40774. */
  40775. export class PlaySoundAction extends Action {
  40776. private _sound;
  40777. /**
  40778. * Instantiate the action
  40779. * @param triggerOptions defines the trigger options
  40780. * @param sound defines the sound to play
  40781. * @param condition defines the trigger related conditions
  40782. */
  40783. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40784. /** @hidden */
  40785. _prepare(): void;
  40786. /**
  40787. * Execute the action and play the sound.
  40788. */
  40789. execute(): void;
  40790. /**
  40791. * Serializes the actions and its related information.
  40792. * @param parent defines the object to serialize in
  40793. * @returns the serialized object
  40794. */
  40795. serialize(parent: any): any;
  40796. }
  40797. /**
  40798. * This defines an action helpful to stop a defined sound on a triggered action.
  40799. */
  40800. export class StopSoundAction extends Action {
  40801. private _sound;
  40802. /**
  40803. * Instantiate the action
  40804. * @param triggerOptions defines the trigger options
  40805. * @param sound defines the sound to stop
  40806. * @param condition defines the trigger related conditions
  40807. */
  40808. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40809. /** @hidden */
  40810. _prepare(): void;
  40811. /**
  40812. * Execute the action and stop the sound.
  40813. */
  40814. execute(): void;
  40815. /**
  40816. * Serializes the actions and its related information.
  40817. * @param parent defines the object to serialize in
  40818. * @returns the serialized object
  40819. */
  40820. serialize(parent: any): any;
  40821. }
  40822. }
  40823. declare module BABYLON {
  40824. /**
  40825. * This defines an action responsible to change the value of a property
  40826. * by interpolating between its current value and the newly set one once triggered.
  40827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40828. */
  40829. export class InterpolateValueAction extends Action {
  40830. /**
  40831. * Defines the path of the property where the value should be interpolated
  40832. */
  40833. propertyPath: string;
  40834. /**
  40835. * Defines the target value at the end of the interpolation.
  40836. */
  40837. value: any;
  40838. /**
  40839. * Defines the time it will take for the property to interpolate to the value.
  40840. */
  40841. duration: number;
  40842. /**
  40843. * Defines if the other scene animations should be stopped when the action has been triggered
  40844. */
  40845. stopOtherAnimations?: boolean;
  40846. /**
  40847. * Defines a callback raised once the interpolation animation has been done.
  40848. */
  40849. onInterpolationDone?: () => void;
  40850. /**
  40851. * Observable triggered once the interpolation animation has been done.
  40852. */
  40853. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40854. private _target;
  40855. private _effectiveTarget;
  40856. private _property;
  40857. /**
  40858. * Instantiate the action
  40859. * @param triggerOptions defines the trigger options
  40860. * @param target defines the object containing the value to interpolate
  40861. * @param propertyPath defines the path to the property in the target object
  40862. * @param value defines the target value at the end of the interpolation
  40863. * @param duration deines the time it will take for the property to interpolate to the value.
  40864. * @param condition defines the trigger related conditions
  40865. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40866. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40867. */
  40868. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40869. /** @hidden */
  40870. _prepare(): void;
  40871. /**
  40872. * Execute the action starts the value interpolation.
  40873. */
  40874. execute(): void;
  40875. /**
  40876. * Serializes the actions and its related information.
  40877. * @param parent defines the object to serialize in
  40878. * @returns the serialized object
  40879. */
  40880. serialize(parent: any): any;
  40881. }
  40882. }
  40883. declare module BABYLON {
  40884. /**
  40885. * Options allowed during the creation of a sound track.
  40886. */
  40887. export interface ISoundTrackOptions {
  40888. /**
  40889. * The volume the sound track should take during creation
  40890. */
  40891. volume?: number;
  40892. /**
  40893. * Define if the sound track is the main sound track of the scene
  40894. */
  40895. mainTrack?: boolean;
  40896. }
  40897. /**
  40898. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40899. * It will be also used in a future release to apply effects on a specific track.
  40900. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40901. */
  40902. export class SoundTrack {
  40903. /**
  40904. * The unique identifier of the sound track in the scene.
  40905. */
  40906. id: number;
  40907. /**
  40908. * The list of sounds included in the sound track.
  40909. */
  40910. soundCollection: Array<Sound>;
  40911. private _outputAudioNode;
  40912. private _scene;
  40913. private _connectedAnalyser;
  40914. private _options;
  40915. private _isInitialized;
  40916. /**
  40917. * Creates a new sound track.
  40918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40919. * @param scene Define the scene the sound track belongs to
  40920. * @param options
  40921. */
  40922. constructor(scene: Scene, options?: ISoundTrackOptions);
  40923. private _initializeSoundTrackAudioGraph;
  40924. /**
  40925. * Release the sound track and its associated resources
  40926. */
  40927. dispose(): void;
  40928. /**
  40929. * Adds a sound to this sound track
  40930. * @param sound define the cound to add
  40931. * @ignoreNaming
  40932. */
  40933. AddSound(sound: Sound): void;
  40934. /**
  40935. * Removes a sound to this sound track
  40936. * @param sound define the cound to remove
  40937. * @ignoreNaming
  40938. */
  40939. RemoveSound(sound: Sound): void;
  40940. /**
  40941. * Set a global volume for the full sound track.
  40942. * @param newVolume Define the new volume of the sound track
  40943. */
  40944. setVolume(newVolume: number): void;
  40945. /**
  40946. * Switch the panning model to HRTF:
  40947. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40949. */
  40950. switchPanningModelToHRTF(): void;
  40951. /**
  40952. * Switch the panning model to Equal Power:
  40953. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40955. */
  40956. switchPanningModelToEqualPower(): void;
  40957. /**
  40958. * Connect the sound track to an audio analyser allowing some amazing
  40959. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40961. * @param analyser The analyser to connect to the engine
  40962. */
  40963. connectToAnalyser(analyser: Analyser): void;
  40964. }
  40965. }
  40966. declare module BABYLON {
  40967. interface AbstractScene {
  40968. /**
  40969. * The list of sounds used in the scene.
  40970. */
  40971. sounds: Nullable<Array<Sound>>;
  40972. }
  40973. interface Scene {
  40974. /**
  40975. * @hidden
  40976. * Backing field
  40977. */
  40978. _mainSoundTrack: SoundTrack;
  40979. /**
  40980. * The main sound track played by the scene.
  40981. * It cotains your primary collection of sounds.
  40982. */
  40983. mainSoundTrack: SoundTrack;
  40984. /**
  40985. * The list of sound tracks added to the scene
  40986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40987. */
  40988. soundTracks: Nullable<Array<SoundTrack>>;
  40989. /**
  40990. * Gets a sound using a given name
  40991. * @param name defines the name to search for
  40992. * @return the found sound or null if not found at all.
  40993. */
  40994. getSoundByName(name: string): Nullable<Sound>;
  40995. /**
  40996. * Gets or sets if audio support is enabled
  40997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40998. */
  40999. audioEnabled: boolean;
  41000. /**
  41001. * Gets or sets if audio will be output to headphones
  41002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41003. */
  41004. headphone: boolean;
  41005. /**
  41006. * Gets or sets custom audio listener position provider
  41007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41008. */
  41009. audioListenerPositionProvider: Nullable<() => Vector3>;
  41010. /**
  41011. * Gets or sets a refresh rate when using 3D audio positioning
  41012. */
  41013. audioPositioningRefreshRate: number;
  41014. }
  41015. /**
  41016. * Defines the sound scene component responsible to manage any sounds
  41017. * in a given scene.
  41018. */
  41019. export class AudioSceneComponent implements ISceneSerializableComponent {
  41020. /**
  41021. * The component name helpfull to identify the component in the list of scene components.
  41022. */
  41023. readonly name: string;
  41024. /**
  41025. * The scene the component belongs to.
  41026. */
  41027. scene: Scene;
  41028. private _audioEnabled;
  41029. /**
  41030. * Gets whether audio is enabled or not.
  41031. * Please use related enable/disable method to switch state.
  41032. */
  41033. get audioEnabled(): boolean;
  41034. private _headphone;
  41035. /**
  41036. * Gets whether audio is outputing to headphone or not.
  41037. * Please use the according Switch methods to change output.
  41038. */
  41039. get headphone(): boolean;
  41040. /**
  41041. * Gets or sets a refresh rate when using 3D audio positioning
  41042. */
  41043. audioPositioningRefreshRate: number;
  41044. private _audioListenerPositionProvider;
  41045. /**
  41046. * Gets the current audio listener position provider
  41047. */
  41048. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41049. /**
  41050. * Sets a custom listener position for all sounds in the scene
  41051. * By default, this is the position of the first active camera
  41052. */
  41053. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41054. /**
  41055. * Creates a new instance of the component for the given scene
  41056. * @param scene Defines the scene to register the component in
  41057. */
  41058. constructor(scene: Scene);
  41059. /**
  41060. * Registers the component in a given scene
  41061. */
  41062. register(): void;
  41063. /**
  41064. * Rebuilds the elements related to this component in case of
  41065. * context lost for instance.
  41066. */
  41067. rebuild(): void;
  41068. /**
  41069. * Serializes the component data to the specified json object
  41070. * @param serializationObject The object to serialize to
  41071. */
  41072. serialize(serializationObject: any): void;
  41073. /**
  41074. * Adds all the elements from the container to the scene
  41075. * @param container the container holding the elements
  41076. */
  41077. addFromContainer(container: AbstractScene): void;
  41078. /**
  41079. * Removes all the elements in the container from the scene
  41080. * @param container contains the elements to remove
  41081. * @param dispose if the removed element should be disposed (default: false)
  41082. */
  41083. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41084. /**
  41085. * Disposes the component and the associated ressources.
  41086. */
  41087. dispose(): void;
  41088. /**
  41089. * Disables audio in the associated scene.
  41090. */
  41091. disableAudio(): void;
  41092. /**
  41093. * Enables audio in the associated scene.
  41094. */
  41095. enableAudio(): void;
  41096. /**
  41097. * Switch audio to headphone output.
  41098. */
  41099. switchAudioModeForHeadphones(): void;
  41100. /**
  41101. * Switch audio to normal speakers.
  41102. */
  41103. switchAudioModeForNormalSpeakers(): void;
  41104. private _cachedCameraDirection;
  41105. private _cachedCameraPosition;
  41106. private _lastCheck;
  41107. private _afterRender;
  41108. }
  41109. }
  41110. declare module BABYLON {
  41111. /**
  41112. * Wraps one or more Sound objects and selects one with random weight for playback.
  41113. */
  41114. export class WeightedSound {
  41115. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41116. loop: boolean;
  41117. private _coneInnerAngle;
  41118. private _coneOuterAngle;
  41119. private _volume;
  41120. /** A Sound is currently playing. */
  41121. isPlaying: boolean;
  41122. /** A Sound is currently paused. */
  41123. isPaused: boolean;
  41124. private _sounds;
  41125. private _weights;
  41126. private _currentIndex?;
  41127. /**
  41128. * Creates a new WeightedSound from the list of sounds given.
  41129. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41130. * @param sounds Array of Sounds that will be selected from.
  41131. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41132. */
  41133. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41134. /**
  41135. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41136. */
  41137. get directionalConeInnerAngle(): number;
  41138. /**
  41139. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41140. */
  41141. set directionalConeInnerAngle(value: number);
  41142. /**
  41143. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41144. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41145. */
  41146. get directionalConeOuterAngle(): number;
  41147. /**
  41148. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41149. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41150. */
  41151. set directionalConeOuterAngle(value: number);
  41152. /**
  41153. * Playback volume.
  41154. */
  41155. get volume(): number;
  41156. /**
  41157. * Playback volume.
  41158. */
  41159. set volume(value: number);
  41160. private _onended;
  41161. /**
  41162. * Suspend playback
  41163. */
  41164. pause(): void;
  41165. /**
  41166. * Stop playback
  41167. */
  41168. stop(): void;
  41169. /**
  41170. * Start playback.
  41171. * @param startOffset Position the clip head at a specific time in seconds.
  41172. */
  41173. play(startOffset?: number): void;
  41174. }
  41175. }
  41176. declare module BABYLON {
  41177. /**
  41178. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41179. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41180. */
  41181. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41182. /**
  41183. * Gets the name of the behavior.
  41184. */
  41185. get name(): string;
  41186. /**
  41187. * The easing function used by animations
  41188. */
  41189. static EasingFunction: BackEase;
  41190. /**
  41191. * The easing mode used by animations
  41192. */
  41193. static EasingMode: number;
  41194. /**
  41195. * The duration of the animation, in milliseconds
  41196. */
  41197. transitionDuration: number;
  41198. /**
  41199. * Length of the distance animated by the transition when lower radius is reached
  41200. */
  41201. lowerRadiusTransitionRange: number;
  41202. /**
  41203. * Length of the distance animated by the transition when upper radius is reached
  41204. */
  41205. upperRadiusTransitionRange: number;
  41206. private _autoTransitionRange;
  41207. /**
  41208. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41209. */
  41210. get autoTransitionRange(): boolean;
  41211. /**
  41212. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41213. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41214. */
  41215. set autoTransitionRange(value: boolean);
  41216. private _attachedCamera;
  41217. private _onAfterCheckInputsObserver;
  41218. private _onMeshTargetChangedObserver;
  41219. /**
  41220. * Initializes the behavior.
  41221. */
  41222. init(): void;
  41223. /**
  41224. * Attaches the behavior to its arc rotate camera.
  41225. * @param camera Defines the camera to attach the behavior to
  41226. */
  41227. attach(camera: ArcRotateCamera): void;
  41228. /**
  41229. * Detaches the behavior from its current arc rotate camera.
  41230. */
  41231. detach(): void;
  41232. private _radiusIsAnimating;
  41233. private _radiusBounceTransition;
  41234. private _animatables;
  41235. private _cachedWheelPrecision;
  41236. /**
  41237. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41238. * @param radiusLimit The limit to check against.
  41239. * @return Bool to indicate if at limit.
  41240. */
  41241. private _isRadiusAtLimit;
  41242. /**
  41243. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41244. * @param radiusDelta The delta by which to animate to. Can be negative.
  41245. */
  41246. private _applyBoundRadiusAnimation;
  41247. /**
  41248. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41249. */
  41250. protected _clearAnimationLocks(): void;
  41251. /**
  41252. * Stops and removes all animations that have been applied to the camera
  41253. */
  41254. stopAllAnimations(): void;
  41255. }
  41256. }
  41257. declare module BABYLON {
  41258. /**
  41259. * 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.
  41260. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41261. */
  41262. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41263. /**
  41264. * Gets the name of the behavior.
  41265. */
  41266. get name(): string;
  41267. private _mode;
  41268. private _radiusScale;
  41269. private _positionScale;
  41270. private _defaultElevation;
  41271. private _elevationReturnTime;
  41272. private _elevationReturnWaitTime;
  41273. private _zoomStopsAnimation;
  41274. private _framingTime;
  41275. /**
  41276. * The easing function used by animations
  41277. */
  41278. static EasingFunction: ExponentialEase;
  41279. /**
  41280. * The easing mode used by animations
  41281. */
  41282. static EasingMode: number;
  41283. /**
  41284. * Sets the current mode used by the behavior
  41285. */
  41286. set mode(mode: number);
  41287. /**
  41288. * Gets current mode used by the behavior.
  41289. */
  41290. get mode(): number;
  41291. /**
  41292. * Sets the scale applied to the radius (1 by default)
  41293. */
  41294. set radiusScale(radius: number);
  41295. /**
  41296. * Gets the scale applied to the radius
  41297. */
  41298. get radiusScale(): number;
  41299. /**
  41300. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41301. */
  41302. set positionScale(scale: number);
  41303. /**
  41304. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41305. */
  41306. get positionScale(): number;
  41307. /**
  41308. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41309. * behaviour is triggered, in radians.
  41310. */
  41311. set defaultElevation(elevation: number);
  41312. /**
  41313. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41314. * behaviour is triggered, in radians.
  41315. */
  41316. get defaultElevation(): number;
  41317. /**
  41318. * Sets the time (in milliseconds) taken to return to the default beta position.
  41319. * Negative value indicates camera should not return to default.
  41320. */
  41321. set elevationReturnTime(speed: number);
  41322. /**
  41323. * Gets the time (in milliseconds) taken to return to the default beta position.
  41324. * Negative value indicates camera should not return to default.
  41325. */
  41326. get elevationReturnTime(): number;
  41327. /**
  41328. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41329. */
  41330. set elevationReturnWaitTime(time: number);
  41331. /**
  41332. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41333. */
  41334. get elevationReturnWaitTime(): number;
  41335. /**
  41336. * Sets the flag that indicates if user zooming should stop animation.
  41337. */
  41338. set zoomStopsAnimation(flag: boolean);
  41339. /**
  41340. * Gets the flag that indicates if user zooming should stop animation.
  41341. */
  41342. get zoomStopsAnimation(): boolean;
  41343. /**
  41344. * Sets the transition time when framing the mesh, in milliseconds
  41345. */
  41346. set framingTime(time: number);
  41347. /**
  41348. * Gets the transition time when framing the mesh, in milliseconds
  41349. */
  41350. get framingTime(): number;
  41351. /**
  41352. * Define if the behavior should automatically change the configured
  41353. * camera limits and sensibilities.
  41354. */
  41355. autoCorrectCameraLimitsAndSensibility: boolean;
  41356. private _onPrePointerObservableObserver;
  41357. private _onAfterCheckInputsObserver;
  41358. private _onMeshTargetChangedObserver;
  41359. private _attachedCamera;
  41360. private _isPointerDown;
  41361. private _lastInteractionTime;
  41362. /**
  41363. * Initializes the behavior.
  41364. */
  41365. init(): void;
  41366. /**
  41367. * Attaches the behavior to its arc rotate camera.
  41368. * @param camera Defines the camera to attach the behavior to
  41369. */
  41370. attach(camera: ArcRotateCamera): void;
  41371. /**
  41372. * Detaches the behavior from its current arc rotate camera.
  41373. */
  41374. detach(): void;
  41375. private _animatables;
  41376. private _betaIsAnimating;
  41377. private _betaTransition;
  41378. private _radiusTransition;
  41379. private _vectorTransition;
  41380. /**
  41381. * Targets the given mesh and updates zoom level accordingly.
  41382. * @param mesh The mesh to target.
  41383. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41384. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41385. */
  41386. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41387. /**
  41388. * Targets the given mesh with its children and updates zoom level accordingly.
  41389. * @param mesh The mesh to target.
  41390. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41391. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41392. */
  41393. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41394. /**
  41395. * Targets the given meshes with their children and updates zoom level accordingly.
  41396. * @param meshes The mesh to target.
  41397. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41398. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41399. */
  41400. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41401. /**
  41402. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41403. * @param minimumWorld Determines the smaller position of the bounding box extend
  41404. * @param maximumWorld Determines the bigger position of the bounding box extend
  41405. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41406. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41407. */
  41408. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41409. /**
  41410. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41411. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41412. * frustum width.
  41413. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41414. * to fully enclose the mesh in the viewing frustum.
  41415. */
  41416. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41417. /**
  41418. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41419. * is automatically returned to its default position (expected to be above ground plane).
  41420. */
  41421. private _maintainCameraAboveGround;
  41422. /**
  41423. * Returns the frustum slope based on the canvas ratio and camera FOV
  41424. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41425. */
  41426. private _getFrustumSlope;
  41427. /**
  41428. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41429. */
  41430. private _clearAnimationLocks;
  41431. /**
  41432. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41433. */
  41434. private _applyUserInteraction;
  41435. /**
  41436. * Stops and removes all animations that have been applied to the camera
  41437. */
  41438. stopAllAnimations(): void;
  41439. /**
  41440. * Gets a value indicating if the user is moving the camera
  41441. */
  41442. get isUserIsMoving(): boolean;
  41443. /**
  41444. * The camera can move all the way towards the mesh.
  41445. */
  41446. static IgnoreBoundsSizeMode: number;
  41447. /**
  41448. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41449. */
  41450. static FitFrustumSidesMode: number;
  41451. }
  41452. }
  41453. declare module BABYLON {
  41454. /**
  41455. * Base class for Camera Pointer Inputs.
  41456. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41457. * for example usage.
  41458. */
  41459. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41460. /**
  41461. * Defines the camera the input is attached to.
  41462. */
  41463. abstract camera: Camera;
  41464. /**
  41465. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41466. */
  41467. protected _altKey: boolean;
  41468. protected _ctrlKey: boolean;
  41469. protected _metaKey: boolean;
  41470. protected _shiftKey: boolean;
  41471. /**
  41472. * Which mouse buttons were pressed at time of last mouse event.
  41473. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41474. */
  41475. protected _buttonsPressed: number;
  41476. /**
  41477. * Defines the buttons associated with the input to handle camera move.
  41478. */
  41479. buttons: number[];
  41480. /**
  41481. * Attach the input controls to a specific dom element to get the input from.
  41482. * @param element Defines the element the controls should be listened from
  41483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41484. */
  41485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41486. /**
  41487. * Detach the current controls from the specified dom element.
  41488. * @param element Defines the element to stop listening the inputs from
  41489. */
  41490. detachControl(element: Nullable<HTMLElement>): void;
  41491. /**
  41492. * Gets the class name of the current input.
  41493. * @returns the class name
  41494. */
  41495. getClassName(): string;
  41496. /**
  41497. * Get the friendly name associated with the input class.
  41498. * @returns the input friendly name
  41499. */
  41500. getSimpleName(): string;
  41501. /**
  41502. * Called on pointer POINTERDOUBLETAP event.
  41503. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41504. */
  41505. protected onDoubleTap(type: string): void;
  41506. /**
  41507. * Called on pointer POINTERMOVE event if only a single touch is active.
  41508. * Override this method to provide functionality.
  41509. */
  41510. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41511. /**
  41512. * Called on pointer POINTERMOVE event if multiple touches are active.
  41513. * Override this method to provide functionality.
  41514. */
  41515. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41516. /**
  41517. * Called on JS contextmenu event.
  41518. * Override this method to provide functionality.
  41519. */
  41520. protected onContextMenu(evt: PointerEvent): void;
  41521. /**
  41522. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41523. * press.
  41524. * Override this method to provide functionality.
  41525. */
  41526. protected onButtonDown(evt: PointerEvent): void;
  41527. /**
  41528. * Called each time a new POINTERUP event occurs. Ie, for each button
  41529. * release.
  41530. * Override this method to provide functionality.
  41531. */
  41532. protected onButtonUp(evt: PointerEvent): void;
  41533. /**
  41534. * Called when window becomes inactive.
  41535. * Override this method to provide functionality.
  41536. */
  41537. protected onLostFocus(): void;
  41538. private _pointerInput;
  41539. private _observer;
  41540. private _onLostFocus;
  41541. private pointA;
  41542. private pointB;
  41543. }
  41544. }
  41545. declare module BABYLON {
  41546. /**
  41547. * Manage the pointers inputs to control an arc rotate camera.
  41548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41549. */
  41550. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41551. /**
  41552. * Defines the camera the input is attached to.
  41553. */
  41554. camera: ArcRotateCamera;
  41555. /**
  41556. * Gets the class name of the current input.
  41557. * @returns the class name
  41558. */
  41559. getClassName(): string;
  41560. /**
  41561. * Defines the buttons associated with the input to handle camera move.
  41562. */
  41563. buttons: number[];
  41564. /**
  41565. * Defines the pointer angular sensibility along the X axis or how fast is
  41566. * the camera rotating.
  41567. */
  41568. angularSensibilityX: number;
  41569. /**
  41570. * Defines the pointer angular sensibility along the Y axis or how fast is
  41571. * the camera rotating.
  41572. */
  41573. angularSensibilityY: number;
  41574. /**
  41575. * Defines the pointer pinch precision or how fast is the camera zooming.
  41576. */
  41577. pinchPrecision: number;
  41578. /**
  41579. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41580. * from 0.
  41581. * It defines the percentage of current camera.radius to use as delta when
  41582. * pinch zoom is used.
  41583. */
  41584. pinchDeltaPercentage: number;
  41585. /**
  41586. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41587. * that any object in the plane at the camera's target point will scale
  41588. * perfectly with finger motion.
  41589. * Overrides pinchDeltaPercentage and pinchPrecision.
  41590. */
  41591. useNaturalPinchZoom: boolean;
  41592. /**
  41593. * Defines the pointer panning sensibility or how fast is the camera moving.
  41594. */
  41595. panningSensibility: number;
  41596. /**
  41597. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41598. */
  41599. multiTouchPanning: boolean;
  41600. /**
  41601. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41602. * zoom (pinch) through multitouch.
  41603. */
  41604. multiTouchPanAndZoom: boolean;
  41605. /**
  41606. * Revers pinch action direction.
  41607. */
  41608. pinchInwards: boolean;
  41609. private _isPanClick;
  41610. private _twoFingerActivityCount;
  41611. private _isPinching;
  41612. /**
  41613. * Called on pointer POINTERMOVE event if only a single touch is active.
  41614. */
  41615. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41616. /**
  41617. * Called on pointer POINTERDOUBLETAP event.
  41618. */
  41619. protected onDoubleTap(type: string): void;
  41620. /**
  41621. * Called on pointer POINTERMOVE event if multiple touches are active.
  41622. */
  41623. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41624. /**
  41625. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41626. * press.
  41627. */
  41628. protected onButtonDown(evt: PointerEvent): void;
  41629. /**
  41630. * Called each time a new POINTERUP event occurs. Ie, for each button
  41631. * release.
  41632. */
  41633. protected onButtonUp(evt: PointerEvent): void;
  41634. /**
  41635. * Called when window becomes inactive.
  41636. */
  41637. protected onLostFocus(): void;
  41638. }
  41639. }
  41640. declare module BABYLON {
  41641. /**
  41642. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41644. */
  41645. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41646. /**
  41647. * Defines the camera the input is attached to.
  41648. */
  41649. camera: ArcRotateCamera;
  41650. /**
  41651. * Defines the list of key codes associated with the up action (increase alpha)
  41652. */
  41653. keysUp: number[];
  41654. /**
  41655. * Defines the list of key codes associated with the down action (decrease alpha)
  41656. */
  41657. keysDown: number[];
  41658. /**
  41659. * Defines the list of key codes associated with the left action (increase beta)
  41660. */
  41661. keysLeft: number[];
  41662. /**
  41663. * Defines the list of key codes associated with the right action (decrease beta)
  41664. */
  41665. keysRight: number[];
  41666. /**
  41667. * Defines the list of key codes associated with the reset action.
  41668. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41669. */
  41670. keysReset: number[];
  41671. /**
  41672. * Defines the panning sensibility of the inputs.
  41673. * (How fast is the camera panning)
  41674. */
  41675. panningSensibility: number;
  41676. /**
  41677. * Defines the zooming sensibility of the inputs.
  41678. * (How fast is the camera zooming)
  41679. */
  41680. zoomingSensibility: number;
  41681. /**
  41682. * Defines whether maintaining the alt key down switch the movement mode from
  41683. * orientation to zoom.
  41684. */
  41685. useAltToZoom: boolean;
  41686. /**
  41687. * Rotation speed of the camera
  41688. */
  41689. angularSpeed: number;
  41690. private _keys;
  41691. private _ctrlPressed;
  41692. private _altPressed;
  41693. private _onCanvasBlurObserver;
  41694. private _onKeyboardObserver;
  41695. private _engine;
  41696. private _scene;
  41697. /**
  41698. * Attach the input controls to a specific dom element to get the input from.
  41699. * @param element Defines the element the controls should be listened from
  41700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41701. */
  41702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41703. /**
  41704. * Detach the current controls from the specified dom element.
  41705. * @param element Defines the element to stop listening the inputs from
  41706. */
  41707. detachControl(element: Nullable<HTMLElement>): void;
  41708. /**
  41709. * Update the current camera state depending on the inputs that have been used this frame.
  41710. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41711. */
  41712. checkInputs(): void;
  41713. /**
  41714. * Gets the class name of the current intput.
  41715. * @returns the class name
  41716. */
  41717. getClassName(): string;
  41718. /**
  41719. * Get the friendly name associated with the input class.
  41720. * @returns the input friendly name
  41721. */
  41722. getSimpleName(): string;
  41723. }
  41724. }
  41725. declare module BABYLON {
  41726. /**
  41727. * Manage the mouse wheel inputs to control an arc rotate camera.
  41728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41729. */
  41730. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41731. /**
  41732. * Defines the camera the input is attached to.
  41733. */
  41734. camera: ArcRotateCamera;
  41735. /**
  41736. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41737. */
  41738. wheelPrecision: number;
  41739. /**
  41740. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41741. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41742. */
  41743. wheelDeltaPercentage: number;
  41744. private _wheel;
  41745. private _observer;
  41746. private computeDeltaFromMouseWheelLegacyEvent;
  41747. /**
  41748. * Attach the input controls to a specific dom element to get the input from.
  41749. * @param element Defines the element the controls should be listened from
  41750. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41751. */
  41752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41753. /**
  41754. * Detach the current controls from the specified dom element.
  41755. * @param element Defines the element to stop listening the inputs from
  41756. */
  41757. detachControl(element: Nullable<HTMLElement>): void;
  41758. /**
  41759. * Gets the class name of the current intput.
  41760. * @returns the class name
  41761. */
  41762. getClassName(): string;
  41763. /**
  41764. * Get the friendly name associated with the input class.
  41765. * @returns the input friendly name
  41766. */
  41767. getSimpleName(): string;
  41768. }
  41769. }
  41770. declare module BABYLON {
  41771. /**
  41772. * Default Inputs manager for the ArcRotateCamera.
  41773. * It groups all the default supported inputs for ease of use.
  41774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41775. */
  41776. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41777. /**
  41778. * Instantiates a new ArcRotateCameraInputsManager.
  41779. * @param camera Defines the camera the inputs belong to
  41780. */
  41781. constructor(camera: ArcRotateCamera);
  41782. /**
  41783. * Add mouse wheel input support to the input manager.
  41784. * @returns the current input manager
  41785. */
  41786. addMouseWheel(): ArcRotateCameraInputsManager;
  41787. /**
  41788. * Add pointers input support to the input manager.
  41789. * @returns the current input manager
  41790. */
  41791. addPointers(): ArcRotateCameraInputsManager;
  41792. /**
  41793. * Add keyboard input support to the input manager.
  41794. * @returns the current input manager
  41795. */
  41796. addKeyboard(): ArcRotateCameraInputsManager;
  41797. }
  41798. }
  41799. declare module BABYLON {
  41800. /**
  41801. * This represents an orbital type of camera.
  41802. *
  41803. * 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.
  41804. * 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.
  41805. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41806. */
  41807. export class ArcRotateCamera extends TargetCamera {
  41808. /**
  41809. * Defines the rotation angle of the camera along the longitudinal axis.
  41810. */
  41811. alpha: number;
  41812. /**
  41813. * Defines the rotation angle of the camera along the latitudinal axis.
  41814. */
  41815. beta: number;
  41816. /**
  41817. * Defines the radius of the camera from it s target point.
  41818. */
  41819. radius: number;
  41820. protected _target: Vector3;
  41821. protected _targetHost: Nullable<AbstractMesh>;
  41822. /**
  41823. * Defines the target point of the camera.
  41824. * The camera looks towards it form the radius distance.
  41825. */
  41826. get target(): Vector3;
  41827. set target(value: Vector3);
  41828. /**
  41829. * Define the current local position of the camera in the scene
  41830. */
  41831. get position(): Vector3;
  41832. set position(newPosition: Vector3);
  41833. protected _upVector: Vector3;
  41834. protected _upToYMatrix: Matrix;
  41835. protected _YToUpMatrix: Matrix;
  41836. /**
  41837. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41838. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41839. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41840. */
  41841. set upVector(vec: Vector3);
  41842. get upVector(): Vector3;
  41843. /**
  41844. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41845. */
  41846. setMatUp(): void;
  41847. /**
  41848. * Current inertia value on the longitudinal axis.
  41849. * The bigger this number the longer it will take for the camera to stop.
  41850. */
  41851. inertialAlphaOffset: number;
  41852. /**
  41853. * Current inertia value on the latitudinal axis.
  41854. * The bigger this number the longer it will take for the camera to stop.
  41855. */
  41856. inertialBetaOffset: number;
  41857. /**
  41858. * Current inertia value on the radius axis.
  41859. * The bigger this number the longer it will take for the camera to stop.
  41860. */
  41861. inertialRadiusOffset: number;
  41862. /**
  41863. * Minimum allowed angle on the longitudinal axis.
  41864. * This can help limiting how the Camera is able to move in the scene.
  41865. */
  41866. lowerAlphaLimit: Nullable<number>;
  41867. /**
  41868. * Maximum allowed angle on the longitudinal axis.
  41869. * This can help limiting how the Camera is able to move in the scene.
  41870. */
  41871. upperAlphaLimit: Nullable<number>;
  41872. /**
  41873. * Minimum allowed angle on the latitudinal axis.
  41874. * This can help limiting how the Camera is able to move in the scene.
  41875. */
  41876. lowerBetaLimit: number;
  41877. /**
  41878. * Maximum allowed angle on the latitudinal axis.
  41879. * This can help limiting how the Camera is able to move in the scene.
  41880. */
  41881. upperBetaLimit: number;
  41882. /**
  41883. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41884. * This can help limiting how the Camera is able to move in the scene.
  41885. */
  41886. lowerRadiusLimit: Nullable<number>;
  41887. /**
  41888. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41889. * This can help limiting how the Camera is able to move in the scene.
  41890. */
  41891. upperRadiusLimit: Nullable<number>;
  41892. /**
  41893. * Defines the current inertia value used during panning of the camera along the X axis.
  41894. */
  41895. inertialPanningX: number;
  41896. /**
  41897. * Defines the current inertia value used during panning of the camera along the Y axis.
  41898. */
  41899. inertialPanningY: number;
  41900. /**
  41901. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41902. * Basically if your fingers moves away from more than this distance you will be considered
  41903. * in pinch mode.
  41904. */
  41905. pinchToPanMaxDistance: number;
  41906. /**
  41907. * Defines the maximum distance the camera can pan.
  41908. * This could help keeping the cammera always in your scene.
  41909. */
  41910. panningDistanceLimit: Nullable<number>;
  41911. /**
  41912. * Defines the target of the camera before paning.
  41913. */
  41914. panningOriginTarget: Vector3;
  41915. /**
  41916. * Defines the value of the inertia used during panning.
  41917. * 0 would mean stop inertia and one would mean no decelleration at all.
  41918. */
  41919. panningInertia: number;
  41920. /**
  41921. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41922. */
  41923. get angularSensibilityX(): number;
  41924. set angularSensibilityX(value: number);
  41925. /**
  41926. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41927. */
  41928. get angularSensibilityY(): number;
  41929. set angularSensibilityY(value: number);
  41930. /**
  41931. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41932. */
  41933. get pinchPrecision(): number;
  41934. set pinchPrecision(value: number);
  41935. /**
  41936. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41937. * It will be used instead of pinchDeltaPrecision if different from 0.
  41938. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41939. */
  41940. get pinchDeltaPercentage(): number;
  41941. set pinchDeltaPercentage(value: number);
  41942. /**
  41943. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41944. * and pinch delta percentage.
  41945. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41946. * that any object in the plane at the camera's target point will scale
  41947. * perfectly with finger motion.
  41948. */
  41949. get useNaturalPinchZoom(): boolean;
  41950. set useNaturalPinchZoom(value: boolean);
  41951. /**
  41952. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41953. */
  41954. get panningSensibility(): number;
  41955. set panningSensibility(value: number);
  41956. /**
  41957. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41958. */
  41959. get keysUp(): number[];
  41960. set keysUp(value: number[]);
  41961. /**
  41962. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41963. */
  41964. get keysDown(): number[];
  41965. set keysDown(value: number[]);
  41966. /**
  41967. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41968. */
  41969. get keysLeft(): number[];
  41970. set keysLeft(value: number[]);
  41971. /**
  41972. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41973. */
  41974. get keysRight(): number[];
  41975. set keysRight(value: number[]);
  41976. /**
  41977. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41978. */
  41979. get wheelPrecision(): number;
  41980. set wheelPrecision(value: number);
  41981. /**
  41982. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41983. * It will be used instead of pinchDeltaPrecision if different from 0.
  41984. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41985. */
  41986. get wheelDeltaPercentage(): number;
  41987. set wheelDeltaPercentage(value: number);
  41988. /**
  41989. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41990. */
  41991. zoomOnFactor: number;
  41992. /**
  41993. * Defines a screen offset for the camera position.
  41994. */
  41995. targetScreenOffset: Vector2;
  41996. /**
  41997. * Allows the camera to be completely reversed.
  41998. * If false the camera can not arrive upside down.
  41999. */
  42000. allowUpsideDown: boolean;
  42001. /**
  42002. * Define if double tap/click is used to restore the previously saved state of the camera.
  42003. */
  42004. useInputToRestoreState: boolean;
  42005. /** @hidden */
  42006. _viewMatrix: Matrix;
  42007. /** @hidden */
  42008. _useCtrlForPanning: boolean;
  42009. /** @hidden */
  42010. _panningMouseButton: number;
  42011. /**
  42012. * Defines the input associated to the camera.
  42013. */
  42014. inputs: ArcRotateCameraInputsManager;
  42015. /** @hidden */
  42016. _reset: () => void;
  42017. /**
  42018. * Defines the allowed panning axis.
  42019. */
  42020. panningAxis: Vector3;
  42021. protected _localDirection: Vector3;
  42022. protected _transformedDirection: Vector3;
  42023. private _bouncingBehavior;
  42024. /**
  42025. * Gets the bouncing behavior of the camera if it has been enabled.
  42026. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42027. */
  42028. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42029. /**
  42030. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42031. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42032. */
  42033. get useBouncingBehavior(): boolean;
  42034. set useBouncingBehavior(value: boolean);
  42035. private _framingBehavior;
  42036. /**
  42037. * Gets the framing behavior of the camera if it has been enabled.
  42038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42039. */
  42040. get framingBehavior(): Nullable<FramingBehavior>;
  42041. /**
  42042. * Defines if the framing behavior of the camera is enabled on the camera.
  42043. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42044. */
  42045. get useFramingBehavior(): boolean;
  42046. set useFramingBehavior(value: boolean);
  42047. private _autoRotationBehavior;
  42048. /**
  42049. * Gets the auto rotation behavior of the camera if it has been enabled.
  42050. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42051. */
  42052. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42053. /**
  42054. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42055. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42056. */
  42057. get useAutoRotationBehavior(): boolean;
  42058. set useAutoRotationBehavior(value: boolean);
  42059. /**
  42060. * Observable triggered when the mesh target has been changed on the camera.
  42061. */
  42062. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42063. /**
  42064. * Event raised when the camera is colliding with a mesh.
  42065. */
  42066. onCollide: (collidedMesh: AbstractMesh) => void;
  42067. /**
  42068. * Defines whether the camera should check collision with the objects oh the scene.
  42069. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42070. */
  42071. checkCollisions: boolean;
  42072. /**
  42073. * Defines the collision radius of the camera.
  42074. * This simulates a sphere around the camera.
  42075. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42076. */
  42077. collisionRadius: Vector3;
  42078. protected _collider: Collider;
  42079. protected _previousPosition: Vector3;
  42080. protected _collisionVelocity: Vector3;
  42081. protected _newPosition: Vector3;
  42082. protected _previousAlpha: number;
  42083. protected _previousBeta: number;
  42084. protected _previousRadius: number;
  42085. protected _collisionTriggered: boolean;
  42086. protected _targetBoundingCenter: Nullable<Vector3>;
  42087. private _computationVector;
  42088. /**
  42089. * Instantiates a new ArcRotateCamera in a given scene
  42090. * @param name Defines the name of the camera
  42091. * @param alpha Defines the camera rotation along the logitudinal axis
  42092. * @param beta Defines the camera rotation along the latitudinal axis
  42093. * @param radius Defines the camera distance from its target
  42094. * @param target Defines the camera target
  42095. * @param scene Defines the scene the camera belongs to
  42096. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42097. */
  42098. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42099. /** @hidden */
  42100. _initCache(): void;
  42101. /** @hidden */
  42102. _updateCache(ignoreParentClass?: boolean): void;
  42103. protected _getTargetPosition(): Vector3;
  42104. private _storedAlpha;
  42105. private _storedBeta;
  42106. private _storedRadius;
  42107. private _storedTarget;
  42108. private _storedTargetScreenOffset;
  42109. /**
  42110. * Stores the current state of the camera (alpha, beta, radius and target)
  42111. * @returns the camera itself
  42112. */
  42113. storeState(): Camera;
  42114. /**
  42115. * @hidden
  42116. * Restored camera state. You must call storeState() first
  42117. */
  42118. _restoreStateValues(): boolean;
  42119. /** @hidden */
  42120. _isSynchronizedViewMatrix(): boolean;
  42121. /**
  42122. * Attached controls to the current camera.
  42123. * @param element Defines the element the controls should be listened from
  42124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42125. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42126. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42127. */
  42128. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42129. /**
  42130. * Detach the current controls from the camera.
  42131. * The camera will stop reacting to inputs.
  42132. * @param element Defines the element to stop listening the inputs from
  42133. */
  42134. detachControl(element: HTMLElement): void;
  42135. /** @hidden */
  42136. _checkInputs(): void;
  42137. protected _checkLimits(): void;
  42138. /**
  42139. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42140. */
  42141. rebuildAnglesAndRadius(): void;
  42142. /**
  42143. * Use a position to define the current camera related information like alpha, beta and radius
  42144. * @param position Defines the position to set the camera at
  42145. */
  42146. setPosition(position: Vector3): void;
  42147. /**
  42148. * Defines the target the camera should look at.
  42149. * This will automatically adapt alpha beta and radius to fit within the new target.
  42150. * @param target Defines the new target as a Vector or a mesh
  42151. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42152. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42153. */
  42154. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42155. /** @hidden */
  42156. _getViewMatrix(): Matrix;
  42157. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42158. /**
  42159. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42160. * @param meshes Defines the mesh to zoom on
  42161. * @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)
  42162. */
  42163. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42164. /**
  42165. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42166. * The target will be changed but the radius
  42167. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42168. * @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)
  42169. */
  42170. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42171. min: Vector3;
  42172. max: Vector3;
  42173. distance: number;
  42174. }, doNotUpdateMaxZ?: boolean): void;
  42175. /**
  42176. * @override
  42177. * Override Camera.createRigCamera
  42178. */
  42179. createRigCamera(name: string, cameraIndex: number): Camera;
  42180. /**
  42181. * @hidden
  42182. * @override
  42183. * Override Camera._updateRigCameras
  42184. */
  42185. _updateRigCameras(): void;
  42186. /**
  42187. * Destroy the camera and release the current resources hold by it.
  42188. */
  42189. dispose(): void;
  42190. /**
  42191. * Gets the current object class name.
  42192. * @return the class name
  42193. */
  42194. getClassName(): string;
  42195. }
  42196. }
  42197. declare module BABYLON {
  42198. /**
  42199. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42200. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42201. */
  42202. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42203. /**
  42204. * Gets the name of the behavior.
  42205. */
  42206. get name(): string;
  42207. private _zoomStopsAnimation;
  42208. private _idleRotationSpeed;
  42209. private _idleRotationWaitTime;
  42210. private _idleRotationSpinupTime;
  42211. /**
  42212. * Sets the flag that indicates if user zooming should stop animation.
  42213. */
  42214. set zoomStopsAnimation(flag: boolean);
  42215. /**
  42216. * Gets the flag that indicates if user zooming should stop animation.
  42217. */
  42218. get zoomStopsAnimation(): boolean;
  42219. /**
  42220. * Sets the default speed at which the camera rotates around the model.
  42221. */
  42222. set idleRotationSpeed(speed: number);
  42223. /**
  42224. * Gets the default speed at which the camera rotates around the model.
  42225. */
  42226. get idleRotationSpeed(): number;
  42227. /**
  42228. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42229. */
  42230. set idleRotationWaitTime(time: number);
  42231. /**
  42232. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42233. */
  42234. get idleRotationWaitTime(): number;
  42235. /**
  42236. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42237. */
  42238. set idleRotationSpinupTime(time: number);
  42239. /**
  42240. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42241. */
  42242. get idleRotationSpinupTime(): number;
  42243. /**
  42244. * Gets a value indicating if the camera is currently rotating because of this behavior
  42245. */
  42246. get rotationInProgress(): boolean;
  42247. private _onPrePointerObservableObserver;
  42248. private _onAfterCheckInputsObserver;
  42249. private _attachedCamera;
  42250. private _isPointerDown;
  42251. private _lastFrameTime;
  42252. private _lastInteractionTime;
  42253. private _cameraRotationSpeed;
  42254. /**
  42255. * Initializes the behavior.
  42256. */
  42257. init(): void;
  42258. /**
  42259. * Attaches the behavior to its arc rotate camera.
  42260. * @param camera Defines the camera to attach the behavior to
  42261. */
  42262. attach(camera: ArcRotateCamera): void;
  42263. /**
  42264. * Detaches the behavior from its current arc rotate camera.
  42265. */
  42266. detach(): void;
  42267. /**
  42268. * Returns true if user is scrolling.
  42269. * @return true if user is scrolling.
  42270. */
  42271. private _userIsZooming;
  42272. private _lastFrameRadius;
  42273. private _shouldAnimationStopForInteraction;
  42274. /**
  42275. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42276. */
  42277. private _applyUserInteraction;
  42278. private _userIsMoving;
  42279. }
  42280. }
  42281. declare module BABYLON {
  42282. /**
  42283. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42284. */
  42285. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42286. private ui;
  42287. /**
  42288. * The name of the behavior
  42289. */
  42290. name: string;
  42291. /**
  42292. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42293. */
  42294. distanceAwayFromFace: number;
  42295. /**
  42296. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42297. */
  42298. distanceAwayFromBottomOfFace: number;
  42299. private _faceVectors;
  42300. private _target;
  42301. private _scene;
  42302. private _onRenderObserver;
  42303. private _tmpMatrix;
  42304. private _tmpVector;
  42305. /**
  42306. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42307. * @param ui The transform node that should be attched to the mesh
  42308. */
  42309. constructor(ui: TransformNode);
  42310. /**
  42311. * Initializes the behavior
  42312. */
  42313. init(): void;
  42314. private _closestFace;
  42315. private _zeroVector;
  42316. private _lookAtTmpMatrix;
  42317. private _lookAtToRef;
  42318. /**
  42319. * Attaches the AttachToBoxBehavior to the passed in mesh
  42320. * @param target The mesh that the specified node will be attached to
  42321. */
  42322. attach(target: Mesh): void;
  42323. /**
  42324. * Detaches the behavior from the mesh
  42325. */
  42326. detach(): void;
  42327. }
  42328. }
  42329. declare module BABYLON {
  42330. /**
  42331. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42332. */
  42333. export class FadeInOutBehavior implements Behavior<Mesh> {
  42334. /**
  42335. * Time in milliseconds to delay before fading in (Default: 0)
  42336. */
  42337. delay: number;
  42338. /**
  42339. * Time in milliseconds for the mesh to fade in (Default: 300)
  42340. */
  42341. fadeInTime: number;
  42342. private _millisecondsPerFrame;
  42343. private _hovered;
  42344. private _hoverValue;
  42345. private _ownerNode;
  42346. /**
  42347. * Instatiates the FadeInOutBehavior
  42348. */
  42349. constructor();
  42350. /**
  42351. * The name of the behavior
  42352. */
  42353. get name(): string;
  42354. /**
  42355. * Initializes the behavior
  42356. */
  42357. init(): void;
  42358. /**
  42359. * Attaches the fade behavior on the passed in mesh
  42360. * @param ownerNode The mesh that will be faded in/out once attached
  42361. */
  42362. attach(ownerNode: Mesh): void;
  42363. /**
  42364. * Detaches the behavior from the mesh
  42365. */
  42366. detach(): void;
  42367. /**
  42368. * Triggers the mesh to begin fading in or out
  42369. * @param value if the object should fade in or out (true to fade in)
  42370. */
  42371. fadeIn(value: boolean): void;
  42372. private _update;
  42373. private _setAllVisibility;
  42374. }
  42375. }
  42376. declare module BABYLON {
  42377. /**
  42378. * Class containing a set of static utilities functions for managing Pivots
  42379. * @hidden
  42380. */
  42381. export class PivotTools {
  42382. private static _PivotCached;
  42383. private static _OldPivotPoint;
  42384. private static _PivotTranslation;
  42385. private static _PivotTmpVector;
  42386. /** @hidden */
  42387. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42388. /** @hidden */
  42389. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42390. }
  42391. }
  42392. declare module BABYLON {
  42393. /**
  42394. * Class containing static functions to help procedurally build meshes
  42395. */
  42396. export class PlaneBuilder {
  42397. /**
  42398. * Creates a plane mesh
  42399. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42400. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42401. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42403. * * 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
  42404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42405. * @param name defines the name of the mesh
  42406. * @param options defines the options used to create the mesh
  42407. * @param scene defines the hosting scene
  42408. * @returns the plane mesh
  42409. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42410. */
  42411. static CreatePlane(name: string, options: {
  42412. size?: number;
  42413. width?: number;
  42414. height?: number;
  42415. sideOrientation?: number;
  42416. frontUVs?: Vector4;
  42417. backUVs?: Vector4;
  42418. updatable?: boolean;
  42419. sourcePlane?: Plane;
  42420. }, scene?: Nullable<Scene>): Mesh;
  42421. }
  42422. }
  42423. declare module BABYLON {
  42424. /**
  42425. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42426. */
  42427. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42428. private static _AnyMouseID;
  42429. /**
  42430. * Abstract mesh the behavior is set on
  42431. */
  42432. attachedNode: AbstractMesh;
  42433. private _dragPlane;
  42434. private _scene;
  42435. private _pointerObserver;
  42436. private _beforeRenderObserver;
  42437. private static _planeScene;
  42438. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42439. /**
  42440. * 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)
  42441. */
  42442. maxDragAngle: number;
  42443. /**
  42444. * @hidden
  42445. */
  42446. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42447. /**
  42448. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42449. */
  42450. currentDraggingPointerID: number;
  42451. /**
  42452. * The last position where the pointer hit the drag plane in world space
  42453. */
  42454. lastDragPosition: Vector3;
  42455. /**
  42456. * If the behavior is currently in a dragging state
  42457. */
  42458. dragging: boolean;
  42459. /**
  42460. * 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)
  42461. */
  42462. dragDeltaRatio: number;
  42463. /**
  42464. * If the drag plane orientation should be updated during the dragging (Default: true)
  42465. */
  42466. updateDragPlane: boolean;
  42467. private _debugMode;
  42468. private _moving;
  42469. /**
  42470. * Fires each time the attached mesh is dragged with the pointer
  42471. * * delta between last drag position and current drag position in world space
  42472. * * dragDistance along the drag axis
  42473. * * dragPlaneNormal normal of the current drag plane used during the drag
  42474. * * dragPlanePoint in world space where the drag intersects the drag plane
  42475. */
  42476. onDragObservable: Observable<{
  42477. delta: Vector3;
  42478. dragPlanePoint: Vector3;
  42479. dragPlaneNormal: Vector3;
  42480. dragDistance: number;
  42481. pointerId: number;
  42482. }>;
  42483. /**
  42484. * Fires each time a drag begins (eg. mouse down on mesh)
  42485. */
  42486. onDragStartObservable: Observable<{
  42487. dragPlanePoint: Vector3;
  42488. pointerId: number;
  42489. }>;
  42490. /**
  42491. * Fires each time a drag ends (eg. mouse release after drag)
  42492. */
  42493. onDragEndObservable: Observable<{
  42494. dragPlanePoint: Vector3;
  42495. pointerId: number;
  42496. }>;
  42497. /**
  42498. * If the attached mesh should be moved when dragged
  42499. */
  42500. moveAttached: boolean;
  42501. /**
  42502. * If the drag behavior will react to drag events (Default: true)
  42503. */
  42504. enabled: boolean;
  42505. /**
  42506. * If pointer events should start and release the drag (Default: true)
  42507. */
  42508. startAndReleaseDragOnPointerEvents: boolean;
  42509. /**
  42510. * If camera controls should be detached during the drag
  42511. */
  42512. detachCameraControls: boolean;
  42513. /**
  42514. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42515. */
  42516. useObjectOrientationForDragging: boolean;
  42517. private _options;
  42518. /**
  42519. * Gets the options used by the behavior
  42520. */
  42521. get options(): {
  42522. dragAxis?: Vector3;
  42523. dragPlaneNormal?: Vector3;
  42524. };
  42525. /**
  42526. * Sets the options used by the behavior
  42527. */
  42528. set options(options: {
  42529. dragAxis?: Vector3;
  42530. dragPlaneNormal?: Vector3;
  42531. });
  42532. /**
  42533. * Creates a pointer drag behavior that can be attached to a mesh
  42534. * @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)
  42535. */
  42536. constructor(options?: {
  42537. dragAxis?: Vector3;
  42538. dragPlaneNormal?: Vector3;
  42539. });
  42540. /**
  42541. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42542. */
  42543. validateDrag: (targetPosition: Vector3) => boolean;
  42544. /**
  42545. * The name of the behavior
  42546. */
  42547. get name(): string;
  42548. /**
  42549. * Initializes the behavior
  42550. */
  42551. init(): void;
  42552. private _tmpVector;
  42553. private _alternatePickedPoint;
  42554. private _worldDragAxis;
  42555. private _targetPosition;
  42556. private _attachedElement;
  42557. /**
  42558. * Attaches the drag behavior the passed in mesh
  42559. * @param ownerNode The mesh that will be dragged around once attached
  42560. * @param predicate Predicate to use for pick filtering
  42561. */
  42562. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42563. /**
  42564. * Force relase the drag action by code.
  42565. */
  42566. releaseDrag(): void;
  42567. private _startDragRay;
  42568. private _lastPointerRay;
  42569. /**
  42570. * Simulates the start of a pointer drag event on the behavior
  42571. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42572. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42573. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42574. */
  42575. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42576. private _startDrag;
  42577. private _dragDelta;
  42578. private _moveDrag;
  42579. private _pickWithRayOnDragPlane;
  42580. private _pointA;
  42581. private _pointB;
  42582. private _pointC;
  42583. private _lineA;
  42584. private _lineB;
  42585. private _localAxis;
  42586. private _lookAt;
  42587. private _updateDragPlanePosition;
  42588. /**
  42589. * Detaches the behavior from the mesh
  42590. */
  42591. detach(): void;
  42592. }
  42593. }
  42594. declare module BABYLON {
  42595. /**
  42596. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42597. */
  42598. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42599. private _dragBehaviorA;
  42600. private _dragBehaviorB;
  42601. private _startDistance;
  42602. private _initialScale;
  42603. private _targetScale;
  42604. private _ownerNode;
  42605. private _sceneRenderObserver;
  42606. /**
  42607. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42608. */
  42609. constructor();
  42610. /**
  42611. * The name of the behavior
  42612. */
  42613. get name(): string;
  42614. /**
  42615. * Initializes the behavior
  42616. */
  42617. init(): void;
  42618. private _getCurrentDistance;
  42619. /**
  42620. * Attaches the scale behavior the passed in mesh
  42621. * @param ownerNode The mesh that will be scaled around once attached
  42622. */
  42623. attach(ownerNode: Mesh): void;
  42624. /**
  42625. * Detaches the behavior from the mesh
  42626. */
  42627. detach(): void;
  42628. }
  42629. }
  42630. declare module BABYLON {
  42631. /**
  42632. * 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
  42633. */
  42634. export class SixDofDragBehavior implements Behavior<Mesh> {
  42635. private static _virtualScene;
  42636. private _ownerNode;
  42637. private _sceneRenderObserver;
  42638. private _scene;
  42639. private _targetPosition;
  42640. private _virtualOriginMesh;
  42641. private _virtualDragMesh;
  42642. private _pointerObserver;
  42643. private _moving;
  42644. private _startingOrientation;
  42645. private _attachedElement;
  42646. /**
  42647. * 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)
  42648. */
  42649. private zDragFactor;
  42650. /**
  42651. * If the object should rotate to face the drag origin
  42652. */
  42653. rotateDraggedObject: boolean;
  42654. /**
  42655. * If the behavior is currently in a dragging state
  42656. */
  42657. dragging: boolean;
  42658. /**
  42659. * 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)
  42660. */
  42661. dragDeltaRatio: number;
  42662. /**
  42663. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42664. */
  42665. currentDraggingPointerID: number;
  42666. /**
  42667. * If camera controls should be detached during the drag
  42668. */
  42669. detachCameraControls: boolean;
  42670. /**
  42671. * Fires each time a drag starts
  42672. */
  42673. onDragStartObservable: Observable<{}>;
  42674. /**
  42675. * Fires each time a drag ends (eg. mouse release after drag)
  42676. */
  42677. onDragEndObservable: Observable<{}>;
  42678. /**
  42679. * 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
  42680. */
  42681. constructor();
  42682. /**
  42683. * The name of the behavior
  42684. */
  42685. get name(): string;
  42686. /**
  42687. * Initializes the behavior
  42688. */
  42689. init(): void;
  42690. /**
  42691. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42692. */
  42693. private get _pointerCamera();
  42694. /**
  42695. * Attaches the scale behavior the passed in mesh
  42696. * @param ownerNode The mesh that will be scaled around once attached
  42697. */
  42698. attach(ownerNode: Mesh): void;
  42699. /**
  42700. * Detaches the behavior from the mesh
  42701. */
  42702. detach(): void;
  42703. }
  42704. }
  42705. declare module BABYLON {
  42706. /**
  42707. * Class used to apply inverse kinematics to bones
  42708. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42709. */
  42710. export class BoneIKController {
  42711. private static _tmpVecs;
  42712. private static _tmpQuat;
  42713. private static _tmpMats;
  42714. /**
  42715. * Gets or sets the target mesh
  42716. */
  42717. targetMesh: AbstractMesh;
  42718. /** Gets or sets the mesh used as pole */
  42719. poleTargetMesh: AbstractMesh;
  42720. /**
  42721. * Gets or sets the bone used as pole
  42722. */
  42723. poleTargetBone: Nullable<Bone>;
  42724. /**
  42725. * Gets or sets the target position
  42726. */
  42727. targetPosition: Vector3;
  42728. /**
  42729. * Gets or sets the pole target position
  42730. */
  42731. poleTargetPosition: Vector3;
  42732. /**
  42733. * Gets or sets the pole target local offset
  42734. */
  42735. poleTargetLocalOffset: Vector3;
  42736. /**
  42737. * Gets or sets the pole angle
  42738. */
  42739. poleAngle: number;
  42740. /**
  42741. * Gets or sets the mesh associated with the controller
  42742. */
  42743. mesh: AbstractMesh;
  42744. /**
  42745. * 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)
  42746. */
  42747. slerpAmount: number;
  42748. private _bone1Quat;
  42749. private _bone1Mat;
  42750. private _bone2Ang;
  42751. private _bone1;
  42752. private _bone2;
  42753. private _bone1Length;
  42754. private _bone2Length;
  42755. private _maxAngle;
  42756. private _maxReach;
  42757. private _rightHandedSystem;
  42758. private _bendAxis;
  42759. private _slerping;
  42760. private _adjustRoll;
  42761. /**
  42762. * Gets or sets maximum allowed angle
  42763. */
  42764. get maxAngle(): number;
  42765. set maxAngle(value: number);
  42766. /**
  42767. * Creates a new BoneIKController
  42768. * @param mesh defines the mesh to control
  42769. * @param bone defines the bone to control
  42770. * @param options defines options to set up the controller
  42771. */
  42772. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42773. targetMesh?: AbstractMesh;
  42774. poleTargetMesh?: AbstractMesh;
  42775. poleTargetBone?: Bone;
  42776. poleTargetLocalOffset?: Vector3;
  42777. poleAngle?: number;
  42778. bendAxis?: Vector3;
  42779. maxAngle?: number;
  42780. slerpAmount?: number;
  42781. });
  42782. private _setMaxAngle;
  42783. /**
  42784. * Force the controller to update the bones
  42785. */
  42786. update(): void;
  42787. }
  42788. }
  42789. declare module BABYLON {
  42790. /**
  42791. * Class used to make a bone look toward a point in space
  42792. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42793. */
  42794. export class BoneLookController {
  42795. private static _tmpVecs;
  42796. private static _tmpQuat;
  42797. private static _tmpMats;
  42798. /**
  42799. * The target Vector3 that the bone will look at
  42800. */
  42801. target: Vector3;
  42802. /**
  42803. * The mesh that the bone is attached to
  42804. */
  42805. mesh: AbstractMesh;
  42806. /**
  42807. * The bone that will be looking to the target
  42808. */
  42809. bone: Bone;
  42810. /**
  42811. * The up axis of the coordinate system that is used when the bone is rotated
  42812. */
  42813. upAxis: Vector3;
  42814. /**
  42815. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42816. */
  42817. upAxisSpace: Space;
  42818. /**
  42819. * Used to make an adjustment to the yaw of the bone
  42820. */
  42821. adjustYaw: number;
  42822. /**
  42823. * Used to make an adjustment to the pitch of the bone
  42824. */
  42825. adjustPitch: number;
  42826. /**
  42827. * Used to make an adjustment to the roll of the bone
  42828. */
  42829. adjustRoll: number;
  42830. /**
  42831. * 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)
  42832. */
  42833. slerpAmount: number;
  42834. private _minYaw;
  42835. private _maxYaw;
  42836. private _minPitch;
  42837. private _maxPitch;
  42838. private _minYawSin;
  42839. private _minYawCos;
  42840. private _maxYawSin;
  42841. private _maxYawCos;
  42842. private _midYawConstraint;
  42843. private _minPitchTan;
  42844. private _maxPitchTan;
  42845. private _boneQuat;
  42846. private _slerping;
  42847. private _transformYawPitch;
  42848. private _transformYawPitchInv;
  42849. private _firstFrameSkipped;
  42850. private _yawRange;
  42851. private _fowardAxis;
  42852. /**
  42853. * Gets or sets the minimum yaw angle that the bone can look to
  42854. */
  42855. get minYaw(): number;
  42856. set minYaw(value: number);
  42857. /**
  42858. * Gets or sets the maximum yaw angle that the bone can look to
  42859. */
  42860. get maxYaw(): number;
  42861. set maxYaw(value: number);
  42862. /**
  42863. * Gets or sets the minimum pitch angle that the bone can look to
  42864. */
  42865. get minPitch(): number;
  42866. set minPitch(value: number);
  42867. /**
  42868. * Gets or sets the maximum pitch angle that the bone can look to
  42869. */
  42870. get maxPitch(): number;
  42871. set maxPitch(value: number);
  42872. /**
  42873. * Create a BoneLookController
  42874. * @param mesh the mesh that the bone belongs to
  42875. * @param bone the bone that will be looking to the target
  42876. * @param target the target Vector3 to look at
  42877. * @param options optional settings:
  42878. * * maxYaw: the maximum angle the bone will yaw to
  42879. * * minYaw: the minimum angle the bone will yaw to
  42880. * * maxPitch: the maximum angle the bone will pitch to
  42881. * * minPitch: the minimum angle the bone will yaw to
  42882. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42883. * * upAxis: the up axis of the coordinate system
  42884. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42885. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42886. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42887. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42888. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42889. * * adjustRoll: used to make an adjustment to the roll of the bone
  42890. **/
  42891. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42892. maxYaw?: number;
  42893. minYaw?: number;
  42894. maxPitch?: number;
  42895. minPitch?: number;
  42896. slerpAmount?: number;
  42897. upAxis?: Vector3;
  42898. upAxisSpace?: Space;
  42899. yawAxis?: Vector3;
  42900. pitchAxis?: Vector3;
  42901. adjustYaw?: number;
  42902. adjustPitch?: number;
  42903. adjustRoll?: number;
  42904. });
  42905. /**
  42906. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42907. */
  42908. update(): void;
  42909. private _getAngleDiff;
  42910. private _getAngleBetween;
  42911. private _isAngleBetween;
  42912. }
  42913. }
  42914. declare module BABYLON {
  42915. /**
  42916. * Manage the gamepad inputs to control an arc rotate camera.
  42917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42918. */
  42919. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42920. /**
  42921. * Defines the camera the input is attached to.
  42922. */
  42923. camera: ArcRotateCamera;
  42924. /**
  42925. * Defines the gamepad the input is gathering event from.
  42926. */
  42927. gamepad: Nullable<Gamepad>;
  42928. /**
  42929. * Defines the gamepad rotation sensiblity.
  42930. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42931. */
  42932. gamepadRotationSensibility: number;
  42933. /**
  42934. * Defines the gamepad move sensiblity.
  42935. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42936. */
  42937. gamepadMoveSensibility: number;
  42938. private _yAxisScale;
  42939. /**
  42940. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42941. */
  42942. get invertYAxis(): boolean;
  42943. set invertYAxis(value: boolean);
  42944. private _onGamepadConnectedObserver;
  42945. private _onGamepadDisconnectedObserver;
  42946. /**
  42947. * Attach the input controls to a specific dom element to get the input from.
  42948. * @param element Defines the element the controls should be listened from
  42949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42950. */
  42951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42952. /**
  42953. * Detach the current controls from the specified dom element.
  42954. * @param element Defines the element to stop listening the inputs from
  42955. */
  42956. detachControl(element: Nullable<HTMLElement>): void;
  42957. /**
  42958. * Update the current camera state depending on the inputs that have been used this frame.
  42959. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42960. */
  42961. checkInputs(): void;
  42962. /**
  42963. * Gets the class name of the current intput.
  42964. * @returns the class name
  42965. */
  42966. getClassName(): string;
  42967. /**
  42968. * Get the friendly name associated with the input class.
  42969. * @returns the input friendly name
  42970. */
  42971. getSimpleName(): string;
  42972. }
  42973. }
  42974. declare module BABYLON {
  42975. interface ArcRotateCameraInputsManager {
  42976. /**
  42977. * Add orientation input support to the input manager.
  42978. * @returns the current input manager
  42979. */
  42980. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42981. }
  42982. /**
  42983. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42985. */
  42986. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42987. /**
  42988. * Defines the camera the input is attached to.
  42989. */
  42990. camera: ArcRotateCamera;
  42991. /**
  42992. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42993. */
  42994. alphaCorrection: number;
  42995. /**
  42996. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42997. */
  42998. gammaCorrection: number;
  42999. private _alpha;
  43000. private _gamma;
  43001. private _dirty;
  43002. private _deviceOrientationHandler;
  43003. /**
  43004. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43005. */
  43006. constructor();
  43007. /**
  43008. * Attach the input controls to a specific dom element to get the input from.
  43009. * @param element Defines the element the controls should be listened from
  43010. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43011. */
  43012. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43013. /** @hidden */
  43014. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43015. /**
  43016. * Update the current camera state depending on the inputs that have been used this frame.
  43017. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43018. */
  43019. checkInputs(): void;
  43020. /**
  43021. * Detach the current controls from the specified dom element.
  43022. * @param element Defines the element to stop listening the inputs from
  43023. */
  43024. detachControl(element: Nullable<HTMLElement>): void;
  43025. /**
  43026. * Gets the class name of the current intput.
  43027. * @returns the class name
  43028. */
  43029. getClassName(): string;
  43030. /**
  43031. * Get the friendly name associated with the input class.
  43032. * @returns the input friendly name
  43033. */
  43034. getSimpleName(): string;
  43035. }
  43036. }
  43037. declare module BABYLON {
  43038. /**
  43039. * Listen to mouse events to control the camera.
  43040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43041. */
  43042. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43043. /**
  43044. * Defines the camera the input is attached to.
  43045. */
  43046. camera: FlyCamera;
  43047. /**
  43048. * Defines if touch is enabled. (Default is true.)
  43049. */
  43050. touchEnabled: boolean;
  43051. /**
  43052. * Defines the buttons associated with the input to handle camera rotation.
  43053. */
  43054. buttons: number[];
  43055. /**
  43056. * Assign buttons for Yaw control.
  43057. */
  43058. buttonsYaw: number[];
  43059. /**
  43060. * Assign buttons for Pitch control.
  43061. */
  43062. buttonsPitch: number[];
  43063. /**
  43064. * Assign buttons for Roll control.
  43065. */
  43066. buttonsRoll: number[];
  43067. /**
  43068. * Detect if any button is being pressed while mouse is moved.
  43069. * -1 = Mouse locked.
  43070. * 0 = Left button.
  43071. * 1 = Middle Button.
  43072. * 2 = Right Button.
  43073. */
  43074. activeButton: number;
  43075. /**
  43076. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43077. * Higher values reduce its sensitivity.
  43078. */
  43079. angularSensibility: number;
  43080. private _mousemoveCallback;
  43081. private _observer;
  43082. private _rollObserver;
  43083. private previousPosition;
  43084. private noPreventDefault;
  43085. private element;
  43086. /**
  43087. * Listen to mouse events to control the camera.
  43088. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43090. */
  43091. constructor(touchEnabled?: boolean);
  43092. /**
  43093. * Attach the mouse control to the HTML DOM element.
  43094. * @param element Defines the element that listens to the input events.
  43095. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43096. */
  43097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43098. /**
  43099. * Detach the current controls from the specified dom element.
  43100. * @param element Defines the element to stop listening the inputs from
  43101. */
  43102. detachControl(element: Nullable<HTMLElement>): void;
  43103. /**
  43104. * Gets the class name of the current input.
  43105. * @returns the class name.
  43106. */
  43107. getClassName(): string;
  43108. /**
  43109. * Get the friendly name associated with the input class.
  43110. * @returns the input's friendly name.
  43111. */
  43112. getSimpleName(): string;
  43113. private _pointerInput;
  43114. private _onMouseMove;
  43115. /**
  43116. * Rotate camera by mouse offset.
  43117. */
  43118. private rotateCamera;
  43119. }
  43120. }
  43121. declare module BABYLON {
  43122. /**
  43123. * Default Inputs manager for the FlyCamera.
  43124. * It groups all the default supported inputs for ease of use.
  43125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43126. */
  43127. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43128. /**
  43129. * Instantiates a new FlyCameraInputsManager.
  43130. * @param camera Defines the camera the inputs belong to.
  43131. */
  43132. constructor(camera: FlyCamera);
  43133. /**
  43134. * Add keyboard input support to the input manager.
  43135. * @returns the new FlyCameraKeyboardMoveInput().
  43136. */
  43137. addKeyboard(): FlyCameraInputsManager;
  43138. /**
  43139. * Add mouse input support to the input manager.
  43140. * @param touchEnabled Enable touch screen support.
  43141. * @returns the new FlyCameraMouseInput().
  43142. */
  43143. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43144. }
  43145. }
  43146. declare module BABYLON {
  43147. /**
  43148. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43149. * such as in a 3D Space Shooter or a Flight Simulator.
  43150. */
  43151. export class FlyCamera extends TargetCamera {
  43152. /**
  43153. * Define the collision ellipsoid of the camera.
  43154. * This is helpful for simulating a camera body, like a player's body.
  43155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43156. */
  43157. ellipsoid: Vector3;
  43158. /**
  43159. * Define an offset for the position of the ellipsoid around the camera.
  43160. * This can be helpful if the camera is attached away from the player's body center,
  43161. * such as at its head.
  43162. */
  43163. ellipsoidOffset: Vector3;
  43164. /**
  43165. * Enable or disable collisions of the camera with the rest of the scene objects.
  43166. */
  43167. checkCollisions: boolean;
  43168. /**
  43169. * Enable or disable gravity on the camera.
  43170. */
  43171. applyGravity: boolean;
  43172. /**
  43173. * Define the current direction the camera is moving to.
  43174. */
  43175. cameraDirection: Vector3;
  43176. /**
  43177. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43178. * This overrides and empties cameraRotation.
  43179. */
  43180. rotationQuaternion: Quaternion;
  43181. /**
  43182. * Track Roll to maintain the wanted Rolling when looking around.
  43183. */
  43184. _trackRoll: number;
  43185. /**
  43186. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43187. */
  43188. rollCorrect: number;
  43189. /**
  43190. * Mimic a banked turn, Rolling the camera when Yawing.
  43191. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43192. */
  43193. bankedTurn: boolean;
  43194. /**
  43195. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43196. */
  43197. bankedTurnLimit: number;
  43198. /**
  43199. * Value of 0 disables the banked Roll.
  43200. * Value of 1 is equal to the Yaw angle in radians.
  43201. */
  43202. bankedTurnMultiplier: number;
  43203. /**
  43204. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43205. */
  43206. inputs: FlyCameraInputsManager;
  43207. /**
  43208. * Gets the input sensibility for mouse input.
  43209. * Higher values reduce sensitivity.
  43210. */
  43211. get angularSensibility(): number;
  43212. /**
  43213. * Sets the input sensibility for a mouse input.
  43214. * Higher values reduce sensitivity.
  43215. */
  43216. set angularSensibility(value: number);
  43217. /**
  43218. * Get the keys for camera movement forward.
  43219. */
  43220. get keysForward(): number[];
  43221. /**
  43222. * Set the keys for camera movement forward.
  43223. */
  43224. set keysForward(value: number[]);
  43225. /**
  43226. * Get the keys for camera movement backward.
  43227. */
  43228. get keysBackward(): number[];
  43229. set keysBackward(value: number[]);
  43230. /**
  43231. * Get the keys for camera movement up.
  43232. */
  43233. get keysUp(): number[];
  43234. /**
  43235. * Set the keys for camera movement up.
  43236. */
  43237. set keysUp(value: number[]);
  43238. /**
  43239. * Get the keys for camera movement down.
  43240. */
  43241. get keysDown(): number[];
  43242. /**
  43243. * Set the keys for camera movement down.
  43244. */
  43245. set keysDown(value: number[]);
  43246. /**
  43247. * Get the keys for camera movement left.
  43248. */
  43249. get keysLeft(): number[];
  43250. /**
  43251. * Set the keys for camera movement left.
  43252. */
  43253. set keysLeft(value: number[]);
  43254. /**
  43255. * Set the keys for camera movement right.
  43256. */
  43257. get keysRight(): number[];
  43258. /**
  43259. * Set the keys for camera movement right.
  43260. */
  43261. set keysRight(value: number[]);
  43262. /**
  43263. * Event raised when the camera collides with a mesh in the scene.
  43264. */
  43265. onCollide: (collidedMesh: AbstractMesh) => void;
  43266. private _collider;
  43267. private _needMoveForGravity;
  43268. private _oldPosition;
  43269. private _diffPosition;
  43270. private _newPosition;
  43271. /** @hidden */
  43272. _localDirection: Vector3;
  43273. /** @hidden */
  43274. _transformedDirection: Vector3;
  43275. /**
  43276. * Instantiates a FlyCamera.
  43277. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43278. * such as in a 3D Space Shooter or a Flight Simulator.
  43279. * @param name Define the name of the camera in the scene.
  43280. * @param position Define the starting position of the camera in the scene.
  43281. * @param scene Define the scene the camera belongs to.
  43282. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43283. */
  43284. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43285. /**
  43286. * Attach a control to the HTML DOM element.
  43287. * @param element Defines the element that listens to the input events.
  43288. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43289. */
  43290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43291. /**
  43292. * Detach a control from the HTML DOM element.
  43293. * The camera will stop reacting to that input.
  43294. * @param element Defines the element that listens to the input events.
  43295. */
  43296. detachControl(element: HTMLElement): void;
  43297. private _collisionMask;
  43298. /**
  43299. * Get the mask that the camera ignores in collision events.
  43300. */
  43301. get collisionMask(): number;
  43302. /**
  43303. * Set the mask that the camera ignores in collision events.
  43304. */
  43305. set collisionMask(mask: number);
  43306. /** @hidden */
  43307. _collideWithWorld(displacement: Vector3): void;
  43308. /** @hidden */
  43309. private _onCollisionPositionChange;
  43310. /** @hidden */
  43311. _checkInputs(): void;
  43312. /** @hidden */
  43313. _decideIfNeedsToMove(): boolean;
  43314. /** @hidden */
  43315. _updatePosition(): void;
  43316. /**
  43317. * Restore the Roll to its target value at the rate specified.
  43318. * @param rate - Higher means slower restoring.
  43319. * @hidden
  43320. */
  43321. restoreRoll(rate: number): void;
  43322. /**
  43323. * Destroy the camera and release the current resources held by it.
  43324. */
  43325. dispose(): void;
  43326. /**
  43327. * Get the current object class name.
  43328. * @returns the class name.
  43329. */
  43330. getClassName(): string;
  43331. }
  43332. }
  43333. declare module BABYLON {
  43334. /**
  43335. * Listen to keyboard events to control the camera.
  43336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43337. */
  43338. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43339. /**
  43340. * Defines the camera the input is attached to.
  43341. */
  43342. camera: FlyCamera;
  43343. /**
  43344. * The list of keyboard keys used to control the forward move of the camera.
  43345. */
  43346. keysForward: number[];
  43347. /**
  43348. * The list of keyboard keys used to control the backward move of the camera.
  43349. */
  43350. keysBackward: number[];
  43351. /**
  43352. * The list of keyboard keys used to control the forward move of the camera.
  43353. */
  43354. keysUp: number[];
  43355. /**
  43356. * The list of keyboard keys used to control the backward move of the camera.
  43357. */
  43358. keysDown: number[];
  43359. /**
  43360. * The list of keyboard keys used to control the right strafe move of the camera.
  43361. */
  43362. keysRight: number[];
  43363. /**
  43364. * The list of keyboard keys used to control the left strafe move of the camera.
  43365. */
  43366. keysLeft: number[];
  43367. private _keys;
  43368. private _onCanvasBlurObserver;
  43369. private _onKeyboardObserver;
  43370. private _engine;
  43371. private _scene;
  43372. /**
  43373. * Attach the input controls to a specific dom element to get the input from.
  43374. * @param element Defines the element the controls should be listened from
  43375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43376. */
  43377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43378. /**
  43379. * Detach the current controls from the specified dom element.
  43380. * @param element Defines the element to stop listening the inputs from
  43381. */
  43382. detachControl(element: Nullable<HTMLElement>): void;
  43383. /**
  43384. * Gets the class name of the current intput.
  43385. * @returns the class name
  43386. */
  43387. getClassName(): string;
  43388. /** @hidden */
  43389. _onLostFocus(e: FocusEvent): void;
  43390. /**
  43391. * Get the friendly name associated with the input class.
  43392. * @returns the input friendly name
  43393. */
  43394. getSimpleName(): string;
  43395. /**
  43396. * Update the current camera state depending on the inputs that have been used this frame.
  43397. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43398. */
  43399. checkInputs(): void;
  43400. }
  43401. }
  43402. declare module BABYLON {
  43403. /**
  43404. * Manage the mouse wheel inputs to control a follow camera.
  43405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43406. */
  43407. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43408. /**
  43409. * Defines the camera the input is attached to.
  43410. */
  43411. camera: FollowCamera;
  43412. /**
  43413. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43414. */
  43415. axisControlRadius: boolean;
  43416. /**
  43417. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43418. */
  43419. axisControlHeight: boolean;
  43420. /**
  43421. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43422. */
  43423. axisControlRotation: boolean;
  43424. /**
  43425. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43426. * relation to mouseWheel events.
  43427. */
  43428. wheelPrecision: number;
  43429. /**
  43430. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43431. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43432. */
  43433. wheelDeltaPercentage: number;
  43434. private _wheel;
  43435. private _observer;
  43436. /**
  43437. * Attach the input controls to a specific dom element to get the input from.
  43438. * @param element Defines the element the controls should be listened from
  43439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43440. */
  43441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43442. /**
  43443. * Detach the current controls from the specified dom element.
  43444. * @param element Defines the element to stop listening the inputs from
  43445. */
  43446. detachControl(element: Nullable<HTMLElement>): void;
  43447. /**
  43448. * Gets the class name of the current intput.
  43449. * @returns the class name
  43450. */
  43451. getClassName(): string;
  43452. /**
  43453. * Get the friendly name associated with the input class.
  43454. * @returns the input friendly name
  43455. */
  43456. getSimpleName(): string;
  43457. }
  43458. }
  43459. declare module BABYLON {
  43460. /**
  43461. * Manage the pointers inputs to control an follow camera.
  43462. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43463. */
  43464. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43465. /**
  43466. * Defines the camera the input is attached to.
  43467. */
  43468. camera: FollowCamera;
  43469. /**
  43470. * Gets the class name of the current input.
  43471. * @returns the class name
  43472. */
  43473. getClassName(): string;
  43474. /**
  43475. * Defines the pointer angular sensibility along the X axis or how fast is
  43476. * the camera rotating.
  43477. * A negative number will reverse the axis direction.
  43478. */
  43479. angularSensibilityX: number;
  43480. /**
  43481. * Defines the pointer angular sensibility along the Y axis or how fast is
  43482. * the camera rotating.
  43483. * A negative number will reverse the axis direction.
  43484. */
  43485. angularSensibilityY: number;
  43486. /**
  43487. * Defines the pointer pinch precision or how fast is the camera zooming.
  43488. * A negative number will reverse the axis direction.
  43489. */
  43490. pinchPrecision: number;
  43491. /**
  43492. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43493. * from 0.
  43494. * It defines the percentage of current camera.radius to use as delta when
  43495. * pinch zoom is used.
  43496. */
  43497. pinchDeltaPercentage: number;
  43498. /**
  43499. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43500. */
  43501. axisXControlRadius: boolean;
  43502. /**
  43503. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43504. */
  43505. axisXControlHeight: boolean;
  43506. /**
  43507. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43508. */
  43509. axisXControlRotation: boolean;
  43510. /**
  43511. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43512. */
  43513. axisYControlRadius: boolean;
  43514. /**
  43515. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43516. */
  43517. axisYControlHeight: boolean;
  43518. /**
  43519. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43520. */
  43521. axisYControlRotation: boolean;
  43522. /**
  43523. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43524. */
  43525. axisPinchControlRadius: boolean;
  43526. /**
  43527. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43528. */
  43529. axisPinchControlHeight: boolean;
  43530. /**
  43531. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43532. */
  43533. axisPinchControlRotation: boolean;
  43534. /**
  43535. * Log error messages if basic misconfiguration has occurred.
  43536. */
  43537. warningEnable: boolean;
  43538. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43539. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43540. private _warningCounter;
  43541. private _warning;
  43542. }
  43543. }
  43544. declare module BABYLON {
  43545. /**
  43546. * Default Inputs manager for the FollowCamera.
  43547. * It groups all the default supported inputs for ease of use.
  43548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43549. */
  43550. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43551. /**
  43552. * Instantiates a new FollowCameraInputsManager.
  43553. * @param camera Defines the camera the inputs belong to
  43554. */
  43555. constructor(camera: FollowCamera);
  43556. /**
  43557. * Add keyboard input support to the input manager.
  43558. * @returns the current input manager
  43559. */
  43560. addKeyboard(): FollowCameraInputsManager;
  43561. /**
  43562. * Add mouse wheel input support to the input manager.
  43563. * @returns the current input manager
  43564. */
  43565. addMouseWheel(): FollowCameraInputsManager;
  43566. /**
  43567. * Add pointers input support to the input manager.
  43568. * @returns the current input manager
  43569. */
  43570. addPointers(): FollowCameraInputsManager;
  43571. /**
  43572. * Add orientation input support to the input manager.
  43573. * @returns the current input manager
  43574. */
  43575. addVRDeviceOrientation(): FollowCameraInputsManager;
  43576. }
  43577. }
  43578. declare module BABYLON {
  43579. /**
  43580. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43581. * an arc rotate version arcFollowCamera are available.
  43582. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43583. */
  43584. export class FollowCamera extends TargetCamera {
  43585. /**
  43586. * Distance the follow camera should follow an object at
  43587. */
  43588. radius: number;
  43589. /**
  43590. * Minimum allowed distance of the camera to the axis of rotation
  43591. * (The camera can not get closer).
  43592. * This can help limiting how the Camera is able to move in the scene.
  43593. */
  43594. lowerRadiusLimit: Nullable<number>;
  43595. /**
  43596. * Maximum allowed distance of the camera to the axis of rotation
  43597. * (The camera can not get further).
  43598. * This can help limiting how the Camera is able to move in the scene.
  43599. */
  43600. upperRadiusLimit: Nullable<number>;
  43601. /**
  43602. * Define a rotation offset between the camera and the object it follows
  43603. */
  43604. rotationOffset: number;
  43605. /**
  43606. * Minimum allowed angle to camera position relative to target object.
  43607. * This can help limiting how the Camera is able to move in the scene.
  43608. */
  43609. lowerRotationOffsetLimit: Nullable<number>;
  43610. /**
  43611. * Maximum allowed angle to camera position relative to target object.
  43612. * This can help limiting how the Camera is able to move in the scene.
  43613. */
  43614. upperRotationOffsetLimit: Nullable<number>;
  43615. /**
  43616. * Define a height offset between the camera and the object it follows.
  43617. * It can help following an object from the top (like a car chaing a plane)
  43618. */
  43619. heightOffset: number;
  43620. /**
  43621. * Minimum allowed height of camera position relative to target object.
  43622. * This can help limiting how the Camera is able to move in the scene.
  43623. */
  43624. lowerHeightOffsetLimit: Nullable<number>;
  43625. /**
  43626. * Maximum allowed height of camera position relative to target object.
  43627. * This can help limiting how the Camera is able to move in the scene.
  43628. */
  43629. upperHeightOffsetLimit: Nullable<number>;
  43630. /**
  43631. * Define how fast the camera can accelerate to follow it s target.
  43632. */
  43633. cameraAcceleration: number;
  43634. /**
  43635. * Define the speed limit of the camera following an object.
  43636. */
  43637. maxCameraSpeed: number;
  43638. /**
  43639. * Define the target of the camera.
  43640. */
  43641. lockedTarget: Nullable<AbstractMesh>;
  43642. /**
  43643. * Defines the input associated with the camera.
  43644. */
  43645. inputs: FollowCameraInputsManager;
  43646. /**
  43647. * Instantiates the follow camera.
  43648. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43649. * @param name Define the name of the camera in the scene
  43650. * @param position Define the position of the camera
  43651. * @param scene Define the scene the camera belong to
  43652. * @param lockedTarget Define the target of the camera
  43653. */
  43654. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43655. private _follow;
  43656. /**
  43657. * Attached controls to the current camera.
  43658. * @param element Defines the element the controls should be listened from
  43659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43660. */
  43661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43662. /**
  43663. * Detach the current controls from the camera.
  43664. * The camera will stop reacting to inputs.
  43665. * @param element Defines the element to stop listening the inputs from
  43666. */
  43667. detachControl(element: HTMLElement): void;
  43668. /** @hidden */
  43669. _checkInputs(): void;
  43670. private _checkLimits;
  43671. /**
  43672. * Gets the camera class name.
  43673. * @returns the class name
  43674. */
  43675. getClassName(): string;
  43676. }
  43677. /**
  43678. * Arc Rotate version of the follow camera.
  43679. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43680. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43681. */
  43682. export class ArcFollowCamera extends TargetCamera {
  43683. /** The longitudinal angle of the camera */
  43684. alpha: number;
  43685. /** The latitudinal angle of the camera */
  43686. beta: number;
  43687. /** The radius of the camera from its target */
  43688. radius: number;
  43689. /** Define the camera target (the mesh it should follow) */
  43690. target: Nullable<AbstractMesh>;
  43691. private _cartesianCoordinates;
  43692. /**
  43693. * Instantiates a new ArcFollowCamera
  43694. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43695. * @param name Define the name of the camera
  43696. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43697. * @param beta Define the rotation angle of the camera around the elevation axis
  43698. * @param radius Define the radius of the camera from its target point
  43699. * @param target Define the target of the camera
  43700. * @param scene Define the scene the camera belongs to
  43701. */
  43702. constructor(name: string,
  43703. /** The longitudinal angle of the camera */
  43704. alpha: number,
  43705. /** The latitudinal angle of the camera */
  43706. beta: number,
  43707. /** The radius of the camera from its target */
  43708. radius: number,
  43709. /** Define the camera target (the mesh it should follow) */
  43710. target: Nullable<AbstractMesh>, scene: Scene);
  43711. private _follow;
  43712. /** @hidden */
  43713. _checkInputs(): void;
  43714. /**
  43715. * Returns the class name of the object.
  43716. * It is mostly used internally for serialization purposes.
  43717. */
  43718. getClassName(): string;
  43719. }
  43720. }
  43721. declare module BABYLON {
  43722. /**
  43723. * Manage the keyboard inputs to control the movement of a follow camera.
  43724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43725. */
  43726. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43727. /**
  43728. * Defines the camera the input is attached to.
  43729. */
  43730. camera: FollowCamera;
  43731. /**
  43732. * Defines the list of key codes associated with the up action (increase heightOffset)
  43733. */
  43734. keysHeightOffsetIncr: number[];
  43735. /**
  43736. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43737. */
  43738. keysHeightOffsetDecr: number[];
  43739. /**
  43740. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43741. */
  43742. keysHeightOffsetModifierAlt: boolean;
  43743. /**
  43744. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43745. */
  43746. keysHeightOffsetModifierCtrl: boolean;
  43747. /**
  43748. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43749. */
  43750. keysHeightOffsetModifierShift: boolean;
  43751. /**
  43752. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43753. */
  43754. keysRotationOffsetIncr: number[];
  43755. /**
  43756. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43757. */
  43758. keysRotationOffsetDecr: number[];
  43759. /**
  43760. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43761. */
  43762. keysRotationOffsetModifierAlt: boolean;
  43763. /**
  43764. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43765. */
  43766. keysRotationOffsetModifierCtrl: boolean;
  43767. /**
  43768. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43769. */
  43770. keysRotationOffsetModifierShift: boolean;
  43771. /**
  43772. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43773. */
  43774. keysRadiusIncr: number[];
  43775. /**
  43776. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43777. */
  43778. keysRadiusDecr: number[];
  43779. /**
  43780. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43781. */
  43782. keysRadiusModifierAlt: boolean;
  43783. /**
  43784. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43785. */
  43786. keysRadiusModifierCtrl: boolean;
  43787. /**
  43788. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43789. */
  43790. keysRadiusModifierShift: boolean;
  43791. /**
  43792. * Defines the rate of change of heightOffset.
  43793. */
  43794. heightSensibility: number;
  43795. /**
  43796. * Defines the rate of change of rotationOffset.
  43797. */
  43798. rotationSensibility: number;
  43799. /**
  43800. * Defines the rate of change of radius.
  43801. */
  43802. radiusSensibility: number;
  43803. private _keys;
  43804. private _ctrlPressed;
  43805. private _altPressed;
  43806. private _shiftPressed;
  43807. private _onCanvasBlurObserver;
  43808. private _onKeyboardObserver;
  43809. private _engine;
  43810. private _scene;
  43811. /**
  43812. * Attach the input controls to a specific dom element to get the input from.
  43813. * @param element Defines the element the controls should be listened from
  43814. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43815. */
  43816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43817. /**
  43818. * Detach the current controls from the specified dom element.
  43819. * @param element Defines the element to stop listening the inputs from
  43820. */
  43821. detachControl(element: Nullable<HTMLElement>): void;
  43822. /**
  43823. * Update the current camera state depending on the inputs that have been used this frame.
  43824. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43825. */
  43826. checkInputs(): void;
  43827. /**
  43828. * Gets the class name of the current input.
  43829. * @returns the class name
  43830. */
  43831. getClassName(): string;
  43832. /**
  43833. * Get the friendly name associated with the input class.
  43834. * @returns the input friendly name
  43835. */
  43836. getSimpleName(): string;
  43837. /**
  43838. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43839. * allow modification of the heightOffset value.
  43840. */
  43841. private _modifierHeightOffset;
  43842. /**
  43843. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43844. * allow modification of the rotationOffset value.
  43845. */
  43846. private _modifierRotationOffset;
  43847. /**
  43848. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43849. * allow modification of the radius value.
  43850. */
  43851. private _modifierRadius;
  43852. }
  43853. }
  43854. declare module BABYLON {
  43855. interface FreeCameraInputsManager {
  43856. /**
  43857. * @hidden
  43858. */
  43859. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43860. /**
  43861. * Add orientation input support to the input manager.
  43862. * @returns the current input manager
  43863. */
  43864. addDeviceOrientation(): FreeCameraInputsManager;
  43865. }
  43866. /**
  43867. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43868. * Screen rotation is taken into account.
  43869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43870. */
  43871. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43872. private _camera;
  43873. private _screenOrientationAngle;
  43874. private _constantTranform;
  43875. private _screenQuaternion;
  43876. private _alpha;
  43877. private _beta;
  43878. private _gamma;
  43879. /**
  43880. * Can be used to detect if a device orientation sensor is available on a device
  43881. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43882. * @returns a promise that will resolve on orientation change
  43883. */
  43884. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43885. /**
  43886. * @hidden
  43887. */
  43888. _onDeviceOrientationChangedObservable: Observable<void>;
  43889. /**
  43890. * Instantiates a new input
  43891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43892. */
  43893. constructor();
  43894. /**
  43895. * Define the camera controlled by the input.
  43896. */
  43897. get camera(): FreeCamera;
  43898. set camera(camera: FreeCamera);
  43899. /**
  43900. * Attach the input controls to a specific dom element to get the input from.
  43901. * @param element Defines the element the controls should be listened from
  43902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43903. */
  43904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43905. private _orientationChanged;
  43906. private _deviceOrientation;
  43907. /**
  43908. * Detach the current controls from the specified dom element.
  43909. * @param element Defines the element to stop listening the inputs from
  43910. */
  43911. detachControl(element: Nullable<HTMLElement>): void;
  43912. /**
  43913. * Update the current camera state depending on the inputs that have been used this frame.
  43914. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43915. */
  43916. checkInputs(): void;
  43917. /**
  43918. * Gets the class name of the current intput.
  43919. * @returns the class name
  43920. */
  43921. getClassName(): string;
  43922. /**
  43923. * Get the friendly name associated with the input class.
  43924. * @returns the input friendly name
  43925. */
  43926. getSimpleName(): string;
  43927. }
  43928. }
  43929. declare module BABYLON {
  43930. /**
  43931. * Manage the gamepad inputs to control a free camera.
  43932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43933. */
  43934. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43935. /**
  43936. * Define the camera the input is attached to.
  43937. */
  43938. camera: FreeCamera;
  43939. /**
  43940. * Define the Gamepad controlling the input
  43941. */
  43942. gamepad: Nullable<Gamepad>;
  43943. /**
  43944. * Defines the gamepad rotation sensiblity.
  43945. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43946. */
  43947. gamepadAngularSensibility: number;
  43948. /**
  43949. * Defines the gamepad move sensiblity.
  43950. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43951. */
  43952. gamepadMoveSensibility: number;
  43953. private _yAxisScale;
  43954. /**
  43955. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43956. */
  43957. get invertYAxis(): boolean;
  43958. set invertYAxis(value: boolean);
  43959. private _onGamepadConnectedObserver;
  43960. private _onGamepadDisconnectedObserver;
  43961. private _cameraTransform;
  43962. private _deltaTransform;
  43963. private _vector3;
  43964. private _vector2;
  43965. /**
  43966. * Attach the input controls to a specific dom element to get the input from.
  43967. * @param element Defines the element the controls should be listened from
  43968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43969. */
  43970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43971. /**
  43972. * Detach the current controls from the specified dom element.
  43973. * @param element Defines the element to stop listening the inputs from
  43974. */
  43975. detachControl(element: Nullable<HTMLElement>): void;
  43976. /**
  43977. * Update the current camera state depending on the inputs that have been used this frame.
  43978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43979. */
  43980. checkInputs(): void;
  43981. /**
  43982. * Gets the class name of the current intput.
  43983. * @returns the class name
  43984. */
  43985. getClassName(): string;
  43986. /**
  43987. * Get the friendly name associated with the input class.
  43988. * @returns the input friendly name
  43989. */
  43990. getSimpleName(): string;
  43991. }
  43992. }
  43993. declare module BABYLON {
  43994. /**
  43995. * Defines the potential axis of a Joystick
  43996. */
  43997. export enum JoystickAxis {
  43998. /** X axis */
  43999. X = 0,
  44000. /** Y axis */
  44001. Y = 1,
  44002. /** Z axis */
  44003. Z = 2
  44004. }
  44005. /**
  44006. * Class used to define virtual joystick (used in touch mode)
  44007. */
  44008. export class VirtualJoystick {
  44009. /**
  44010. * Gets or sets a boolean indicating that left and right values must be inverted
  44011. */
  44012. reverseLeftRight: boolean;
  44013. /**
  44014. * Gets or sets a boolean indicating that up and down values must be inverted
  44015. */
  44016. reverseUpDown: boolean;
  44017. /**
  44018. * Gets the offset value for the position (ie. the change of the position value)
  44019. */
  44020. deltaPosition: Vector3;
  44021. /**
  44022. * Gets a boolean indicating if the virtual joystick was pressed
  44023. */
  44024. pressed: boolean;
  44025. /**
  44026. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44027. */
  44028. static Canvas: Nullable<HTMLCanvasElement>;
  44029. private static _globalJoystickIndex;
  44030. private static vjCanvasContext;
  44031. private static vjCanvasWidth;
  44032. private static vjCanvasHeight;
  44033. private static halfWidth;
  44034. private _action;
  44035. private _axisTargetedByLeftAndRight;
  44036. private _axisTargetedByUpAndDown;
  44037. private _joystickSensibility;
  44038. private _inversedSensibility;
  44039. private _joystickPointerID;
  44040. private _joystickColor;
  44041. private _joystickPointerPos;
  44042. private _joystickPreviousPointerPos;
  44043. private _joystickPointerStartPos;
  44044. private _deltaJoystickVector;
  44045. private _leftJoystick;
  44046. private _touches;
  44047. private _onPointerDownHandlerRef;
  44048. private _onPointerMoveHandlerRef;
  44049. private _onPointerUpHandlerRef;
  44050. private _onResize;
  44051. /**
  44052. * Creates a new virtual joystick
  44053. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44054. */
  44055. constructor(leftJoystick?: boolean);
  44056. /**
  44057. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44058. * @param newJoystickSensibility defines the new sensibility
  44059. */
  44060. setJoystickSensibility(newJoystickSensibility: number): void;
  44061. private _onPointerDown;
  44062. private _onPointerMove;
  44063. private _onPointerUp;
  44064. /**
  44065. * Change the color of the virtual joystick
  44066. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44067. */
  44068. setJoystickColor(newColor: string): void;
  44069. /**
  44070. * Defines a callback to call when the joystick is touched
  44071. * @param action defines the callback
  44072. */
  44073. setActionOnTouch(action: () => any): void;
  44074. /**
  44075. * Defines which axis you'd like to control for left & right
  44076. * @param axis defines the axis to use
  44077. */
  44078. setAxisForLeftRight(axis: JoystickAxis): void;
  44079. /**
  44080. * Defines which axis you'd like to control for up & down
  44081. * @param axis defines the axis to use
  44082. */
  44083. setAxisForUpDown(axis: JoystickAxis): void;
  44084. private _drawVirtualJoystick;
  44085. /**
  44086. * Release internal HTML canvas
  44087. */
  44088. releaseCanvas(): void;
  44089. }
  44090. }
  44091. declare module BABYLON {
  44092. interface FreeCameraInputsManager {
  44093. /**
  44094. * Add virtual joystick input support to the input manager.
  44095. * @returns the current input manager
  44096. */
  44097. addVirtualJoystick(): FreeCameraInputsManager;
  44098. }
  44099. /**
  44100. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44102. */
  44103. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44104. /**
  44105. * Defines the camera the input is attached to.
  44106. */
  44107. camera: FreeCamera;
  44108. private _leftjoystick;
  44109. private _rightjoystick;
  44110. /**
  44111. * Gets the left stick of the virtual joystick.
  44112. * @returns The virtual Joystick
  44113. */
  44114. getLeftJoystick(): VirtualJoystick;
  44115. /**
  44116. * Gets the right stick of the virtual joystick.
  44117. * @returns The virtual Joystick
  44118. */
  44119. getRightJoystick(): VirtualJoystick;
  44120. /**
  44121. * Update the current camera state depending on the inputs that have been used this frame.
  44122. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44123. */
  44124. checkInputs(): void;
  44125. /**
  44126. * Attach the input controls to a specific dom element to get the input from.
  44127. * @param element Defines the element the controls should be listened from
  44128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44129. */
  44130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44131. /**
  44132. * Detach the current controls from the specified dom element.
  44133. * @param element Defines the element to stop listening the inputs from
  44134. */
  44135. detachControl(element: Nullable<HTMLElement>): void;
  44136. /**
  44137. * Gets the class name of the current intput.
  44138. * @returns the class name
  44139. */
  44140. getClassName(): string;
  44141. /**
  44142. * Get the friendly name associated with the input class.
  44143. * @returns the input friendly name
  44144. */
  44145. getSimpleName(): string;
  44146. }
  44147. }
  44148. declare module BABYLON {
  44149. /**
  44150. * This represents a FPS type of camera controlled by touch.
  44151. * This is like a universal camera minus the Gamepad controls.
  44152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44153. */
  44154. export class TouchCamera extends FreeCamera {
  44155. /**
  44156. * Defines the touch sensibility for rotation.
  44157. * The higher the faster.
  44158. */
  44159. get touchAngularSensibility(): number;
  44160. set touchAngularSensibility(value: number);
  44161. /**
  44162. * Defines the touch sensibility for move.
  44163. * The higher the faster.
  44164. */
  44165. get touchMoveSensibility(): number;
  44166. set touchMoveSensibility(value: number);
  44167. /**
  44168. * Instantiates a new touch camera.
  44169. * This represents a FPS type of camera controlled by touch.
  44170. * This is like a universal camera minus the Gamepad controls.
  44171. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44172. * @param name Define the name of the camera in the scene
  44173. * @param position Define the start position of the camera in the scene
  44174. * @param scene Define the scene the camera belongs to
  44175. */
  44176. constructor(name: string, position: Vector3, scene: Scene);
  44177. /**
  44178. * Gets the current object class name.
  44179. * @return the class name
  44180. */
  44181. getClassName(): string;
  44182. /** @hidden */
  44183. _setupInputs(): void;
  44184. }
  44185. }
  44186. declare module BABYLON {
  44187. /**
  44188. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44189. * being tilted forward or back and left or right.
  44190. */
  44191. export class DeviceOrientationCamera extends FreeCamera {
  44192. private _initialQuaternion;
  44193. private _quaternionCache;
  44194. private _tmpDragQuaternion;
  44195. private _disablePointerInputWhenUsingDeviceOrientation;
  44196. /**
  44197. * Creates a new device orientation camera
  44198. * @param name The name of the camera
  44199. * @param position The start position camera
  44200. * @param scene The scene the camera belongs to
  44201. */
  44202. constructor(name: string, position: Vector3, scene: Scene);
  44203. /**
  44204. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44205. */
  44206. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44207. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44208. private _dragFactor;
  44209. /**
  44210. * Enabled turning on the y axis when the orientation sensor is active
  44211. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44212. */
  44213. enableHorizontalDragging(dragFactor?: number): void;
  44214. /**
  44215. * Gets the current instance class name ("DeviceOrientationCamera").
  44216. * This helps avoiding instanceof at run time.
  44217. * @returns the class name
  44218. */
  44219. getClassName(): string;
  44220. /**
  44221. * @hidden
  44222. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44223. */
  44224. _checkInputs(): void;
  44225. /**
  44226. * Reset the camera to its default orientation on the specified axis only.
  44227. * @param axis The axis to reset
  44228. */
  44229. resetToCurrentRotation(axis?: Axis): void;
  44230. }
  44231. }
  44232. declare module BABYLON {
  44233. /**
  44234. * Defines supported buttons for XBox360 compatible gamepads
  44235. */
  44236. export enum Xbox360Button {
  44237. /** A */
  44238. A = 0,
  44239. /** B */
  44240. B = 1,
  44241. /** X */
  44242. X = 2,
  44243. /** Y */
  44244. Y = 3,
  44245. /** Left button */
  44246. LB = 4,
  44247. /** Right button */
  44248. RB = 5,
  44249. /** Back */
  44250. Back = 8,
  44251. /** Start */
  44252. Start = 9,
  44253. /** Left stick */
  44254. LeftStick = 10,
  44255. /** Right stick */
  44256. RightStick = 11
  44257. }
  44258. /** Defines values for XBox360 DPad */
  44259. export enum Xbox360Dpad {
  44260. /** Up */
  44261. Up = 12,
  44262. /** Down */
  44263. Down = 13,
  44264. /** Left */
  44265. Left = 14,
  44266. /** Right */
  44267. Right = 15
  44268. }
  44269. /**
  44270. * Defines a XBox360 gamepad
  44271. */
  44272. export class Xbox360Pad extends Gamepad {
  44273. private _leftTrigger;
  44274. private _rightTrigger;
  44275. private _onlefttriggerchanged;
  44276. private _onrighttriggerchanged;
  44277. private _onbuttondown;
  44278. private _onbuttonup;
  44279. private _ondpaddown;
  44280. private _ondpadup;
  44281. /** Observable raised when a button is pressed */
  44282. onButtonDownObservable: Observable<Xbox360Button>;
  44283. /** Observable raised when a button is released */
  44284. onButtonUpObservable: Observable<Xbox360Button>;
  44285. /** Observable raised when a pad is pressed */
  44286. onPadDownObservable: Observable<Xbox360Dpad>;
  44287. /** Observable raised when a pad is released */
  44288. onPadUpObservable: Observable<Xbox360Dpad>;
  44289. private _buttonA;
  44290. private _buttonB;
  44291. private _buttonX;
  44292. private _buttonY;
  44293. private _buttonBack;
  44294. private _buttonStart;
  44295. private _buttonLB;
  44296. private _buttonRB;
  44297. private _buttonLeftStick;
  44298. private _buttonRightStick;
  44299. private _dPadUp;
  44300. private _dPadDown;
  44301. private _dPadLeft;
  44302. private _dPadRight;
  44303. private _isXboxOnePad;
  44304. /**
  44305. * Creates a new XBox360 gamepad object
  44306. * @param id defines the id of this gamepad
  44307. * @param index defines its index
  44308. * @param gamepad defines the internal HTML gamepad object
  44309. * @param xboxOne defines if it is a XBox One gamepad
  44310. */
  44311. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44312. /**
  44313. * Defines the callback to call when left trigger is pressed
  44314. * @param callback defines the callback to use
  44315. */
  44316. onlefttriggerchanged(callback: (value: number) => void): void;
  44317. /**
  44318. * Defines the callback to call when right trigger is pressed
  44319. * @param callback defines the callback to use
  44320. */
  44321. onrighttriggerchanged(callback: (value: number) => void): void;
  44322. /**
  44323. * Gets the left trigger value
  44324. */
  44325. get leftTrigger(): number;
  44326. /**
  44327. * Sets the left trigger value
  44328. */
  44329. set leftTrigger(newValue: number);
  44330. /**
  44331. * Gets the right trigger value
  44332. */
  44333. get rightTrigger(): number;
  44334. /**
  44335. * Sets the right trigger value
  44336. */
  44337. set rightTrigger(newValue: number);
  44338. /**
  44339. * Defines the callback to call when a button is pressed
  44340. * @param callback defines the callback to use
  44341. */
  44342. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44343. /**
  44344. * Defines the callback to call when a button is released
  44345. * @param callback defines the callback to use
  44346. */
  44347. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44348. /**
  44349. * Defines the callback to call when a pad is pressed
  44350. * @param callback defines the callback to use
  44351. */
  44352. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44353. /**
  44354. * Defines the callback to call when a pad is released
  44355. * @param callback defines the callback to use
  44356. */
  44357. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44358. private _setButtonValue;
  44359. private _setDPadValue;
  44360. /**
  44361. * Gets the value of the `A` button
  44362. */
  44363. get buttonA(): number;
  44364. /**
  44365. * Sets the value of the `A` button
  44366. */
  44367. set buttonA(value: number);
  44368. /**
  44369. * Gets the value of the `B` button
  44370. */
  44371. get buttonB(): number;
  44372. /**
  44373. * Sets the value of the `B` button
  44374. */
  44375. set buttonB(value: number);
  44376. /**
  44377. * Gets the value of the `X` button
  44378. */
  44379. get buttonX(): number;
  44380. /**
  44381. * Sets the value of the `X` button
  44382. */
  44383. set buttonX(value: number);
  44384. /**
  44385. * Gets the value of the `Y` button
  44386. */
  44387. get buttonY(): number;
  44388. /**
  44389. * Sets the value of the `Y` button
  44390. */
  44391. set buttonY(value: number);
  44392. /**
  44393. * Gets the value of the `Start` button
  44394. */
  44395. get buttonStart(): number;
  44396. /**
  44397. * Sets the value of the `Start` button
  44398. */
  44399. set buttonStart(value: number);
  44400. /**
  44401. * Gets the value of the `Back` button
  44402. */
  44403. get buttonBack(): number;
  44404. /**
  44405. * Sets the value of the `Back` button
  44406. */
  44407. set buttonBack(value: number);
  44408. /**
  44409. * Gets the value of the `Left` button
  44410. */
  44411. get buttonLB(): number;
  44412. /**
  44413. * Sets the value of the `Left` button
  44414. */
  44415. set buttonLB(value: number);
  44416. /**
  44417. * Gets the value of the `Right` button
  44418. */
  44419. get buttonRB(): number;
  44420. /**
  44421. * Sets the value of the `Right` button
  44422. */
  44423. set buttonRB(value: number);
  44424. /**
  44425. * Gets the value of the Left joystick
  44426. */
  44427. get buttonLeftStick(): number;
  44428. /**
  44429. * Sets the value of the Left joystick
  44430. */
  44431. set buttonLeftStick(value: number);
  44432. /**
  44433. * Gets the value of the Right joystick
  44434. */
  44435. get buttonRightStick(): number;
  44436. /**
  44437. * Sets the value of the Right joystick
  44438. */
  44439. set buttonRightStick(value: number);
  44440. /**
  44441. * Gets the value of D-pad up
  44442. */
  44443. get dPadUp(): number;
  44444. /**
  44445. * Sets the value of D-pad up
  44446. */
  44447. set dPadUp(value: number);
  44448. /**
  44449. * Gets the value of D-pad down
  44450. */
  44451. get dPadDown(): number;
  44452. /**
  44453. * Sets the value of D-pad down
  44454. */
  44455. set dPadDown(value: number);
  44456. /**
  44457. * Gets the value of D-pad left
  44458. */
  44459. get dPadLeft(): number;
  44460. /**
  44461. * Sets the value of D-pad left
  44462. */
  44463. set dPadLeft(value: number);
  44464. /**
  44465. * Gets the value of D-pad right
  44466. */
  44467. get dPadRight(): number;
  44468. /**
  44469. * Sets the value of D-pad right
  44470. */
  44471. set dPadRight(value: number);
  44472. /**
  44473. * Force the gamepad to synchronize with device values
  44474. */
  44475. update(): void;
  44476. /**
  44477. * Disposes the gamepad
  44478. */
  44479. dispose(): void;
  44480. }
  44481. }
  44482. declare module BABYLON {
  44483. /**
  44484. * Defines supported buttons for DualShock compatible gamepads
  44485. */
  44486. export enum DualShockButton {
  44487. /** Cross */
  44488. Cross = 0,
  44489. /** Circle */
  44490. Circle = 1,
  44491. /** Square */
  44492. Square = 2,
  44493. /** Triangle */
  44494. Triangle = 3,
  44495. /** L1 */
  44496. L1 = 4,
  44497. /** R1 */
  44498. R1 = 5,
  44499. /** Share */
  44500. Share = 8,
  44501. /** Options */
  44502. Options = 9,
  44503. /** Left stick */
  44504. LeftStick = 10,
  44505. /** Right stick */
  44506. RightStick = 11
  44507. }
  44508. /** Defines values for DualShock DPad */
  44509. export enum DualShockDpad {
  44510. /** Up */
  44511. Up = 12,
  44512. /** Down */
  44513. Down = 13,
  44514. /** Left */
  44515. Left = 14,
  44516. /** Right */
  44517. Right = 15
  44518. }
  44519. /**
  44520. * Defines a DualShock gamepad
  44521. */
  44522. export class DualShockPad extends Gamepad {
  44523. private _leftTrigger;
  44524. private _rightTrigger;
  44525. private _onlefttriggerchanged;
  44526. private _onrighttriggerchanged;
  44527. private _onbuttondown;
  44528. private _onbuttonup;
  44529. private _ondpaddown;
  44530. private _ondpadup;
  44531. /** Observable raised when a button is pressed */
  44532. onButtonDownObservable: Observable<DualShockButton>;
  44533. /** Observable raised when a button is released */
  44534. onButtonUpObservable: Observable<DualShockButton>;
  44535. /** Observable raised when a pad is pressed */
  44536. onPadDownObservable: Observable<DualShockDpad>;
  44537. /** Observable raised when a pad is released */
  44538. onPadUpObservable: Observable<DualShockDpad>;
  44539. private _buttonCross;
  44540. private _buttonCircle;
  44541. private _buttonSquare;
  44542. private _buttonTriangle;
  44543. private _buttonShare;
  44544. private _buttonOptions;
  44545. private _buttonL1;
  44546. private _buttonR1;
  44547. private _buttonLeftStick;
  44548. private _buttonRightStick;
  44549. private _dPadUp;
  44550. private _dPadDown;
  44551. private _dPadLeft;
  44552. private _dPadRight;
  44553. /**
  44554. * Creates a new DualShock gamepad object
  44555. * @param id defines the id of this gamepad
  44556. * @param index defines its index
  44557. * @param gamepad defines the internal HTML gamepad object
  44558. */
  44559. constructor(id: string, index: number, gamepad: any);
  44560. /**
  44561. * Defines the callback to call when left trigger is pressed
  44562. * @param callback defines the callback to use
  44563. */
  44564. onlefttriggerchanged(callback: (value: number) => void): void;
  44565. /**
  44566. * Defines the callback to call when right trigger is pressed
  44567. * @param callback defines the callback to use
  44568. */
  44569. onrighttriggerchanged(callback: (value: number) => void): void;
  44570. /**
  44571. * Gets the left trigger value
  44572. */
  44573. get leftTrigger(): number;
  44574. /**
  44575. * Sets the left trigger value
  44576. */
  44577. set leftTrigger(newValue: number);
  44578. /**
  44579. * Gets the right trigger value
  44580. */
  44581. get rightTrigger(): number;
  44582. /**
  44583. * Sets the right trigger value
  44584. */
  44585. set rightTrigger(newValue: number);
  44586. /**
  44587. * Defines the callback to call when a button is pressed
  44588. * @param callback defines the callback to use
  44589. */
  44590. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44591. /**
  44592. * Defines the callback to call when a button is released
  44593. * @param callback defines the callback to use
  44594. */
  44595. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44596. /**
  44597. * Defines the callback to call when a pad is pressed
  44598. * @param callback defines the callback to use
  44599. */
  44600. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44601. /**
  44602. * Defines the callback to call when a pad is released
  44603. * @param callback defines the callback to use
  44604. */
  44605. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44606. private _setButtonValue;
  44607. private _setDPadValue;
  44608. /**
  44609. * Gets the value of the `Cross` button
  44610. */
  44611. get buttonCross(): number;
  44612. /**
  44613. * Sets the value of the `Cross` button
  44614. */
  44615. set buttonCross(value: number);
  44616. /**
  44617. * Gets the value of the `Circle` button
  44618. */
  44619. get buttonCircle(): number;
  44620. /**
  44621. * Sets the value of the `Circle` button
  44622. */
  44623. set buttonCircle(value: number);
  44624. /**
  44625. * Gets the value of the `Square` button
  44626. */
  44627. get buttonSquare(): number;
  44628. /**
  44629. * Sets the value of the `Square` button
  44630. */
  44631. set buttonSquare(value: number);
  44632. /**
  44633. * Gets the value of the `Triangle` button
  44634. */
  44635. get buttonTriangle(): number;
  44636. /**
  44637. * Sets the value of the `Triangle` button
  44638. */
  44639. set buttonTriangle(value: number);
  44640. /**
  44641. * Gets the value of the `Options` button
  44642. */
  44643. get buttonOptions(): number;
  44644. /**
  44645. * Sets the value of the `Options` button
  44646. */
  44647. set buttonOptions(value: number);
  44648. /**
  44649. * Gets the value of the `Share` button
  44650. */
  44651. get buttonShare(): number;
  44652. /**
  44653. * Sets the value of the `Share` button
  44654. */
  44655. set buttonShare(value: number);
  44656. /**
  44657. * Gets the value of the `L1` button
  44658. */
  44659. get buttonL1(): number;
  44660. /**
  44661. * Sets the value of the `L1` button
  44662. */
  44663. set buttonL1(value: number);
  44664. /**
  44665. * Gets the value of the `R1` button
  44666. */
  44667. get buttonR1(): number;
  44668. /**
  44669. * Sets the value of the `R1` button
  44670. */
  44671. set buttonR1(value: number);
  44672. /**
  44673. * Gets the value of the Left joystick
  44674. */
  44675. get buttonLeftStick(): number;
  44676. /**
  44677. * Sets the value of the Left joystick
  44678. */
  44679. set buttonLeftStick(value: number);
  44680. /**
  44681. * Gets the value of the Right joystick
  44682. */
  44683. get buttonRightStick(): number;
  44684. /**
  44685. * Sets the value of the Right joystick
  44686. */
  44687. set buttonRightStick(value: number);
  44688. /**
  44689. * Gets the value of D-pad up
  44690. */
  44691. get dPadUp(): number;
  44692. /**
  44693. * Sets the value of D-pad up
  44694. */
  44695. set dPadUp(value: number);
  44696. /**
  44697. * Gets the value of D-pad down
  44698. */
  44699. get dPadDown(): number;
  44700. /**
  44701. * Sets the value of D-pad down
  44702. */
  44703. set dPadDown(value: number);
  44704. /**
  44705. * Gets the value of D-pad left
  44706. */
  44707. get dPadLeft(): number;
  44708. /**
  44709. * Sets the value of D-pad left
  44710. */
  44711. set dPadLeft(value: number);
  44712. /**
  44713. * Gets the value of D-pad right
  44714. */
  44715. get dPadRight(): number;
  44716. /**
  44717. * Sets the value of D-pad right
  44718. */
  44719. set dPadRight(value: number);
  44720. /**
  44721. * Force the gamepad to synchronize with device values
  44722. */
  44723. update(): void;
  44724. /**
  44725. * Disposes the gamepad
  44726. */
  44727. dispose(): void;
  44728. }
  44729. }
  44730. declare module BABYLON {
  44731. /**
  44732. * Manager for handling gamepads
  44733. */
  44734. export class GamepadManager {
  44735. private _scene?;
  44736. private _babylonGamepads;
  44737. private _oneGamepadConnected;
  44738. /** @hidden */
  44739. _isMonitoring: boolean;
  44740. private _gamepadEventSupported;
  44741. private _gamepadSupport?;
  44742. /**
  44743. * observable to be triggered when the gamepad controller has been connected
  44744. */
  44745. onGamepadConnectedObservable: Observable<Gamepad>;
  44746. /**
  44747. * observable to be triggered when the gamepad controller has been disconnected
  44748. */
  44749. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44750. private _onGamepadConnectedEvent;
  44751. private _onGamepadDisconnectedEvent;
  44752. /**
  44753. * Initializes the gamepad manager
  44754. * @param _scene BabylonJS scene
  44755. */
  44756. constructor(_scene?: Scene | undefined);
  44757. /**
  44758. * The gamepads in the game pad manager
  44759. */
  44760. get gamepads(): Gamepad[];
  44761. /**
  44762. * Get the gamepad controllers based on type
  44763. * @param type The type of gamepad controller
  44764. * @returns Nullable gamepad
  44765. */
  44766. getGamepadByType(type?: number): Nullable<Gamepad>;
  44767. /**
  44768. * Disposes the gamepad manager
  44769. */
  44770. dispose(): void;
  44771. private _addNewGamepad;
  44772. private _startMonitoringGamepads;
  44773. private _stopMonitoringGamepads;
  44774. /** @hidden */
  44775. _checkGamepadsStatus(): void;
  44776. private _updateGamepadObjects;
  44777. }
  44778. }
  44779. declare module BABYLON {
  44780. interface Scene {
  44781. /** @hidden */
  44782. _gamepadManager: Nullable<GamepadManager>;
  44783. /**
  44784. * Gets the gamepad manager associated with the scene
  44785. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44786. */
  44787. gamepadManager: GamepadManager;
  44788. }
  44789. /**
  44790. * Interface representing a free camera inputs manager
  44791. */
  44792. interface FreeCameraInputsManager {
  44793. /**
  44794. * Adds gamepad input support to the FreeCameraInputsManager.
  44795. * @returns the FreeCameraInputsManager
  44796. */
  44797. addGamepad(): FreeCameraInputsManager;
  44798. }
  44799. /**
  44800. * Interface representing an arc rotate camera inputs manager
  44801. */
  44802. interface ArcRotateCameraInputsManager {
  44803. /**
  44804. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44805. * @returns the camera inputs manager
  44806. */
  44807. addGamepad(): ArcRotateCameraInputsManager;
  44808. }
  44809. /**
  44810. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44811. */
  44812. export class GamepadSystemSceneComponent implements ISceneComponent {
  44813. /**
  44814. * The component name helpfull to identify the component in the list of scene components.
  44815. */
  44816. readonly name: string;
  44817. /**
  44818. * The scene the component belongs to.
  44819. */
  44820. scene: Scene;
  44821. /**
  44822. * Creates a new instance of the component for the given scene
  44823. * @param scene Defines the scene to register the component in
  44824. */
  44825. constructor(scene: Scene);
  44826. /**
  44827. * Registers the component in a given scene
  44828. */
  44829. register(): void;
  44830. /**
  44831. * Rebuilds the elements related to this component in case of
  44832. * context lost for instance.
  44833. */
  44834. rebuild(): void;
  44835. /**
  44836. * Disposes the component and the associated ressources
  44837. */
  44838. dispose(): void;
  44839. private _beforeCameraUpdate;
  44840. }
  44841. }
  44842. declare module BABYLON {
  44843. /**
  44844. * 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,
  44845. * which still works and will still be found in many Playgrounds.
  44846. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44847. */
  44848. export class UniversalCamera extends TouchCamera {
  44849. /**
  44850. * Defines the gamepad rotation sensiblity.
  44851. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44852. */
  44853. get gamepadAngularSensibility(): number;
  44854. set gamepadAngularSensibility(value: number);
  44855. /**
  44856. * Defines the gamepad move sensiblity.
  44857. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44858. */
  44859. get gamepadMoveSensibility(): number;
  44860. set gamepadMoveSensibility(value: number);
  44861. /**
  44862. * 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,
  44863. * which still works and will still be found in many Playgrounds.
  44864. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44865. * @param name Define the name of the camera in the scene
  44866. * @param position Define the start position of the camera in the scene
  44867. * @param scene Define the scene the camera belongs to
  44868. */
  44869. constructor(name: string, position: Vector3, scene: Scene);
  44870. /**
  44871. * Gets the current object class name.
  44872. * @return the class name
  44873. */
  44874. getClassName(): string;
  44875. }
  44876. }
  44877. declare module BABYLON {
  44878. /**
  44879. * This represents a FPS type of camera. This is only here for back compat purpose.
  44880. * Please use the UniversalCamera instead as both are identical.
  44881. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44882. */
  44883. export class GamepadCamera extends UniversalCamera {
  44884. /**
  44885. * Instantiates a new Gamepad Camera
  44886. * This represents a FPS type of camera. This is only here for back compat purpose.
  44887. * Please use the UniversalCamera instead as both are identical.
  44888. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44889. * @param name Define the name of the camera in the scene
  44890. * @param position Define the start position of the camera in the scene
  44891. * @param scene Define the scene the camera belongs to
  44892. */
  44893. constructor(name: string, position: Vector3, scene: Scene);
  44894. /**
  44895. * Gets the current object class name.
  44896. * @return the class name
  44897. */
  44898. getClassName(): string;
  44899. }
  44900. }
  44901. declare module BABYLON {
  44902. /** @hidden */
  44903. export var passPixelShader: {
  44904. name: string;
  44905. shader: string;
  44906. };
  44907. }
  44908. declare module BABYLON {
  44909. /** @hidden */
  44910. export var passCubePixelShader: {
  44911. name: string;
  44912. shader: string;
  44913. };
  44914. }
  44915. declare module BABYLON {
  44916. /**
  44917. * PassPostProcess which produces an output the same as it's input
  44918. */
  44919. export class PassPostProcess extends PostProcess {
  44920. /**
  44921. * Creates the PassPostProcess
  44922. * @param name The name of the effect.
  44923. * @param options The required width/height ratio to downsize to before computing the render pass.
  44924. * @param camera The camera to apply the render pass to.
  44925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44926. * @param engine The engine which the post process will be applied. (default: current engine)
  44927. * @param reusable If the post process can be reused on the same frame. (default: false)
  44928. * @param textureType The type of texture to be used when performing the post processing.
  44929. * @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)
  44930. */
  44931. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44932. }
  44933. /**
  44934. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44935. */
  44936. export class PassCubePostProcess extends PostProcess {
  44937. private _face;
  44938. /**
  44939. * Gets or sets the cube face to display.
  44940. * * 0 is +X
  44941. * * 1 is -X
  44942. * * 2 is +Y
  44943. * * 3 is -Y
  44944. * * 4 is +Z
  44945. * * 5 is -Z
  44946. */
  44947. get face(): number;
  44948. set face(value: number);
  44949. /**
  44950. * Creates the PassCubePostProcess
  44951. * @param name The name of the effect.
  44952. * @param options The required width/height ratio to downsize to before computing the render pass.
  44953. * @param camera The camera to apply the render pass to.
  44954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44955. * @param engine The engine which the post process will be applied. (default: current engine)
  44956. * @param reusable If the post process can be reused on the same frame. (default: false)
  44957. * @param textureType The type of texture to be used when performing the post processing.
  44958. * @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)
  44959. */
  44960. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44961. }
  44962. }
  44963. declare module BABYLON {
  44964. /** @hidden */
  44965. export var anaglyphPixelShader: {
  44966. name: string;
  44967. shader: string;
  44968. };
  44969. }
  44970. declare module BABYLON {
  44971. /**
  44972. * Postprocess used to generate anaglyphic rendering
  44973. */
  44974. export class AnaglyphPostProcess extends PostProcess {
  44975. private _passedProcess;
  44976. /**
  44977. * Creates a new AnaglyphPostProcess
  44978. * @param name defines postprocess name
  44979. * @param options defines creation options or target ratio scale
  44980. * @param rigCameras defines cameras using this postprocess
  44981. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44982. * @param engine defines hosting engine
  44983. * @param reusable defines if the postprocess will be reused multiple times per frame
  44984. */
  44985. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44986. }
  44987. }
  44988. declare module BABYLON {
  44989. /**
  44990. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44991. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44992. */
  44993. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44994. /**
  44995. * Creates a new AnaglyphArcRotateCamera
  44996. * @param name defines camera name
  44997. * @param alpha defines alpha angle (in radians)
  44998. * @param beta defines beta angle (in radians)
  44999. * @param radius defines radius
  45000. * @param target defines camera target
  45001. * @param interaxialDistance defines distance between each color axis
  45002. * @param scene defines the hosting scene
  45003. */
  45004. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45005. /**
  45006. * Gets camera class name
  45007. * @returns AnaglyphArcRotateCamera
  45008. */
  45009. getClassName(): string;
  45010. }
  45011. }
  45012. declare module BABYLON {
  45013. /**
  45014. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45015. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45016. */
  45017. export class AnaglyphFreeCamera extends FreeCamera {
  45018. /**
  45019. * Creates a new AnaglyphFreeCamera
  45020. * @param name defines camera name
  45021. * @param position defines initial position
  45022. * @param interaxialDistance defines distance between each color axis
  45023. * @param scene defines the hosting scene
  45024. */
  45025. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45026. /**
  45027. * Gets camera class name
  45028. * @returns AnaglyphFreeCamera
  45029. */
  45030. getClassName(): string;
  45031. }
  45032. }
  45033. declare module BABYLON {
  45034. /**
  45035. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45036. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45037. */
  45038. export class AnaglyphGamepadCamera extends GamepadCamera {
  45039. /**
  45040. * Creates a new AnaglyphGamepadCamera
  45041. * @param name defines camera name
  45042. * @param position defines initial position
  45043. * @param interaxialDistance defines distance between each color axis
  45044. * @param scene defines the hosting scene
  45045. */
  45046. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45047. /**
  45048. * Gets camera class name
  45049. * @returns AnaglyphGamepadCamera
  45050. */
  45051. getClassName(): string;
  45052. }
  45053. }
  45054. declare module BABYLON {
  45055. /**
  45056. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45057. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45058. */
  45059. export class AnaglyphUniversalCamera extends UniversalCamera {
  45060. /**
  45061. * Creates a new AnaglyphUniversalCamera
  45062. * @param name defines camera name
  45063. * @param position defines initial position
  45064. * @param interaxialDistance defines distance between each color axis
  45065. * @param scene defines the hosting scene
  45066. */
  45067. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45068. /**
  45069. * Gets camera class name
  45070. * @returns AnaglyphUniversalCamera
  45071. */
  45072. getClassName(): string;
  45073. }
  45074. }
  45075. declare module BABYLON {
  45076. /**
  45077. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45078. * @see http://doc.babylonjs.com/features/cameras
  45079. */
  45080. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45081. /**
  45082. * Creates a new StereoscopicArcRotateCamera
  45083. * @param name defines camera name
  45084. * @param alpha defines alpha angle (in radians)
  45085. * @param beta defines beta angle (in radians)
  45086. * @param radius defines radius
  45087. * @param target defines camera target
  45088. * @param interaxialDistance defines distance between each color axis
  45089. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45090. * @param scene defines the hosting scene
  45091. */
  45092. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45093. /**
  45094. * Gets camera class name
  45095. * @returns StereoscopicArcRotateCamera
  45096. */
  45097. getClassName(): string;
  45098. }
  45099. }
  45100. declare module BABYLON {
  45101. /**
  45102. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45103. * @see http://doc.babylonjs.com/features/cameras
  45104. */
  45105. export class StereoscopicFreeCamera extends FreeCamera {
  45106. /**
  45107. * Creates a new StereoscopicFreeCamera
  45108. * @param name defines camera name
  45109. * @param position defines initial position
  45110. * @param interaxialDistance defines distance between each color axis
  45111. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45112. * @param scene defines the hosting scene
  45113. */
  45114. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45115. /**
  45116. * Gets camera class name
  45117. * @returns StereoscopicFreeCamera
  45118. */
  45119. getClassName(): string;
  45120. }
  45121. }
  45122. declare module BABYLON {
  45123. /**
  45124. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45125. * @see http://doc.babylonjs.com/features/cameras
  45126. */
  45127. export class StereoscopicGamepadCamera extends GamepadCamera {
  45128. /**
  45129. * Creates a new StereoscopicGamepadCamera
  45130. * @param name defines camera name
  45131. * @param position defines initial position
  45132. * @param interaxialDistance defines distance between each color axis
  45133. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45134. * @param scene defines the hosting scene
  45135. */
  45136. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45137. /**
  45138. * Gets camera class name
  45139. * @returns StereoscopicGamepadCamera
  45140. */
  45141. getClassName(): string;
  45142. }
  45143. }
  45144. declare module BABYLON {
  45145. /**
  45146. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45147. * @see http://doc.babylonjs.com/features/cameras
  45148. */
  45149. export class StereoscopicUniversalCamera extends UniversalCamera {
  45150. /**
  45151. * Creates a new StereoscopicUniversalCamera
  45152. * @param name defines camera name
  45153. * @param position defines initial position
  45154. * @param interaxialDistance defines distance between each color axis
  45155. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45156. * @param scene defines the hosting scene
  45157. */
  45158. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45159. /**
  45160. * Gets camera class name
  45161. * @returns StereoscopicUniversalCamera
  45162. */
  45163. getClassName(): string;
  45164. }
  45165. }
  45166. declare module BABYLON {
  45167. /**
  45168. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45169. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45170. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45171. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45172. */
  45173. export class VirtualJoysticksCamera extends FreeCamera {
  45174. /**
  45175. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45176. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45177. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45178. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45179. * @param name Define the name of the camera in the scene
  45180. * @param position Define the start position of the camera in the scene
  45181. * @param scene Define the scene the camera belongs to
  45182. */
  45183. constructor(name: string, position: Vector3, scene: Scene);
  45184. /**
  45185. * Gets the current object class name.
  45186. * @return the class name
  45187. */
  45188. getClassName(): string;
  45189. }
  45190. }
  45191. declare module BABYLON {
  45192. /**
  45193. * This represents all the required metrics to create a VR camera.
  45194. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45195. */
  45196. export class VRCameraMetrics {
  45197. /**
  45198. * Define the horizontal resolution off the screen.
  45199. */
  45200. hResolution: number;
  45201. /**
  45202. * Define the vertical resolution off the screen.
  45203. */
  45204. vResolution: number;
  45205. /**
  45206. * Define the horizontal screen size.
  45207. */
  45208. hScreenSize: number;
  45209. /**
  45210. * Define the vertical screen size.
  45211. */
  45212. vScreenSize: number;
  45213. /**
  45214. * Define the vertical screen center position.
  45215. */
  45216. vScreenCenter: number;
  45217. /**
  45218. * Define the distance of the eyes to the screen.
  45219. */
  45220. eyeToScreenDistance: number;
  45221. /**
  45222. * Define the distance between both lenses
  45223. */
  45224. lensSeparationDistance: number;
  45225. /**
  45226. * Define the distance between both viewer's eyes.
  45227. */
  45228. interpupillaryDistance: number;
  45229. /**
  45230. * Define the distortion factor of the VR postprocess.
  45231. * Please, touch with care.
  45232. */
  45233. distortionK: number[];
  45234. /**
  45235. * Define the chromatic aberration correction factors for the VR post process.
  45236. */
  45237. chromaAbCorrection: number[];
  45238. /**
  45239. * Define the scale factor of the post process.
  45240. * The smaller the better but the slower.
  45241. */
  45242. postProcessScaleFactor: number;
  45243. /**
  45244. * Define an offset for the lens center.
  45245. */
  45246. lensCenterOffset: number;
  45247. /**
  45248. * Define if the current vr camera should compensate the distortion of the lense or not.
  45249. */
  45250. compensateDistortion: boolean;
  45251. /**
  45252. * Defines if multiview should be enabled when rendering (Default: false)
  45253. */
  45254. multiviewEnabled: boolean;
  45255. /**
  45256. * Gets the rendering aspect ratio based on the provided resolutions.
  45257. */
  45258. get aspectRatio(): number;
  45259. /**
  45260. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45261. */
  45262. get aspectRatioFov(): number;
  45263. /**
  45264. * @hidden
  45265. */
  45266. get leftHMatrix(): Matrix;
  45267. /**
  45268. * @hidden
  45269. */
  45270. get rightHMatrix(): Matrix;
  45271. /**
  45272. * @hidden
  45273. */
  45274. get leftPreViewMatrix(): Matrix;
  45275. /**
  45276. * @hidden
  45277. */
  45278. get rightPreViewMatrix(): Matrix;
  45279. /**
  45280. * Get the default VRMetrics based on the most generic setup.
  45281. * @returns the default vr metrics
  45282. */
  45283. static GetDefault(): VRCameraMetrics;
  45284. }
  45285. }
  45286. declare module BABYLON {
  45287. /** @hidden */
  45288. export var vrDistortionCorrectionPixelShader: {
  45289. name: string;
  45290. shader: string;
  45291. };
  45292. }
  45293. declare module BABYLON {
  45294. /**
  45295. * VRDistortionCorrectionPostProcess used for mobile VR
  45296. */
  45297. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45298. private _isRightEye;
  45299. private _distortionFactors;
  45300. private _postProcessScaleFactor;
  45301. private _lensCenterOffset;
  45302. private _scaleIn;
  45303. private _scaleFactor;
  45304. private _lensCenter;
  45305. /**
  45306. * Initializes the VRDistortionCorrectionPostProcess
  45307. * @param name The name of the effect.
  45308. * @param camera The camera to apply the render pass to.
  45309. * @param isRightEye If this is for the right eye distortion
  45310. * @param vrMetrics All the required metrics for the VR camera
  45311. */
  45312. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45313. }
  45314. }
  45315. declare module BABYLON {
  45316. /**
  45317. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45318. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45319. */
  45320. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45321. /**
  45322. * Creates a new VRDeviceOrientationArcRotateCamera
  45323. * @param name defines camera name
  45324. * @param alpha defines the camera rotation along the logitudinal axis
  45325. * @param beta defines the camera rotation along the latitudinal axis
  45326. * @param radius defines the camera distance from its target
  45327. * @param target defines the camera target
  45328. * @param scene defines the scene the camera belongs to
  45329. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45330. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45331. */
  45332. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45333. /**
  45334. * Gets camera class name
  45335. * @returns VRDeviceOrientationArcRotateCamera
  45336. */
  45337. getClassName(): string;
  45338. }
  45339. }
  45340. declare module BABYLON {
  45341. /**
  45342. * Camera used to simulate VR rendering (based on FreeCamera)
  45343. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45344. */
  45345. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45346. /**
  45347. * Creates a new VRDeviceOrientationFreeCamera
  45348. * @param name defines camera name
  45349. * @param position defines the start position of the camera
  45350. * @param scene defines the scene the camera belongs to
  45351. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45352. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45353. */
  45354. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45355. /**
  45356. * Gets camera class name
  45357. * @returns VRDeviceOrientationFreeCamera
  45358. */
  45359. getClassName(): string;
  45360. }
  45361. }
  45362. declare module BABYLON {
  45363. /**
  45364. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45365. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45366. */
  45367. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45368. /**
  45369. * Creates a new VRDeviceOrientationGamepadCamera
  45370. * @param name defines camera name
  45371. * @param position defines the start position of the camera
  45372. * @param scene defines the scene the camera belongs to
  45373. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45374. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45375. */
  45376. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45377. /**
  45378. * Gets camera class name
  45379. * @returns VRDeviceOrientationGamepadCamera
  45380. */
  45381. getClassName(): string;
  45382. }
  45383. }
  45384. declare module BABYLON {
  45385. /**
  45386. * A class extending Texture allowing drawing on a texture
  45387. * @see http://doc.babylonjs.com/how_to/dynamictexture
  45388. */
  45389. export class DynamicTexture extends Texture {
  45390. private _generateMipMaps;
  45391. private _canvas;
  45392. private _context;
  45393. /**
  45394. * Creates a DynamicTexture
  45395. * @param name defines the name of the texture
  45396. * @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
  45397. * @param scene defines the scene where you want the texture
  45398. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45399. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  45400. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  45401. */
  45402. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45403. /**
  45404. * Get the current class name of the texture useful for serialization or dynamic coding.
  45405. * @returns "DynamicTexture"
  45406. */
  45407. getClassName(): string;
  45408. /**
  45409. * Gets the current state of canRescale
  45410. */
  45411. get canRescale(): boolean;
  45412. private _recreate;
  45413. /**
  45414. * Scales the texture
  45415. * @param ratio the scale factor to apply to both width and height
  45416. */
  45417. scale(ratio: number): void;
  45418. /**
  45419. * Resizes the texture
  45420. * @param width the new width
  45421. * @param height the new height
  45422. */
  45423. scaleTo(width: number, height: number): void;
  45424. /**
  45425. * Gets the context of the canvas used by the texture
  45426. * @returns the canvas context of the dynamic texture
  45427. */
  45428. getContext(): CanvasRenderingContext2D;
  45429. /**
  45430. * Clears the texture
  45431. */
  45432. clear(): void;
  45433. /**
  45434. * Updates the texture
  45435. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45436. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45437. */
  45438. update(invertY?: boolean, premulAlpha?: boolean): void;
  45439. /**
  45440. * Draws text onto the texture
  45441. * @param text defines the text to be drawn
  45442. * @param x defines the placement of the text from the left
  45443. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45444. * @param font defines the font to be used with font-style, font-size, font-name
  45445. * @param color defines the color used for the text
  45446. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45447. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45448. * @param update defines whether texture is immediately update (default is true)
  45449. */
  45450. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  45451. /**
  45452. * Clones the texture
  45453. * @returns the clone of the texture.
  45454. */
  45455. clone(): DynamicTexture;
  45456. /**
  45457. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45458. * @returns a serialized dynamic texture object
  45459. */
  45460. serialize(): any;
  45461. private _IsCanvasElement;
  45462. /** @hidden */
  45463. _rebuild(): void;
  45464. }
  45465. }
  45466. declare module BABYLON {
  45467. /** @hidden */
  45468. export var imageProcessingPixelShader: {
  45469. name: string;
  45470. shader: string;
  45471. };
  45472. }
  45473. declare module BABYLON {
  45474. /**
  45475. * ImageProcessingPostProcess
  45476. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45477. */
  45478. export class ImageProcessingPostProcess extends PostProcess {
  45479. /**
  45480. * Default configuration related to image processing available in the PBR Material.
  45481. */
  45482. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45483. /**
  45484. * Gets the image processing configuration used either in this material.
  45485. */
  45486. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45487. /**
  45488. * Sets the Default image processing configuration used either in the this material.
  45489. *
  45490. * If sets to null, the scene one is in use.
  45491. */
  45492. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45493. /**
  45494. * Keep track of the image processing observer to allow dispose and replace.
  45495. */
  45496. private _imageProcessingObserver;
  45497. /**
  45498. * Attaches a new image processing configuration to the PBR Material.
  45499. * @param configuration
  45500. */
  45501. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45502. /**
  45503. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45504. */
  45505. get colorCurves(): Nullable<ColorCurves>;
  45506. /**
  45507. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45508. */
  45509. set colorCurves(value: Nullable<ColorCurves>);
  45510. /**
  45511. * Gets wether the color curves effect is enabled.
  45512. */
  45513. get colorCurvesEnabled(): boolean;
  45514. /**
  45515. * Sets wether the color curves effect is enabled.
  45516. */
  45517. set colorCurvesEnabled(value: boolean);
  45518. /**
  45519. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45520. */
  45521. get colorGradingTexture(): Nullable<BaseTexture>;
  45522. /**
  45523. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45524. */
  45525. set colorGradingTexture(value: Nullable<BaseTexture>);
  45526. /**
  45527. * Gets wether the color grading effect is enabled.
  45528. */
  45529. get colorGradingEnabled(): boolean;
  45530. /**
  45531. * Gets wether the color grading effect is enabled.
  45532. */
  45533. set colorGradingEnabled(value: boolean);
  45534. /**
  45535. * Gets exposure used in the effect.
  45536. */
  45537. get exposure(): number;
  45538. /**
  45539. * Sets exposure used in the effect.
  45540. */
  45541. set exposure(value: number);
  45542. /**
  45543. * Gets wether tonemapping is enabled or not.
  45544. */
  45545. get toneMappingEnabled(): boolean;
  45546. /**
  45547. * Sets wether tonemapping is enabled or not
  45548. */
  45549. set toneMappingEnabled(value: boolean);
  45550. /**
  45551. * Gets the type of tone mapping effect.
  45552. */
  45553. get toneMappingType(): number;
  45554. /**
  45555. * Sets the type of tone mapping effect.
  45556. */
  45557. set toneMappingType(value: number);
  45558. /**
  45559. * Gets contrast used in the effect.
  45560. */
  45561. get contrast(): number;
  45562. /**
  45563. * Sets contrast used in the effect.
  45564. */
  45565. set contrast(value: number);
  45566. /**
  45567. * Gets Vignette stretch size.
  45568. */
  45569. get vignetteStretch(): number;
  45570. /**
  45571. * Sets Vignette stretch size.
  45572. */
  45573. set vignetteStretch(value: number);
  45574. /**
  45575. * Gets Vignette centre X Offset.
  45576. */
  45577. get vignetteCentreX(): number;
  45578. /**
  45579. * Sets Vignette centre X Offset.
  45580. */
  45581. set vignetteCentreX(value: number);
  45582. /**
  45583. * Gets Vignette centre Y Offset.
  45584. */
  45585. get vignetteCentreY(): number;
  45586. /**
  45587. * Sets Vignette centre Y Offset.
  45588. */
  45589. set vignetteCentreY(value: number);
  45590. /**
  45591. * Gets Vignette weight or intensity of the vignette effect.
  45592. */
  45593. get vignetteWeight(): number;
  45594. /**
  45595. * Sets Vignette weight or intensity of the vignette effect.
  45596. */
  45597. set vignetteWeight(value: number);
  45598. /**
  45599. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45600. * if vignetteEnabled is set to true.
  45601. */
  45602. get vignetteColor(): Color4;
  45603. /**
  45604. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45605. * if vignetteEnabled is set to true.
  45606. */
  45607. set vignetteColor(value: Color4);
  45608. /**
  45609. * Gets Camera field of view used by the Vignette effect.
  45610. */
  45611. get vignetteCameraFov(): number;
  45612. /**
  45613. * Sets Camera field of view used by the Vignette effect.
  45614. */
  45615. set vignetteCameraFov(value: number);
  45616. /**
  45617. * Gets the vignette blend mode allowing different kind of effect.
  45618. */
  45619. get vignetteBlendMode(): number;
  45620. /**
  45621. * Sets the vignette blend mode allowing different kind of effect.
  45622. */
  45623. set vignetteBlendMode(value: number);
  45624. /**
  45625. * Gets wether the vignette effect is enabled.
  45626. */
  45627. get vignetteEnabled(): boolean;
  45628. /**
  45629. * Sets wether the vignette effect is enabled.
  45630. */
  45631. set vignetteEnabled(value: boolean);
  45632. private _fromLinearSpace;
  45633. /**
  45634. * Gets wether the input of the processing is in Gamma or Linear Space.
  45635. */
  45636. get fromLinearSpace(): boolean;
  45637. /**
  45638. * Sets wether the input of the processing is in Gamma or Linear Space.
  45639. */
  45640. set fromLinearSpace(value: boolean);
  45641. /**
  45642. * Defines cache preventing GC.
  45643. */
  45644. private _defines;
  45645. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45646. /**
  45647. * "ImageProcessingPostProcess"
  45648. * @returns "ImageProcessingPostProcess"
  45649. */
  45650. getClassName(): string;
  45651. protected _updateParameters(): void;
  45652. dispose(camera?: Camera): void;
  45653. }
  45654. }
  45655. declare module BABYLON {
  45656. /**
  45657. * Class containing static functions to help procedurally build meshes
  45658. */
  45659. export class GroundBuilder {
  45660. /**
  45661. * Creates a ground mesh
  45662. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45663. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45665. * @param name defines the name of the mesh
  45666. * @param options defines the options used to create the mesh
  45667. * @param scene defines the hosting scene
  45668. * @returns the ground mesh
  45669. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45670. */
  45671. static CreateGround(name: string, options: {
  45672. width?: number;
  45673. height?: number;
  45674. subdivisions?: number;
  45675. subdivisionsX?: number;
  45676. subdivisionsY?: number;
  45677. updatable?: boolean;
  45678. }, scene: any): Mesh;
  45679. /**
  45680. * Creates a tiled ground mesh
  45681. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45682. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45683. * * 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
  45684. * * 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
  45685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45686. * @param name defines the name of the mesh
  45687. * @param options defines the options used to create the mesh
  45688. * @param scene defines the hosting scene
  45689. * @returns the tiled ground mesh
  45690. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45691. */
  45692. static CreateTiledGround(name: string, options: {
  45693. xmin: number;
  45694. zmin: number;
  45695. xmax: number;
  45696. zmax: number;
  45697. subdivisions?: {
  45698. w: number;
  45699. h: number;
  45700. };
  45701. precision?: {
  45702. w: number;
  45703. h: number;
  45704. };
  45705. updatable?: boolean;
  45706. }, scene?: Nullable<Scene>): Mesh;
  45707. /**
  45708. * Creates a ground mesh from a height map
  45709. * * The parameter `url` sets the URL of the height map image resource.
  45710. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45711. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45712. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45713. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45714. * * 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.
  45715. * * 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).
  45716. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45718. * @param name defines the name of the mesh
  45719. * @param url defines the url to the height map
  45720. * @param options defines the options used to create the mesh
  45721. * @param scene defines the hosting scene
  45722. * @returns the ground mesh
  45723. * @see https://doc.babylonjs.com/babylon101/height_map
  45724. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45725. */
  45726. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45727. width?: number;
  45728. height?: number;
  45729. subdivisions?: number;
  45730. minHeight?: number;
  45731. maxHeight?: number;
  45732. colorFilter?: Color3;
  45733. alphaFilter?: number;
  45734. updatable?: boolean;
  45735. onReady?: (mesh: GroundMesh) => void;
  45736. }, scene?: Nullable<Scene>): GroundMesh;
  45737. }
  45738. }
  45739. declare module BABYLON {
  45740. /**
  45741. * Class containing static functions to help procedurally build meshes
  45742. */
  45743. export class TorusBuilder {
  45744. /**
  45745. * Creates a torus mesh
  45746. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45747. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45748. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45750. * * 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
  45751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45752. * @param name defines the name of the mesh
  45753. * @param options defines the options used to create the mesh
  45754. * @param scene defines the hosting scene
  45755. * @returns the torus mesh
  45756. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45757. */
  45758. static CreateTorus(name: string, options: {
  45759. diameter?: number;
  45760. thickness?: number;
  45761. tessellation?: number;
  45762. updatable?: boolean;
  45763. sideOrientation?: number;
  45764. frontUVs?: Vector4;
  45765. backUVs?: Vector4;
  45766. }, scene: any): Mesh;
  45767. }
  45768. }
  45769. declare module BABYLON {
  45770. /**
  45771. * Class containing static functions to help procedurally build meshes
  45772. */
  45773. export class CylinderBuilder {
  45774. /**
  45775. * Creates a cylinder or a cone mesh
  45776. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45777. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45778. * * 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.
  45779. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45780. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45781. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45782. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45783. * * 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).
  45784. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45785. * * 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).
  45786. * * 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
  45787. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45788. * * 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
  45789. * * 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.
  45790. * * If `enclose` is false, a ring surface is one element.
  45791. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45792. * * 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
  45793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45794. * * 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
  45795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45796. * @param name defines the name of the mesh
  45797. * @param options defines the options used to create the mesh
  45798. * @param scene defines the hosting scene
  45799. * @returns the cylinder mesh
  45800. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45801. */
  45802. static CreateCylinder(name: string, options: {
  45803. height?: number;
  45804. diameterTop?: number;
  45805. diameterBottom?: number;
  45806. diameter?: number;
  45807. tessellation?: number;
  45808. subdivisions?: number;
  45809. arc?: number;
  45810. faceColors?: Color4[];
  45811. faceUV?: Vector4[];
  45812. updatable?: boolean;
  45813. hasRings?: boolean;
  45814. enclose?: boolean;
  45815. cap?: number;
  45816. sideOrientation?: number;
  45817. frontUVs?: Vector4;
  45818. backUVs?: Vector4;
  45819. }, scene: any): Mesh;
  45820. }
  45821. }
  45822. declare module BABYLON {
  45823. /**
  45824. * States of the webXR experience
  45825. */
  45826. export enum WebXRState {
  45827. /**
  45828. * Transitioning to being in XR mode
  45829. */
  45830. ENTERING_XR = 0,
  45831. /**
  45832. * Transitioning to non XR mode
  45833. */
  45834. EXITING_XR = 1,
  45835. /**
  45836. * In XR mode and presenting
  45837. */
  45838. IN_XR = 2,
  45839. /**
  45840. * Not entered XR mode
  45841. */
  45842. NOT_IN_XR = 3
  45843. }
  45844. /**
  45845. * Abstraction of the XR render target
  45846. */
  45847. export interface WebXRRenderTarget extends IDisposable {
  45848. /**
  45849. * xrpresent context of the canvas which can be used to display/mirror xr content
  45850. */
  45851. canvasContext: WebGLRenderingContext;
  45852. /**
  45853. * xr layer for the canvas
  45854. */
  45855. xrLayer: Nullable<XRWebGLLayer>;
  45856. /**
  45857. * Initializes the xr layer for the session
  45858. * @param xrSession xr session
  45859. * @returns a promise that will resolve once the XR Layer has been created
  45860. */
  45861. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45862. }
  45863. }
  45864. declare module BABYLON {
  45865. /**
  45866. * COnfiguration object for WebXR output canvas
  45867. */
  45868. export class WebXRManagedOutputCanvasOptions {
  45869. /**
  45870. * An optional canvas in case you wish to create it yourself and provide it here.
  45871. * If not provided, a new canvas will be created
  45872. */
  45873. canvasElement?: HTMLCanvasElement;
  45874. /**
  45875. * Options for this XR Layer output
  45876. */
  45877. canvasOptions?: XRWebGLLayerOptions;
  45878. /**
  45879. * CSS styling for a newly created canvas (if not provided)
  45880. */
  45881. newCanvasCssStyle?: string;
  45882. /**
  45883. * Get the default values of the configuration object
  45884. * @returns default values of this configuration object
  45885. */
  45886. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45887. }
  45888. /**
  45889. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45890. */
  45891. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45892. private _options;
  45893. private _canvas;
  45894. private _engine;
  45895. /**
  45896. * Rendering context of the canvas which can be used to display/mirror xr content
  45897. */
  45898. canvasContext: WebGLRenderingContext;
  45899. /**
  45900. * xr layer for the canvas
  45901. */
  45902. xrLayer: Nullable<XRWebGLLayer>;
  45903. /**
  45904. * Initializes the canvas to be added/removed upon entering/exiting xr
  45905. * @param _xrSessionManager The XR Session manager
  45906. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45907. */
  45908. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45909. /**
  45910. * Disposes of the object
  45911. */
  45912. dispose(): void;
  45913. /**
  45914. * Initializes the xr layer for the session
  45915. * @param xrSession xr session
  45916. * @returns a promise that will resolve once the XR Layer has been created
  45917. */
  45918. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45919. private _addCanvas;
  45920. private _removeCanvas;
  45921. private _setManagedOutputCanvas;
  45922. }
  45923. }
  45924. declare module BABYLON {
  45925. /**
  45926. * Manages an XRSession to work with Babylon's engine
  45927. * @see https://doc.babylonjs.com/how_to/webxr
  45928. */
  45929. export class WebXRSessionManager implements IDisposable {
  45930. /** The scene which the session should be created for */
  45931. scene: Scene;
  45932. private _referenceSpace;
  45933. private _rttProvider;
  45934. private _sessionEnded;
  45935. private _xrNavigator;
  45936. private baseLayer;
  45937. /**
  45938. * The base reference space from which the session started. good if you want to reset your
  45939. * reference space
  45940. */
  45941. baseReferenceSpace: XRReferenceSpace;
  45942. /**
  45943. * Current XR frame
  45944. */
  45945. currentFrame: Nullable<XRFrame>;
  45946. /** WebXR timestamp updated every frame */
  45947. currentTimestamp: number;
  45948. /**
  45949. * Used just in case of a failure to initialize an immersive session.
  45950. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45951. */
  45952. defaultHeightCompensation: number;
  45953. /**
  45954. * Fires every time a new xrFrame arrives which can be used to update the camera
  45955. */
  45956. onXRFrameObservable: Observable<XRFrame>;
  45957. /**
  45958. * Fires when the reference space changed
  45959. */
  45960. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45961. /**
  45962. * Fires when the xr session is ended either by the device or manually done
  45963. */
  45964. onXRSessionEnded: Observable<any>;
  45965. /**
  45966. * Fires when the xr session is ended either by the device or manually done
  45967. */
  45968. onXRSessionInit: Observable<XRSession>;
  45969. /**
  45970. * Underlying xr session
  45971. */
  45972. session: XRSession;
  45973. /**
  45974. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45975. * or get the offset the player is currently at.
  45976. */
  45977. viewerReferenceSpace: XRReferenceSpace;
  45978. /**
  45979. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45980. * @param scene The scene which the session should be created for
  45981. */
  45982. constructor(
  45983. /** The scene which the session should be created for */
  45984. scene: Scene);
  45985. /**
  45986. * The current reference space used in this session. This reference space can constantly change!
  45987. * It is mainly used to offset the camera's position.
  45988. */
  45989. get referenceSpace(): XRReferenceSpace;
  45990. /**
  45991. * Set a new reference space and triggers the observable
  45992. */
  45993. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45994. /**
  45995. * Disposes of the session manager
  45996. */
  45997. dispose(): void;
  45998. /**
  45999. * Stops the xrSession and restores the render loop
  46000. * @returns Promise which resolves after it exits XR
  46001. */
  46002. exitXRAsync(): Promise<void>;
  46003. /**
  46004. * Gets the correct render target texture to be rendered this frame for this eye
  46005. * @param eye the eye for which to get the render target
  46006. * @returns the render target for the specified eye
  46007. */
  46008. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46009. /**
  46010. * Creates a WebXRRenderTarget object for the XR session
  46011. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46012. * @param options optional options to provide when creating a new render target
  46013. * @returns a WebXR render target to which the session can render
  46014. */
  46015. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46016. /**
  46017. * Initializes the manager
  46018. * After initialization enterXR can be called to start an XR session
  46019. * @returns Promise which resolves after it is initialized
  46020. */
  46021. initializeAsync(): Promise<void>;
  46022. /**
  46023. * Initializes an xr session
  46024. * @param xrSessionMode mode to initialize
  46025. * @param xrSessionInit defines optional and required values to pass to the session builder
  46026. * @returns a promise which will resolve once the session has been initialized
  46027. */
  46028. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46029. /**
  46030. * Checks if a session would be supported for the creation options specified
  46031. * @param sessionMode session mode to check if supported eg. immersive-vr
  46032. * @returns A Promise that resolves to true if supported and false if not
  46033. */
  46034. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46035. /**
  46036. * Resets the reference space to the one started the session
  46037. */
  46038. resetReferenceSpace(): void;
  46039. /**
  46040. * Starts rendering to the xr layer
  46041. */
  46042. runXRRenderLoop(): void;
  46043. /**
  46044. * Sets the reference space on the xr session
  46045. * @param referenceSpaceType space to set
  46046. * @returns a promise that will resolve once the reference space has been set
  46047. */
  46048. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46049. /**
  46050. * Updates the render state of the session
  46051. * @param state state to set
  46052. * @returns a promise that resolves once the render state has been updated
  46053. */
  46054. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46055. /**
  46056. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46057. * @param sessionMode defines the session to test
  46058. * @returns a promise with boolean as final value
  46059. */
  46060. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46061. private _createRenderTargetTexture;
  46062. }
  46063. }
  46064. declare module BABYLON {
  46065. /**
  46066. * WebXR Camera which holds the views for the xrSession
  46067. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46068. */
  46069. export class WebXRCamera extends FreeCamera {
  46070. private _xrSessionManager;
  46071. private _firstFrame;
  46072. private _referenceQuaternion;
  46073. private _referencedPosition;
  46074. private _xrInvPositionCache;
  46075. private _xrInvQuaternionCache;
  46076. /**
  46077. * Should position compensation execute on first frame.
  46078. * This is used when copying the position from a native (non XR) camera
  46079. */
  46080. compensateOnFirstFrame: boolean;
  46081. /**
  46082. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46083. * @param name the name of the camera
  46084. * @param scene the scene to add the camera to
  46085. * @param _xrSessionManager a constructed xr session manager
  46086. */
  46087. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46088. /**
  46089. * Return the user's height, unrelated to the current ground.
  46090. * This will be the y position of this camera, when ground level is 0.
  46091. */
  46092. get realWorldHeight(): number;
  46093. /** @hidden */
  46094. _updateForDualEyeDebugging(): void;
  46095. /**
  46096. * Sets this camera's transformation based on a non-vr camera
  46097. * @param otherCamera the non-vr camera to copy the transformation from
  46098. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46099. */
  46100. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46101. /**
  46102. * Gets the current instance class name ("WebXRCamera").
  46103. * @returns the class name
  46104. */
  46105. getClassName(): string;
  46106. /**
  46107. * Overriding the _getViewMatrix function, as it is computed by WebXR
  46108. */
  46109. _getViewMatrix(): Matrix;
  46110. private _updateFromXRSession;
  46111. private _updateNumberOfRigCameras;
  46112. private _updateReferenceSpace;
  46113. private _updateReferenceSpaceOffset;
  46114. }
  46115. }
  46116. declare module BABYLON {
  46117. /**
  46118. * Defining the interface required for a (webxr) feature
  46119. */
  46120. export interface IWebXRFeature extends IDisposable {
  46121. /**
  46122. * Is this feature attached
  46123. */
  46124. attached: boolean;
  46125. /**
  46126. * Should auto-attach be disabled?
  46127. */
  46128. disableAutoAttach: boolean;
  46129. /**
  46130. * Attach the feature to the session
  46131. * Will usually be called by the features manager
  46132. *
  46133. * @param force should attachment be forced (even when already attached)
  46134. * @returns true if successful.
  46135. */
  46136. attach(force?: boolean): boolean;
  46137. /**
  46138. * Detach the feature from the session
  46139. * Will usually be called by the features manager
  46140. *
  46141. * @returns true if successful.
  46142. */
  46143. detach(): boolean;
  46144. }
  46145. /**
  46146. * A list of the currently available features without referencing them
  46147. */
  46148. export class WebXRFeatureName {
  46149. /**
  46150. * The name of the anchor system feature
  46151. */
  46152. static ANCHOR_SYSTEM: string;
  46153. /**
  46154. * The name of the background remover feature
  46155. */
  46156. static BACKGROUND_REMOVER: string;
  46157. /**
  46158. * The name of the hit test feature
  46159. */
  46160. static HIT_TEST: string;
  46161. /**
  46162. * physics impostors for xr controllers feature
  46163. */
  46164. static PHYSICS_CONTROLLERS: string;
  46165. /**
  46166. * The name of the plane detection feature
  46167. */
  46168. static PLANE_DETECTION: string;
  46169. /**
  46170. * The name of the pointer selection feature
  46171. */
  46172. static POINTER_SELECTION: string;
  46173. /**
  46174. * The name of the teleportation feature
  46175. */
  46176. static TELEPORTATION: string;
  46177. }
  46178. /**
  46179. * Defining the constructor of a feature. Used to register the modules.
  46180. */
  46181. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46182. /**
  46183. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46184. * It is mainly used in AR sessions.
  46185. *
  46186. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46187. */
  46188. export class WebXRFeaturesManager implements IDisposable {
  46189. private _xrSessionManager;
  46190. private static readonly _AvailableFeatures;
  46191. private _features;
  46192. /**
  46193. * constructs a new features manages.
  46194. *
  46195. * @param _xrSessionManager an instance of WebXRSessionManager
  46196. */
  46197. constructor(_xrSessionManager: WebXRSessionManager);
  46198. /**
  46199. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46200. * Mainly used internally.
  46201. *
  46202. * @param featureName the name of the feature to register
  46203. * @param constructorFunction the function used to construct the module
  46204. * @param version the (babylon) version of the module
  46205. * @param stable is that a stable version of this module
  46206. */
  46207. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46208. /**
  46209. * Returns a constructor of a specific feature.
  46210. *
  46211. * @param featureName the name of the feature to construct
  46212. * @param version the version of the feature to load
  46213. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46214. * @param options optional options provided to the module.
  46215. * @returns a function that, when called, will return a new instance of this feature
  46216. */
  46217. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46218. /**
  46219. * Can be used to return the list of features currently registered
  46220. *
  46221. * @returns an Array of available features
  46222. */
  46223. static GetAvailableFeatures(): string[];
  46224. /**
  46225. * Gets the versions available for a specific feature
  46226. * @param featureName the name of the feature
  46227. * @returns an array with the available versions
  46228. */
  46229. static GetAvailableVersions(featureName: string): string[];
  46230. /**
  46231. * Return the latest unstable version of this feature
  46232. * @param featureName the name of the feature to search
  46233. * @returns the version number. if not found will return -1
  46234. */
  46235. static GetLatestVersionOfFeature(featureName: string): number;
  46236. /**
  46237. * Return the latest stable version of this feature
  46238. * @param featureName the name of the feature to search
  46239. * @returns the version number. if not found will return -1
  46240. */
  46241. static GetStableVersionOfFeature(featureName: string): number;
  46242. /**
  46243. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46244. * Can be used during a session to start a feature
  46245. * @param featureName the name of feature to attach
  46246. */
  46247. attachFeature(featureName: string): void;
  46248. /**
  46249. * Can be used inside a session or when the session ends to detach a specific feature
  46250. * @param featureName the name of the feature to detach
  46251. */
  46252. detachFeature(featureName: string): void;
  46253. /**
  46254. * Used to disable an already-enabled feature
  46255. * The feature will be disposed and will be recreated once enabled.
  46256. * @param featureName the feature to disable
  46257. * @returns true if disable was successful
  46258. */
  46259. disableFeature(featureName: string | {
  46260. Name: string;
  46261. }): boolean;
  46262. /**
  46263. * dispose this features manager
  46264. */
  46265. dispose(): void;
  46266. /**
  46267. * 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.
  46268. * 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.
  46269. *
  46270. * @param featureName the name of the feature to load or the class of the feature
  46271. * @param version optional version to load. if not provided the latest version will be enabled
  46272. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46273. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46274. * @returns a new constructed feature or throws an error if feature not found.
  46275. */
  46276. enableFeature(featureName: string | {
  46277. Name: string;
  46278. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46279. /**
  46280. * get the implementation of an enabled feature.
  46281. * @param featureName the name of the feature to load
  46282. * @returns the feature class, if found
  46283. */
  46284. getEnabledFeature(featureName: string): IWebXRFeature;
  46285. /**
  46286. * Get the list of enabled features
  46287. * @returns an array of enabled features
  46288. */
  46289. getEnabledFeatures(): string[];
  46290. }
  46291. }
  46292. declare module BABYLON {
  46293. /**
  46294. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46295. * @see https://doc.babylonjs.com/how_to/webxr
  46296. */
  46297. export class WebXRExperienceHelper implements IDisposable {
  46298. private scene;
  46299. private _nonVRCamera;
  46300. private _originalSceneAutoClear;
  46301. private _supported;
  46302. /**
  46303. * Camera used to render xr content
  46304. */
  46305. camera: WebXRCamera;
  46306. /** A features manager for this xr session */
  46307. featuresManager: WebXRFeaturesManager;
  46308. /**
  46309. * Observers registered here will be triggered after the camera's initial transformation is set
  46310. * This can be used to set a different ground level or an extra rotation.
  46311. *
  46312. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46313. * to the position set after this observable is done executing.
  46314. */
  46315. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46316. /**
  46317. * Fires when the state of the experience helper has changed
  46318. */
  46319. onStateChangedObservable: Observable<WebXRState>;
  46320. /** Session manager used to keep track of xr session */
  46321. sessionManager: WebXRSessionManager;
  46322. /**
  46323. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46324. */
  46325. state: WebXRState;
  46326. /**
  46327. * Creates a WebXRExperienceHelper
  46328. * @param scene The scene the helper should be created in
  46329. */
  46330. private constructor();
  46331. /**
  46332. * Creates the experience helper
  46333. * @param scene the scene to attach the experience helper to
  46334. * @returns a promise for the experience helper
  46335. */
  46336. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46337. /**
  46338. * Disposes of the experience helper
  46339. */
  46340. dispose(): void;
  46341. /**
  46342. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46343. * @param sessionMode options for the XR session
  46344. * @param referenceSpaceType frame of reference of the XR session
  46345. * @param renderTarget the output canvas that will be used to enter XR mode
  46346. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46347. * @returns promise that resolves after xr mode has entered
  46348. */
  46349. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46350. /**
  46351. * Exits XR mode and returns the scene to its original state
  46352. * @returns promise that resolves after xr mode has exited
  46353. */
  46354. exitXRAsync(): Promise<void>;
  46355. private _nonXRToXRCamera;
  46356. private _setState;
  46357. }
  46358. }
  46359. declare module BABYLON {
  46360. /**
  46361. * X-Y values for axes in WebXR
  46362. */
  46363. export interface IWebXRMotionControllerAxesValue {
  46364. /**
  46365. * The value of the x axis
  46366. */
  46367. x: number;
  46368. /**
  46369. * The value of the y-axis
  46370. */
  46371. y: number;
  46372. }
  46373. /**
  46374. * changed / previous values for the values of this component
  46375. */
  46376. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46377. /**
  46378. * current (this frame) value
  46379. */
  46380. current: T;
  46381. /**
  46382. * previous (last change) value
  46383. */
  46384. previous: T;
  46385. }
  46386. /**
  46387. * Represents changes in the component between current frame and last values recorded
  46388. */
  46389. export interface IWebXRMotionControllerComponentChanges {
  46390. /**
  46391. * will be populated with previous and current values if axes changed
  46392. */
  46393. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46394. /**
  46395. * will be populated with previous and current values if pressed changed
  46396. */
  46397. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46398. /**
  46399. * will be populated with previous and current values if touched changed
  46400. */
  46401. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46402. /**
  46403. * will be populated with previous and current values if value changed
  46404. */
  46405. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46406. }
  46407. /**
  46408. * This class represents a single component (for example button or thumbstick) of a motion controller
  46409. */
  46410. export class WebXRControllerComponent implements IDisposable {
  46411. /**
  46412. * the id of this component
  46413. */
  46414. id: string;
  46415. /**
  46416. * the type of the component
  46417. */
  46418. type: MotionControllerComponentType;
  46419. private _buttonIndex;
  46420. private _axesIndices;
  46421. private _axes;
  46422. private _changes;
  46423. private _currentValue;
  46424. private _hasChanges;
  46425. private _pressed;
  46426. private _touched;
  46427. /**
  46428. * button component type
  46429. */
  46430. static BUTTON_TYPE: MotionControllerComponentType;
  46431. /**
  46432. * squeeze component type
  46433. */
  46434. static SQUEEZE_TYPE: MotionControllerComponentType;
  46435. /**
  46436. * Thumbstick component type
  46437. */
  46438. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46439. /**
  46440. * Touchpad component type
  46441. */
  46442. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46443. /**
  46444. * trigger component type
  46445. */
  46446. static TRIGGER_TYPE: MotionControllerComponentType;
  46447. /**
  46448. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46449. * the axes data changes
  46450. */
  46451. onAxisValueChangedObservable: Observable<{
  46452. x: number;
  46453. y: number;
  46454. }>;
  46455. /**
  46456. * Observers registered here will be triggered when the state of a button changes
  46457. * State change is either pressed / touched / value
  46458. */
  46459. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46460. /**
  46461. * Creates a new component for a motion controller.
  46462. * It is created by the motion controller itself
  46463. *
  46464. * @param id the id of this component
  46465. * @param type the type of the component
  46466. * @param _buttonIndex index in the buttons array of the gamepad
  46467. * @param _axesIndices indices of the values in the axes array of the gamepad
  46468. */
  46469. constructor(
  46470. /**
  46471. * the id of this component
  46472. */
  46473. id: string,
  46474. /**
  46475. * the type of the component
  46476. */
  46477. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46478. /**
  46479. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46480. */
  46481. get axes(): IWebXRMotionControllerAxesValue;
  46482. /**
  46483. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46484. */
  46485. get changes(): IWebXRMotionControllerComponentChanges;
  46486. /**
  46487. * Return whether or not the component changed the last frame
  46488. */
  46489. get hasChanges(): boolean;
  46490. /**
  46491. * is the button currently pressed
  46492. */
  46493. get pressed(): boolean;
  46494. /**
  46495. * is the button currently touched
  46496. */
  46497. get touched(): boolean;
  46498. /**
  46499. * Get the current value of this component
  46500. */
  46501. get value(): number;
  46502. /**
  46503. * Dispose this component
  46504. */
  46505. dispose(): void;
  46506. /**
  46507. * Are there axes correlating to this component
  46508. * @return true is axes data is available
  46509. */
  46510. isAxes(): boolean;
  46511. /**
  46512. * Is this component a button (hence - pressable)
  46513. * @returns true if can be pressed
  46514. */
  46515. isButton(): boolean;
  46516. /**
  46517. * update this component using the gamepad object it is in. Called on every frame
  46518. * @param nativeController the native gamepad controller object
  46519. */
  46520. update(nativeController: IMinimalMotionControllerObject): void;
  46521. }
  46522. }
  46523. declare module BABYLON {
  46524. /**
  46525. * Interface used to represent data loading progression
  46526. */
  46527. export interface ISceneLoaderProgressEvent {
  46528. /**
  46529. * Defines if data length to load can be evaluated
  46530. */
  46531. readonly lengthComputable: boolean;
  46532. /**
  46533. * Defines the loaded data length
  46534. */
  46535. readonly loaded: number;
  46536. /**
  46537. * Defines the data length to load
  46538. */
  46539. readonly total: number;
  46540. }
  46541. /**
  46542. * Interface used by SceneLoader plugins to define supported file extensions
  46543. */
  46544. export interface ISceneLoaderPluginExtensions {
  46545. /**
  46546. * Defines the list of supported extensions
  46547. */
  46548. [extension: string]: {
  46549. isBinary: boolean;
  46550. };
  46551. }
  46552. /**
  46553. * Interface used by SceneLoader plugin factory
  46554. */
  46555. export interface ISceneLoaderPluginFactory {
  46556. /**
  46557. * Defines the name of the factory
  46558. */
  46559. name: string;
  46560. /**
  46561. * Function called to create a new plugin
  46562. * @return the new plugin
  46563. */
  46564. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46565. /**
  46566. * The callback that returns true if the data can be directly loaded.
  46567. * @param data string containing the file data
  46568. * @returns if the data can be loaded directly
  46569. */
  46570. canDirectLoad?(data: string): boolean;
  46571. }
  46572. /**
  46573. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46574. */
  46575. export interface ISceneLoaderPluginBase {
  46576. /**
  46577. * The friendly name of this plugin.
  46578. */
  46579. name: string;
  46580. /**
  46581. * The file extensions supported by this plugin.
  46582. */
  46583. extensions: string | ISceneLoaderPluginExtensions;
  46584. /**
  46585. * The callback called when loading from a url.
  46586. * @param scene scene loading this url
  46587. * @param url url to load
  46588. * @param onSuccess callback called when the file successfully loads
  46589. * @param onProgress callback called while file is loading (if the server supports this mode)
  46590. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46591. * @param onError callback called when the file fails to load
  46592. * @returns a file request object
  46593. */
  46594. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46595. /**
  46596. * The callback called when loading from a file object.
  46597. * @param scene scene loading this file
  46598. * @param file defines the file to load
  46599. * @param onSuccess defines the callback to call when data is loaded
  46600. * @param onProgress defines the callback to call during loading process
  46601. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46602. * @param onError defines the callback to call when an error occurs
  46603. * @returns a file request object
  46604. */
  46605. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46606. /**
  46607. * The callback that returns true if the data can be directly loaded.
  46608. * @param data string containing the file data
  46609. * @returns if the data can be loaded directly
  46610. */
  46611. canDirectLoad?(data: string): boolean;
  46612. /**
  46613. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46614. * @param scene scene loading this data
  46615. * @param data string containing the data
  46616. * @returns data to pass to the plugin
  46617. */
  46618. directLoad?(scene: Scene, data: string): any;
  46619. /**
  46620. * The callback that allows custom handling of the root url based on the response url.
  46621. * @param rootUrl the original root url
  46622. * @param responseURL the response url if available
  46623. * @returns the new root url
  46624. */
  46625. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46626. }
  46627. /**
  46628. * Interface used to define a SceneLoader plugin
  46629. */
  46630. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46631. /**
  46632. * Import meshes into a scene.
  46633. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46634. * @param scene The scene to import into
  46635. * @param data The data to import
  46636. * @param rootUrl The root url for scene and resources
  46637. * @param meshes The meshes array to import into
  46638. * @param particleSystems The particle systems array to import into
  46639. * @param skeletons The skeletons array to import into
  46640. * @param onError The callback when import fails
  46641. * @returns True if successful or false otherwise
  46642. */
  46643. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46644. /**
  46645. * Load into a scene.
  46646. * @param scene The scene to load into
  46647. * @param data The data to import
  46648. * @param rootUrl The root url for scene and resources
  46649. * @param onError The callback when import fails
  46650. * @returns True if successful or false otherwise
  46651. */
  46652. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46653. /**
  46654. * Load into an asset container.
  46655. * @param scene The scene to load into
  46656. * @param data The data to import
  46657. * @param rootUrl The root url for scene and resources
  46658. * @param onError The callback when import fails
  46659. * @returns The loaded asset container
  46660. */
  46661. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46662. }
  46663. /**
  46664. * Interface used to define an async SceneLoader plugin
  46665. */
  46666. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46667. /**
  46668. * Import meshes into a scene.
  46669. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46670. * @param scene The scene to import into
  46671. * @param data The data to import
  46672. * @param rootUrl The root url for scene and resources
  46673. * @param onProgress The callback when the load progresses
  46674. * @param fileName Defines the name of the file to load
  46675. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46676. */
  46677. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46678. meshes: AbstractMesh[];
  46679. particleSystems: IParticleSystem[];
  46680. skeletons: Skeleton[];
  46681. animationGroups: AnimationGroup[];
  46682. }>;
  46683. /**
  46684. * Load into a scene.
  46685. * @param scene The scene to load into
  46686. * @param data The data to import
  46687. * @param rootUrl The root url for scene and resources
  46688. * @param onProgress The callback when the load progresses
  46689. * @param fileName Defines the name of the file to load
  46690. * @returns Nothing
  46691. */
  46692. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46693. /**
  46694. * Load into an asset container.
  46695. * @param scene The scene to load into
  46696. * @param data The data to import
  46697. * @param rootUrl The root url for scene and resources
  46698. * @param onProgress The callback when the load progresses
  46699. * @param fileName Defines the name of the file to load
  46700. * @returns The loaded asset container
  46701. */
  46702. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46703. }
  46704. /**
  46705. * Mode that determines how to handle old animation groups before loading new ones.
  46706. */
  46707. export enum SceneLoaderAnimationGroupLoadingMode {
  46708. /**
  46709. * Reset all old animations to initial state then dispose them.
  46710. */
  46711. Clean = 0,
  46712. /**
  46713. * Stop all old animations.
  46714. */
  46715. Stop = 1,
  46716. /**
  46717. * Restart old animations from first frame.
  46718. */
  46719. Sync = 2,
  46720. /**
  46721. * Old animations remains untouched.
  46722. */
  46723. NoSync = 3
  46724. }
  46725. /**
  46726. * Class used to load scene from various file formats using registered plugins
  46727. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46728. */
  46729. export class SceneLoader {
  46730. /**
  46731. * No logging while loading
  46732. */
  46733. static readonly NO_LOGGING: number;
  46734. /**
  46735. * Minimal logging while loading
  46736. */
  46737. static readonly MINIMAL_LOGGING: number;
  46738. /**
  46739. * Summary logging while loading
  46740. */
  46741. static readonly SUMMARY_LOGGING: number;
  46742. /**
  46743. * Detailled logging while loading
  46744. */
  46745. static readonly DETAILED_LOGGING: number;
  46746. /**
  46747. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46748. */
  46749. static get ForceFullSceneLoadingForIncremental(): boolean;
  46750. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46751. /**
  46752. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46753. */
  46754. static get ShowLoadingScreen(): boolean;
  46755. static set ShowLoadingScreen(value: boolean);
  46756. /**
  46757. * Defines the current logging level (while loading the scene)
  46758. * @ignorenaming
  46759. */
  46760. static get loggingLevel(): number;
  46761. static set loggingLevel(value: number);
  46762. /**
  46763. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46764. */
  46765. static get CleanBoneMatrixWeights(): boolean;
  46766. static set CleanBoneMatrixWeights(value: boolean);
  46767. /**
  46768. * Event raised when a plugin is used to load a scene
  46769. */
  46770. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46771. private static _registeredPlugins;
  46772. private static _getDefaultPlugin;
  46773. private static _getPluginForExtension;
  46774. private static _getPluginForDirectLoad;
  46775. private static _getPluginForFilename;
  46776. private static _getDirectLoad;
  46777. private static _loadData;
  46778. private static _getFileInfo;
  46779. /**
  46780. * Gets a plugin that can load the given extension
  46781. * @param extension defines the extension to load
  46782. * @returns a plugin or null if none works
  46783. */
  46784. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46785. /**
  46786. * Gets a boolean indicating that the given extension can be loaded
  46787. * @param extension defines the extension to load
  46788. * @returns true if the extension is supported
  46789. */
  46790. static IsPluginForExtensionAvailable(extension: string): boolean;
  46791. /**
  46792. * Adds a new plugin to the list of registered plugins
  46793. * @param plugin defines the plugin to add
  46794. */
  46795. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46796. /**
  46797. * Import meshes into a scene
  46798. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46799. * @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)
  46800. * @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)
  46801. * @param scene the instance of BABYLON.Scene to append to
  46802. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46803. * @param onProgress a callback with a progress event for each file being loaded
  46804. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46805. * @param pluginExtension the extension used to determine the plugin
  46806. * @returns The loaded plugin
  46807. */
  46808. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46809. /**
  46810. * Import meshes into a scene
  46811. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46812. * @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)
  46813. * @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)
  46814. * @param scene the instance of BABYLON.Scene to append to
  46815. * @param onProgress a callback with a progress event for each file being loaded
  46816. * @param pluginExtension the extension used to determine the plugin
  46817. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46818. */
  46819. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46820. meshes: AbstractMesh[];
  46821. particleSystems: IParticleSystem[];
  46822. skeletons: Skeleton[];
  46823. animationGroups: AnimationGroup[];
  46824. }>;
  46825. /**
  46826. * Load a scene
  46827. * @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)
  46828. * @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)
  46829. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46830. * @param onSuccess a callback with the scene when import succeeds
  46831. * @param onProgress a callback with a progress event for each file being loaded
  46832. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46833. * @param pluginExtension the extension used to determine the plugin
  46834. * @returns The loaded plugin
  46835. */
  46836. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46837. /**
  46838. * Load a scene
  46839. * @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)
  46840. * @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)
  46841. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46842. * @param onProgress a callback with a progress event for each file being loaded
  46843. * @param pluginExtension the extension used to determine the plugin
  46844. * @returns The loaded scene
  46845. */
  46846. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46847. /**
  46848. * Append a scene
  46849. * @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)
  46850. * @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)
  46851. * @param scene is the instance of BABYLON.Scene to append to
  46852. * @param onSuccess a callback with the scene when import succeeds
  46853. * @param onProgress a callback with a progress event for each file being loaded
  46854. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46855. * @param pluginExtension the extension used to determine the plugin
  46856. * @returns The loaded plugin
  46857. */
  46858. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46859. /**
  46860. * Append a scene
  46861. * @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)
  46862. * @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)
  46863. * @param scene is the instance of BABYLON.Scene to append to
  46864. * @param onProgress a callback with a progress event for each file being loaded
  46865. * @param pluginExtension the extension used to determine the plugin
  46866. * @returns The given scene
  46867. */
  46868. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46869. /**
  46870. * Load a scene into an asset container
  46871. * @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)
  46872. * @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)
  46873. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46874. * @param onSuccess a callback with the scene when import succeeds
  46875. * @param onProgress a callback with a progress event for each file being loaded
  46876. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46877. * @param pluginExtension the extension used to determine the plugin
  46878. * @returns The loaded plugin
  46879. */
  46880. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46881. /**
  46882. * Load a scene into an asset container
  46883. * @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)
  46884. * @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)
  46885. * @param scene is the instance of Scene to append to
  46886. * @param onProgress a callback with a progress event for each file being loaded
  46887. * @param pluginExtension the extension used to determine the plugin
  46888. * @returns The loaded asset container
  46889. */
  46890. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46891. /**
  46892. * Import animations from a file into a scene
  46893. * @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)
  46894. * @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)
  46895. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46896. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46897. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46898. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46899. * @param onSuccess a callback with the scene when import succeeds
  46900. * @param onProgress a callback with a progress event for each file being loaded
  46901. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46902. */
  46903. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  46904. /**
  46905. * Import animations from a file into a scene
  46906. * @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)
  46907. * @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)
  46908. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46909. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46910. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46911. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46912. * @param onSuccess a callback with the scene when import succeeds
  46913. * @param onProgress a callback with a progress event for each file being loaded
  46914. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46915. * @returns the updated scene with imported animations
  46916. */
  46917. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  46918. }
  46919. }
  46920. declare module BABYLON {
  46921. /**
  46922. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46923. */
  46924. export type MotionControllerHandedness = "none" | "left" | "right";
  46925. /**
  46926. * The type of components available in motion controllers.
  46927. * This is not the name of the component.
  46928. */
  46929. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46930. /**
  46931. * The state of a controller component
  46932. */
  46933. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46934. /**
  46935. * The schema of motion controller layout.
  46936. * No object will be initialized using this interface
  46937. * This is used just to define the profile.
  46938. */
  46939. export interface IMotionControllerLayout {
  46940. /**
  46941. * Path to load the assets. Usually relative to the base path
  46942. */
  46943. assetPath: string;
  46944. /**
  46945. * Available components (unsorted)
  46946. */
  46947. components: {
  46948. /**
  46949. * A map of component Ids
  46950. */
  46951. [componentId: string]: {
  46952. /**
  46953. * The type of input the component outputs
  46954. */
  46955. type: MotionControllerComponentType;
  46956. /**
  46957. * The indices of this component in the gamepad object
  46958. */
  46959. gamepadIndices: {
  46960. /**
  46961. * Index of button
  46962. */
  46963. button?: number;
  46964. /**
  46965. * If available, index of x-axis
  46966. */
  46967. xAxis?: number;
  46968. /**
  46969. * If available, index of y-axis
  46970. */
  46971. yAxis?: number;
  46972. };
  46973. /**
  46974. * The mesh's root node name
  46975. */
  46976. rootNodeName: string;
  46977. /**
  46978. * Animation definitions for this model
  46979. */
  46980. visualResponses: {
  46981. [stateKey: string]: {
  46982. /**
  46983. * What property will be animated
  46984. */
  46985. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46986. /**
  46987. * What states influence this visual response
  46988. */
  46989. states: MotionControllerComponentStateType[];
  46990. /**
  46991. * Type of animation - movement or visibility
  46992. */
  46993. valueNodeProperty: "transform" | "visibility";
  46994. /**
  46995. * Base node name to move. Its position will be calculated according to the min and max nodes
  46996. */
  46997. valueNodeName?: string;
  46998. /**
  46999. * Minimum movement node
  47000. */
  47001. minNodeName?: string;
  47002. /**
  47003. * Max movement node
  47004. */
  47005. maxNodeName?: string;
  47006. };
  47007. };
  47008. /**
  47009. * If touch enabled, what is the name of node to display user feedback
  47010. */
  47011. touchPointNodeName?: string;
  47012. };
  47013. };
  47014. /**
  47015. * Is it xr standard mapping or not
  47016. */
  47017. gamepadMapping: "" | "xr-standard";
  47018. /**
  47019. * Base root node of this entire model
  47020. */
  47021. rootNodeName: string;
  47022. /**
  47023. * Defines the main button component id
  47024. */
  47025. selectComponentId: string;
  47026. }
  47027. /**
  47028. * A definition for the layout map in the input profile
  47029. */
  47030. export interface IMotionControllerLayoutMap {
  47031. /**
  47032. * Layouts with handedness type as a key
  47033. */
  47034. [handedness: string]: IMotionControllerLayout;
  47035. }
  47036. /**
  47037. * The XR Input profile schema
  47038. * Profiles can be found here:
  47039. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47040. */
  47041. export interface IMotionControllerProfile {
  47042. /**
  47043. * fallback profiles for this profileId
  47044. */
  47045. fallbackProfileIds: string[];
  47046. /**
  47047. * The layout map, with handedness as key
  47048. */
  47049. layouts: IMotionControllerLayoutMap;
  47050. /**
  47051. * The id of this profile
  47052. * correlates to the profile(s) in the xrInput.profiles array
  47053. */
  47054. profileId: string;
  47055. }
  47056. /**
  47057. * A helper-interface for the 3 meshes needed for controller button animation
  47058. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47059. */
  47060. export interface IMotionControllerButtonMeshMap {
  47061. /**
  47062. * the mesh that defines the pressed value mesh position.
  47063. * This is used to find the max-position of this button
  47064. */
  47065. pressedMesh: AbstractMesh;
  47066. /**
  47067. * the mesh that defines the unpressed value mesh position.
  47068. * This is used to find the min (or initial) position of this button
  47069. */
  47070. unpressedMesh: AbstractMesh;
  47071. /**
  47072. * The mesh that will be changed when value changes
  47073. */
  47074. valueMesh: AbstractMesh;
  47075. }
  47076. /**
  47077. * A helper-interface for the 3 meshes needed for controller axis animation.
  47078. * This will be expanded when touchpad animations are fully supported
  47079. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47080. */
  47081. export interface IMotionControllerMeshMap {
  47082. /**
  47083. * the mesh that defines the maximum value mesh position.
  47084. */
  47085. maxMesh?: AbstractMesh;
  47086. /**
  47087. * the mesh that defines the minimum value mesh position.
  47088. */
  47089. minMesh?: AbstractMesh;
  47090. /**
  47091. * The mesh that will be changed when axis value changes
  47092. */
  47093. valueMesh: AbstractMesh;
  47094. }
  47095. /**
  47096. * The elements needed for change-detection of the gamepad objects in motion controllers
  47097. */
  47098. export interface IMinimalMotionControllerObject {
  47099. /**
  47100. * Available axes of this controller
  47101. */
  47102. axes: number[];
  47103. /**
  47104. * An array of available buttons
  47105. */
  47106. buttons: Array<{
  47107. /**
  47108. * Value of the button/trigger
  47109. */
  47110. value: number;
  47111. /**
  47112. * If the button/trigger is currently touched
  47113. */
  47114. touched: boolean;
  47115. /**
  47116. * If the button/trigger is currently pressed
  47117. */
  47118. pressed: boolean;
  47119. }>;
  47120. /**
  47121. * EXPERIMENTAL haptic support.
  47122. */
  47123. hapticActuators?: Array<{
  47124. pulse: (value: number, duration: number) => Promise<boolean>;
  47125. }>;
  47126. }
  47127. /**
  47128. * An Abstract Motion controller
  47129. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47130. * Each component has an observable to check for changes in value and state
  47131. */
  47132. export abstract class WebXRAbstractMotionController implements IDisposable {
  47133. protected scene: Scene;
  47134. protected layout: IMotionControllerLayout;
  47135. /**
  47136. * The gamepad object correlating to this controller
  47137. */
  47138. gamepadObject: IMinimalMotionControllerObject;
  47139. /**
  47140. * handedness (left/right/none) of this controller
  47141. */
  47142. handedness: MotionControllerHandedness;
  47143. private _initComponent;
  47144. private _modelReady;
  47145. /**
  47146. * A map of components (WebXRControllerComponent) in this motion controller
  47147. * Components have a ComponentType and can also have both button and axis definitions
  47148. */
  47149. readonly components: {
  47150. [id: string]: WebXRControllerComponent;
  47151. };
  47152. /**
  47153. * Disable the model's animation. Can be set at any time.
  47154. */
  47155. disableAnimation: boolean;
  47156. /**
  47157. * Observers registered here will be triggered when the model of this controller is done loading
  47158. */
  47159. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47160. /**
  47161. * The profile id of this motion controller
  47162. */
  47163. abstract profileId: string;
  47164. /**
  47165. * The root mesh of the model. It is null if the model was not yet initialized
  47166. */
  47167. rootMesh: Nullable<AbstractMesh>;
  47168. /**
  47169. * constructs a new abstract motion controller
  47170. * @param scene the scene to which the model of the controller will be added
  47171. * @param layout The profile layout to load
  47172. * @param gamepadObject The gamepad object correlating to this controller
  47173. * @param handedness handedness (left/right/none) of this controller
  47174. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47175. */
  47176. constructor(scene: Scene, layout: IMotionControllerLayout,
  47177. /**
  47178. * The gamepad object correlating to this controller
  47179. */
  47180. gamepadObject: IMinimalMotionControllerObject,
  47181. /**
  47182. * handedness (left/right/none) of this controller
  47183. */
  47184. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47185. /**
  47186. * Dispose this controller, the model mesh and all its components
  47187. */
  47188. dispose(): void;
  47189. /**
  47190. * Returns all components of specific type
  47191. * @param type the type to search for
  47192. * @return an array of components with this type
  47193. */
  47194. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47195. /**
  47196. * get a component based an its component id as defined in layout.components
  47197. * @param id the id of the component
  47198. * @returns the component correlates to the id or undefined if not found
  47199. */
  47200. getComponent(id: string): WebXRControllerComponent;
  47201. /**
  47202. * Get the list of components available in this motion controller
  47203. * @returns an array of strings correlating to available components
  47204. */
  47205. getComponentIds(): string[];
  47206. /**
  47207. * Get the first component of specific type
  47208. * @param type type of component to find
  47209. * @return a controller component or null if not found
  47210. */
  47211. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47212. /**
  47213. * Get the main (Select) component of this controller as defined in the layout
  47214. * @returns the main component of this controller
  47215. */
  47216. getMainComponent(): WebXRControllerComponent;
  47217. /**
  47218. * Loads the model correlating to this controller
  47219. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47220. * @returns A promise fulfilled with the result of the model loading
  47221. */
  47222. loadModel(): Promise<boolean>;
  47223. /**
  47224. * Update this model using the current XRFrame
  47225. * @param xrFrame the current xr frame to use and update the model
  47226. */
  47227. updateFromXRFrame(xrFrame: XRFrame): void;
  47228. /**
  47229. * Backwards compatibility due to a deeply-integrated typo
  47230. */
  47231. get handness(): XREye;
  47232. /**
  47233. * Pulse (vibrate) this controller
  47234. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47235. * Consecutive calls to this function will cancel the last pulse call
  47236. *
  47237. * @param value the strength of the pulse in 0.0...1.0 range
  47238. * @param duration Duration of the pulse in milliseconds
  47239. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47240. * @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
  47241. */
  47242. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47243. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47244. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47245. /**
  47246. * Moves the axis on the controller mesh based on its current state
  47247. * @param axis the index of the axis
  47248. * @param axisValue the value of the axis which determines the meshes new position
  47249. * @hidden
  47250. */
  47251. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47252. /**
  47253. * Update the model itself with the current frame data
  47254. * @param xrFrame the frame to use for updating the model mesh
  47255. */
  47256. protected updateModel(xrFrame: XRFrame): void;
  47257. /**
  47258. * Get the filename and path for this controller's model
  47259. * @returns a map of filename and path
  47260. */
  47261. protected abstract _getFilenameAndPath(): {
  47262. filename: string;
  47263. path: string;
  47264. };
  47265. /**
  47266. * This function is called before the mesh is loaded. It checks for loading constraints.
  47267. * For example, this function can check if the GLB loader is available
  47268. * If this function returns false, the generic controller will be loaded instead
  47269. * @returns Is the client ready to load the mesh
  47270. */
  47271. protected abstract _getModelLoadingConstraints(): boolean;
  47272. /**
  47273. * This function will be called after the model was successfully loaded and can be used
  47274. * for mesh transformations before it is available for the user
  47275. * @param meshes the loaded meshes
  47276. */
  47277. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47278. /**
  47279. * Set the root mesh for this controller. Important for the WebXR controller class
  47280. * @param meshes the loaded meshes
  47281. */
  47282. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47283. /**
  47284. * A function executed each frame that updates the mesh (if needed)
  47285. * @param xrFrame the current xrFrame
  47286. */
  47287. protected abstract _updateModel(xrFrame: XRFrame): void;
  47288. private _getGenericFilenameAndPath;
  47289. private _getGenericParentMesh;
  47290. }
  47291. }
  47292. declare module BABYLON {
  47293. /**
  47294. * A generic trigger-only motion controller for WebXR
  47295. */
  47296. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47297. /**
  47298. * Static version of the profile id of this controller
  47299. */
  47300. static ProfileId: string;
  47301. profileId: string;
  47302. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47303. protected _getFilenameAndPath(): {
  47304. filename: string;
  47305. path: string;
  47306. };
  47307. protected _getModelLoadingConstraints(): boolean;
  47308. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47309. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47310. protected _updateModel(): void;
  47311. }
  47312. }
  47313. declare module BABYLON {
  47314. /**
  47315. * Class containing static functions to help procedurally build meshes
  47316. */
  47317. export class SphereBuilder {
  47318. /**
  47319. * Creates a sphere mesh
  47320. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47321. * * 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`)
  47322. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47323. * * 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
  47324. * * 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)
  47325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47326. * * 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
  47327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47328. * @param name defines the name of the mesh
  47329. * @param options defines the options used to create the mesh
  47330. * @param scene defines the hosting scene
  47331. * @returns the sphere mesh
  47332. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47333. */
  47334. static CreateSphere(name: string, options: {
  47335. segments?: number;
  47336. diameter?: number;
  47337. diameterX?: number;
  47338. diameterY?: number;
  47339. diameterZ?: number;
  47340. arc?: number;
  47341. slice?: number;
  47342. sideOrientation?: number;
  47343. frontUVs?: Vector4;
  47344. backUVs?: Vector4;
  47345. updatable?: boolean;
  47346. }, scene?: Nullable<Scene>): Mesh;
  47347. }
  47348. }
  47349. declare module BABYLON {
  47350. /**
  47351. * A profiled motion controller has its profile loaded from an online repository.
  47352. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47353. */
  47354. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47355. private _repositoryUrl;
  47356. private _buttonMeshMapping;
  47357. private _touchDots;
  47358. /**
  47359. * The profile ID of this controller. Will be populated when the controller initializes.
  47360. */
  47361. profileId: string;
  47362. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47363. dispose(): void;
  47364. protected _getFilenameAndPath(): {
  47365. filename: string;
  47366. path: string;
  47367. };
  47368. protected _getModelLoadingConstraints(): boolean;
  47369. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47370. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47371. protected _updateModel(_xrFrame: XRFrame): void;
  47372. }
  47373. }
  47374. declare module BABYLON {
  47375. /**
  47376. * A construction function type to create a new controller based on an xrInput object
  47377. */
  47378. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47379. /**
  47380. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47381. *
  47382. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47383. * it should be replaced with auto-loaded controllers.
  47384. *
  47385. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47386. */
  47387. export class WebXRMotionControllerManager {
  47388. private static _AvailableControllers;
  47389. private static _Fallbacks;
  47390. private static _ProfileLoadingPromises;
  47391. private static _ProfilesList;
  47392. /**
  47393. * The base URL of the online controller repository. Can be changed at any time.
  47394. */
  47395. static BaseRepositoryUrl: string;
  47396. /**
  47397. * Which repository gets priority - local or online
  47398. */
  47399. static PrioritizeOnlineRepository: boolean;
  47400. /**
  47401. * Use the online repository, or use only locally-defined controllers
  47402. */
  47403. static UseOnlineRepository: boolean;
  47404. /**
  47405. * Clear the cache used for profile loading and reload when requested again
  47406. */
  47407. static ClearProfilesCache(): void;
  47408. /**
  47409. * Register the default fallbacks.
  47410. * This function is called automatically when this file is imported.
  47411. */
  47412. static DefaultFallbacks(): void;
  47413. /**
  47414. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47415. * @param profileId the profile to which a fallback needs to be found
  47416. * @return an array with corresponding fallback profiles
  47417. */
  47418. static FindFallbackWithProfileId(profileId: string): string[];
  47419. /**
  47420. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47421. * The order of search:
  47422. *
  47423. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47424. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47425. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47426. * 4) return the generic trigger controller if none were found
  47427. *
  47428. * @param xrInput the xrInput to which a new controller is initialized
  47429. * @param scene the scene to which the model will be added
  47430. * @param forceProfile force a certain profile for this controller
  47431. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47432. */
  47433. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47434. /**
  47435. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47436. *
  47437. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47438. *
  47439. * @param type the profile type to register
  47440. * @param constructFunction the function to be called when loading this profile
  47441. */
  47442. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47443. /**
  47444. * Register a fallback to a specific profile.
  47445. * @param profileId the profileId that will receive the fallbacks
  47446. * @param fallbacks A list of fallback profiles
  47447. */
  47448. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47449. /**
  47450. * Will update the list of profiles available in the repository
  47451. * @return a promise that resolves to a map of profiles available online
  47452. */
  47453. static UpdateProfilesList(): Promise<{
  47454. [profile: string]: string;
  47455. }>;
  47456. private static _LoadProfileFromRepository;
  47457. private static _LoadProfilesFromAvailableControllers;
  47458. }
  47459. }
  47460. declare module BABYLON {
  47461. /**
  47462. * Configuration options for the WebXR controller creation
  47463. */
  47464. export interface IWebXRControllerOptions {
  47465. /**
  47466. * Should the controller mesh be animated when a user interacts with it
  47467. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47468. */
  47469. disableMotionControllerAnimation?: boolean;
  47470. /**
  47471. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47472. */
  47473. doNotLoadControllerMesh?: boolean;
  47474. /**
  47475. * Force a specific controller type for this controller.
  47476. * This can be used when creating your own profile or when testing different controllers
  47477. */
  47478. forceControllerProfile?: string;
  47479. /**
  47480. * Defines a rendering group ID for meshes that will be loaded.
  47481. * This is for the default controllers only.
  47482. */
  47483. renderingGroupId?: number;
  47484. }
  47485. /**
  47486. * Represents an XR controller
  47487. */
  47488. export class WebXRInputSource {
  47489. private _scene;
  47490. /** The underlying input source for the controller */
  47491. inputSource: XRInputSource;
  47492. private _options;
  47493. private _tmpVector;
  47494. private _uniqueId;
  47495. /**
  47496. * 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
  47497. */
  47498. grip?: AbstractMesh;
  47499. /**
  47500. * If available, this is the gamepad object related to this controller.
  47501. * Using this object it is possible to get click events and trackpad changes of the
  47502. * webxr controller that is currently being used.
  47503. */
  47504. motionController?: WebXRAbstractMotionController;
  47505. /**
  47506. * Event that fires when the controller is removed/disposed.
  47507. * The object provided as event data is this controller, after associated assets were disposed.
  47508. * uniqueId is still available.
  47509. */
  47510. onDisposeObservable: Observable<WebXRInputSource>;
  47511. /**
  47512. * Will be triggered when the mesh associated with the motion controller is done loading.
  47513. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47514. * A shortened version of controller -> motion controller -> on mesh loaded.
  47515. */
  47516. onMeshLoadedObservable: Observable<AbstractMesh>;
  47517. /**
  47518. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47519. */
  47520. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47521. /**
  47522. * Pointer which can be used to select objects or attach a visible laser to
  47523. */
  47524. pointer: AbstractMesh;
  47525. /**
  47526. * Creates the controller
  47527. * @see https://doc.babylonjs.com/how_to/webxr
  47528. * @param _scene the scene which the controller should be associated to
  47529. * @param inputSource the underlying input source for the controller
  47530. * @param _options options for this controller creation
  47531. */
  47532. constructor(_scene: Scene,
  47533. /** The underlying input source for the controller */
  47534. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47535. /**
  47536. * Get this controllers unique id
  47537. */
  47538. get uniqueId(): string;
  47539. /**
  47540. * Disposes of the object
  47541. */
  47542. dispose(): void;
  47543. /**
  47544. * Gets a world space ray coming from the pointer or grip
  47545. * @param result the resulting ray
  47546. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47547. */
  47548. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47549. /**
  47550. * Updates the controller pose based on the given XRFrame
  47551. * @param xrFrame xr frame to update the pose with
  47552. * @param referenceSpace reference space to use
  47553. */
  47554. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47555. }
  47556. }
  47557. declare module BABYLON {
  47558. /**
  47559. * The schema for initialization options of the XR Input class
  47560. */
  47561. export interface IWebXRInputOptions {
  47562. /**
  47563. * If set to true no model will be automatically loaded
  47564. */
  47565. doNotLoadControllerMeshes?: boolean;
  47566. /**
  47567. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47568. * If not found, the xr input profile data will be used.
  47569. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47570. */
  47571. forceInputProfile?: string;
  47572. /**
  47573. * Do not send a request to the controller repository to load the profile.
  47574. *
  47575. * Instead, use the controllers available in babylon itself.
  47576. */
  47577. disableOnlineControllerRepository?: boolean;
  47578. /**
  47579. * A custom URL for the controllers repository
  47580. */
  47581. customControllersRepositoryURL?: string;
  47582. /**
  47583. * Should the controller model's components not move according to the user input
  47584. */
  47585. disableControllerAnimation?: boolean;
  47586. /**
  47587. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47588. */
  47589. controllerOptions?: IWebXRControllerOptions;
  47590. }
  47591. /**
  47592. * XR input used to track XR inputs such as controllers/rays
  47593. */
  47594. export class WebXRInput implements IDisposable {
  47595. /**
  47596. * the xr session manager for this session
  47597. */
  47598. xrSessionManager: WebXRSessionManager;
  47599. /**
  47600. * the WebXR camera for this session. Mainly used for teleportation
  47601. */
  47602. xrCamera: WebXRCamera;
  47603. private readonly options;
  47604. /**
  47605. * XR controllers being tracked
  47606. */
  47607. controllers: Array<WebXRInputSource>;
  47608. private _frameObserver;
  47609. private _sessionEndedObserver;
  47610. private _sessionInitObserver;
  47611. /**
  47612. * Event when a controller has been connected/added
  47613. */
  47614. onControllerAddedObservable: Observable<WebXRInputSource>;
  47615. /**
  47616. * Event when a controller has been removed/disconnected
  47617. */
  47618. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47619. /**
  47620. * Initializes the WebXRInput
  47621. * @param xrSessionManager the xr session manager for this session
  47622. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47623. * @param options = initialization options for this xr input
  47624. */
  47625. constructor(
  47626. /**
  47627. * the xr session manager for this session
  47628. */
  47629. xrSessionManager: WebXRSessionManager,
  47630. /**
  47631. * the WebXR camera for this session. Mainly used for teleportation
  47632. */
  47633. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47634. private _onInputSourcesChange;
  47635. private _addAndRemoveControllers;
  47636. /**
  47637. * Disposes of the object
  47638. */
  47639. dispose(): void;
  47640. }
  47641. }
  47642. declare module BABYLON {
  47643. /**
  47644. * This is the base class for all WebXR features.
  47645. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47646. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47647. */
  47648. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47649. protected _xrSessionManager: WebXRSessionManager;
  47650. private _attached;
  47651. private _removeOnDetach;
  47652. /**
  47653. * Should auto-attach be disabled?
  47654. */
  47655. disableAutoAttach: boolean;
  47656. /**
  47657. * Construct a new (abstract) WebXR feature
  47658. * @param _xrSessionManager the xr session manager for this feature
  47659. */
  47660. constructor(_xrSessionManager: WebXRSessionManager);
  47661. /**
  47662. * Is this feature attached
  47663. */
  47664. get attached(): boolean;
  47665. /**
  47666. * attach this feature
  47667. *
  47668. * @param force should attachment be forced (even when already attached)
  47669. * @returns true if successful, false is failed or already attached
  47670. */
  47671. attach(force?: boolean): boolean;
  47672. /**
  47673. * detach this feature.
  47674. *
  47675. * @returns true if successful, false if failed or already detached
  47676. */
  47677. detach(): boolean;
  47678. /**
  47679. * Dispose this feature and all of the resources attached
  47680. */
  47681. dispose(): void;
  47682. /**
  47683. * This is used to register callbacks that will automatically be removed when detach is called.
  47684. * @param observable the observable to which the observer will be attached
  47685. * @param callback the callback to register
  47686. */
  47687. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47688. /**
  47689. * Code in this function will be executed on each xrFrame received from the browser.
  47690. * This function will not execute after the feature is detached.
  47691. * @param _xrFrame the current frame
  47692. */
  47693. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47694. }
  47695. }
  47696. declare module BABYLON {
  47697. /**
  47698. * Renders a layer on top of an existing scene
  47699. */
  47700. export class UtilityLayerRenderer implements IDisposable {
  47701. /** the original scene that will be rendered on top of */
  47702. originalScene: Scene;
  47703. private _pointerCaptures;
  47704. private _lastPointerEvents;
  47705. private static _DefaultUtilityLayer;
  47706. private static _DefaultKeepDepthUtilityLayer;
  47707. private _sharedGizmoLight;
  47708. private _renderCamera;
  47709. /**
  47710. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47711. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47712. * @returns the camera that is used when rendering the utility layer
  47713. */
  47714. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47715. /**
  47716. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47717. * @param cam the camera that should be used when rendering the utility layer
  47718. */
  47719. setRenderCamera(cam: Nullable<Camera>): void;
  47720. /**
  47721. * @hidden
  47722. * Light which used by gizmos to get light shading
  47723. */
  47724. _getSharedGizmoLight(): HemisphericLight;
  47725. /**
  47726. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47727. */
  47728. pickUtilitySceneFirst: boolean;
  47729. /**
  47730. * 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)
  47731. */
  47732. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47733. /**
  47734. * 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)
  47735. */
  47736. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47737. /**
  47738. * The scene that is rendered on top of the original scene
  47739. */
  47740. utilityLayerScene: Scene;
  47741. /**
  47742. * If the utility layer should automatically be rendered on top of existing scene
  47743. */
  47744. shouldRender: boolean;
  47745. /**
  47746. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47747. */
  47748. onlyCheckPointerDownEvents: boolean;
  47749. /**
  47750. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47751. */
  47752. processAllEvents: boolean;
  47753. /**
  47754. * Observable raised when the pointer move from the utility layer scene to the main scene
  47755. */
  47756. onPointerOutObservable: Observable<number>;
  47757. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47758. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47759. private _afterRenderObserver;
  47760. private _sceneDisposeObserver;
  47761. private _originalPointerObserver;
  47762. /**
  47763. * Instantiates a UtilityLayerRenderer
  47764. * @param originalScene the original scene that will be rendered on top of
  47765. * @param handleEvents boolean indicating if the utility layer should handle events
  47766. */
  47767. constructor(
  47768. /** the original scene that will be rendered on top of */
  47769. originalScene: Scene, handleEvents?: boolean);
  47770. private _notifyObservers;
  47771. /**
  47772. * Renders the utility layers scene on top of the original scene
  47773. */
  47774. render(): void;
  47775. /**
  47776. * Disposes of the renderer
  47777. */
  47778. dispose(): void;
  47779. private _updateCamera;
  47780. }
  47781. }
  47782. declare module BABYLON {
  47783. /**
  47784. * Options interface for the pointer selection module
  47785. */
  47786. export interface IWebXRControllerPointerSelectionOptions {
  47787. /**
  47788. * if provided, this scene will be used to render meshes.
  47789. */
  47790. customUtilityLayerScene?: Scene;
  47791. /**
  47792. * 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)
  47793. * If not disabled, the last picked point will be used to execute a pointer up event
  47794. * If disabled, pointer up event will be triggered right after the pointer down event.
  47795. * Used in screen and gaze target ray mode only
  47796. */
  47797. disablePointerUpOnTouchOut: boolean;
  47798. /**
  47799. * For gaze mode (time to select instead of press)
  47800. */
  47801. forceGazeMode: boolean;
  47802. /**
  47803. * 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
  47804. * to start a new countdown to the pointer down event.
  47805. * Defaults to 1.
  47806. */
  47807. gazeModePointerMovedFactor?: number;
  47808. /**
  47809. * Different button type to use instead of the main component
  47810. */
  47811. overrideButtonId?: string;
  47812. /**
  47813. * use this rendering group id for the meshes (optional)
  47814. */
  47815. renderingGroupId?: number;
  47816. /**
  47817. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47818. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47819. * 3000 means 3 seconds between pointing at something and selecting it
  47820. */
  47821. timeToSelect?: number;
  47822. /**
  47823. * Should meshes created here be added to a utility layer or the main scene
  47824. */
  47825. useUtilityLayer?: boolean;
  47826. /**
  47827. * the xr input to use with this pointer selection
  47828. */
  47829. xrInput: WebXRInput;
  47830. }
  47831. /**
  47832. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47833. */
  47834. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47835. private readonly _options;
  47836. private static _idCounter;
  47837. private _attachController;
  47838. private _controllers;
  47839. private _scene;
  47840. private _tmpVectorForPickCompare;
  47841. /**
  47842. * The module's name
  47843. */
  47844. static readonly Name: string;
  47845. /**
  47846. * The (Babylon) version of this module.
  47847. * This is an integer representing the implementation version.
  47848. * This number does not correspond to the WebXR specs version
  47849. */
  47850. static readonly Version: number;
  47851. /**
  47852. * Disable lighting on the laser pointer (so it will always be visible)
  47853. */
  47854. disablePointerLighting: boolean;
  47855. /**
  47856. * Disable lighting on the selection mesh (so it will always be visible)
  47857. */
  47858. disableSelectionMeshLighting: boolean;
  47859. /**
  47860. * Should the laser pointer be displayed
  47861. */
  47862. displayLaserPointer: boolean;
  47863. /**
  47864. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47865. */
  47866. displaySelectionMesh: boolean;
  47867. /**
  47868. * This color will be set to the laser pointer when selection is triggered
  47869. */
  47870. laserPointerPickedColor: Color3;
  47871. /**
  47872. * Default color of the laser pointer
  47873. */
  47874. laserPointerDefaultColor: Color3;
  47875. /**
  47876. * default color of the selection ring
  47877. */
  47878. selectionMeshDefaultColor: Color3;
  47879. /**
  47880. * This color will be applied to the selection ring when selection is triggered
  47881. */
  47882. selectionMeshPickedColor: Color3;
  47883. /**
  47884. * Optional filter to be used for ray selection. This predicate shares behavior with
  47885. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47886. */
  47887. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47888. /**
  47889. * constructs a new background remover module
  47890. * @param _xrSessionManager the session manager for this module
  47891. * @param _options read-only options to be used in this module
  47892. */
  47893. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47894. /**
  47895. * attach this feature
  47896. * Will usually be called by the features manager
  47897. *
  47898. * @returns true if successful.
  47899. */
  47900. attach(): boolean;
  47901. /**
  47902. * detach this feature.
  47903. * Will usually be called by the features manager
  47904. *
  47905. * @returns true if successful.
  47906. */
  47907. detach(): boolean;
  47908. /**
  47909. * Will get the mesh under a specific pointer.
  47910. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47911. * @param controllerId the controllerId to check
  47912. * @returns The mesh under pointer or null if no mesh is under the pointer
  47913. */
  47914. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47915. /**
  47916. * Get the xr controller that correlates to the pointer id in the pointer event
  47917. *
  47918. * @param id the pointer id to search for
  47919. * @returns the controller that correlates to this id or null if not found
  47920. */
  47921. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47922. protected _onXRFrame(_xrFrame: XRFrame): void;
  47923. private _attachGazeMode;
  47924. private _attachScreenRayMode;
  47925. private _attachTrackedPointerRayMode;
  47926. private _convertNormalToDirectionOfRay;
  47927. private _detachController;
  47928. private _generateNewMeshPair;
  47929. private _pickingMoved;
  47930. private _updatePointerDistance;
  47931. /** @hidden */
  47932. get lasterPointerDefaultColor(): Color3;
  47933. }
  47934. }
  47935. declare module BABYLON {
  47936. /**
  47937. * Button which can be used to enter a different mode of XR
  47938. */
  47939. export class WebXREnterExitUIButton {
  47940. /** button element */
  47941. element: HTMLElement;
  47942. /** XR initialization options for the button */
  47943. sessionMode: XRSessionMode;
  47944. /** Reference space type */
  47945. referenceSpaceType: XRReferenceSpaceType;
  47946. /**
  47947. * Creates a WebXREnterExitUIButton
  47948. * @param element button element
  47949. * @param sessionMode XR initialization session mode
  47950. * @param referenceSpaceType the type of reference space to be used
  47951. */
  47952. constructor(
  47953. /** button element */
  47954. element: HTMLElement,
  47955. /** XR initialization options for the button */
  47956. sessionMode: XRSessionMode,
  47957. /** Reference space type */
  47958. referenceSpaceType: XRReferenceSpaceType);
  47959. /**
  47960. * Extendable function which can be used to update the button's visuals when the state changes
  47961. * @param activeButton the current active button in the UI
  47962. */
  47963. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47964. }
  47965. /**
  47966. * Options to create the webXR UI
  47967. */
  47968. export class WebXREnterExitUIOptions {
  47969. /**
  47970. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47971. */
  47972. customButtons?: Array<WebXREnterExitUIButton>;
  47973. /**
  47974. * A reference space type to use when creating the default button.
  47975. * Default is local-floor
  47976. */
  47977. referenceSpaceType?: XRReferenceSpaceType;
  47978. /**
  47979. * Context to enter xr with
  47980. */
  47981. renderTarget?: Nullable<WebXRRenderTarget>;
  47982. /**
  47983. * A session mode to use when creating the default button.
  47984. * Default is immersive-vr
  47985. */
  47986. sessionMode?: XRSessionMode;
  47987. /**
  47988. * A list of optional features to init the session with
  47989. */
  47990. optionalFeatures?: string[];
  47991. }
  47992. /**
  47993. * UI to allow the user to enter/exit XR mode
  47994. */
  47995. export class WebXREnterExitUI implements IDisposable {
  47996. private scene;
  47997. /** version of the options passed to this UI */
  47998. options: WebXREnterExitUIOptions;
  47999. private _activeButton;
  48000. private _buttons;
  48001. private _overlay;
  48002. /**
  48003. * Fired every time the active button is changed.
  48004. *
  48005. * When xr is entered via a button that launches xr that button will be the callback parameter
  48006. *
  48007. * When exiting xr the callback parameter will be null)
  48008. */
  48009. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48010. /**
  48011. *
  48012. * @param scene babylon scene object to use
  48013. * @param options (read-only) version of the options passed to this UI
  48014. */
  48015. private constructor();
  48016. /**
  48017. * Creates UI to allow the user to enter/exit XR mode
  48018. * @param scene the scene to add the ui to
  48019. * @param helper the xr experience helper to enter/exit xr with
  48020. * @param options options to configure the UI
  48021. * @returns the created ui
  48022. */
  48023. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48024. /**
  48025. * Disposes of the XR UI component
  48026. */
  48027. dispose(): void;
  48028. private _updateButtons;
  48029. }
  48030. }
  48031. declare module BABYLON {
  48032. /**
  48033. * Class containing static functions to help procedurally build meshes
  48034. */
  48035. export class LinesBuilder {
  48036. /**
  48037. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48038. * * 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
  48039. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48040. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48041. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48042. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48043. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48044. * * 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
  48045. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48047. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48048. * @param name defines the name of the new line system
  48049. * @param options defines the options used to create the line system
  48050. * @param scene defines the hosting scene
  48051. * @returns a new line system mesh
  48052. */
  48053. static CreateLineSystem(name: string, options: {
  48054. lines: Vector3[][];
  48055. updatable?: boolean;
  48056. instance?: Nullable<LinesMesh>;
  48057. colors?: Nullable<Color4[][]>;
  48058. useVertexAlpha?: boolean;
  48059. }, scene: Nullable<Scene>): LinesMesh;
  48060. /**
  48061. * Creates a line mesh
  48062. * 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
  48063. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48064. * * The parameter `points` is an array successive Vector3
  48065. * * 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
  48066. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48067. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48068. * * When updating an instance, remember that only point positions can change, not the number of points
  48069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48071. * @param name defines the name of the new line system
  48072. * @param options defines the options used to create the line system
  48073. * @param scene defines the hosting scene
  48074. * @returns a new line mesh
  48075. */
  48076. static CreateLines(name: string, options: {
  48077. points: Vector3[];
  48078. updatable?: boolean;
  48079. instance?: Nullable<LinesMesh>;
  48080. colors?: Color4[];
  48081. useVertexAlpha?: boolean;
  48082. }, scene?: Nullable<Scene>): LinesMesh;
  48083. /**
  48084. * Creates a dashed line mesh
  48085. * * 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
  48086. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48087. * * The parameter `points` is an array successive Vector3
  48088. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48089. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48090. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48091. * * 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
  48092. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48093. * * When updating an instance, remember that only point positions can change, not the number of points
  48094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48095. * @param name defines the name of the mesh
  48096. * @param options defines the options used to create the mesh
  48097. * @param scene defines the hosting scene
  48098. * @returns the dashed line mesh
  48099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48100. */
  48101. static CreateDashedLines(name: string, options: {
  48102. points: Vector3[];
  48103. dashSize?: number;
  48104. gapSize?: number;
  48105. dashNb?: number;
  48106. updatable?: boolean;
  48107. instance?: LinesMesh;
  48108. useVertexAlpha?: boolean;
  48109. }, scene?: Nullable<Scene>): LinesMesh;
  48110. }
  48111. }
  48112. declare module BABYLON {
  48113. /**
  48114. * Construction options for a timer
  48115. */
  48116. export interface ITimerOptions<T> {
  48117. /**
  48118. * Time-to-end
  48119. */
  48120. timeout: number;
  48121. /**
  48122. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48123. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48124. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48125. */
  48126. contextObservable: Observable<T>;
  48127. /**
  48128. * Optional parameters when adding an observer to the observable
  48129. */
  48130. observableParameters?: {
  48131. mask?: number;
  48132. insertFirst?: boolean;
  48133. scope?: any;
  48134. };
  48135. /**
  48136. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48137. */
  48138. breakCondition?: (data?: ITimerData<T>) => boolean;
  48139. /**
  48140. * Will be triggered when the time condition has met
  48141. */
  48142. onEnded?: (data: ITimerData<any>) => void;
  48143. /**
  48144. * Will be triggered when the break condition has met (prematurely ended)
  48145. */
  48146. onAborted?: (data: ITimerData<any>) => void;
  48147. /**
  48148. * Optional function to execute on each tick (or count)
  48149. */
  48150. onTick?: (data: ITimerData<any>) => void;
  48151. }
  48152. /**
  48153. * An interface defining the data sent by the timer
  48154. */
  48155. export interface ITimerData<T> {
  48156. /**
  48157. * When did it start
  48158. */
  48159. startTime: number;
  48160. /**
  48161. * Time now
  48162. */
  48163. currentTime: number;
  48164. /**
  48165. * Time passed since started
  48166. */
  48167. deltaTime: number;
  48168. /**
  48169. * How much is completed, in [0.0...1.0].
  48170. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48171. */
  48172. completeRate: number;
  48173. /**
  48174. * What the registered observable sent in the last count
  48175. */
  48176. payload: T;
  48177. }
  48178. /**
  48179. * The current state of the timer
  48180. */
  48181. export enum TimerState {
  48182. /**
  48183. * Timer initialized, not yet started
  48184. */
  48185. INIT = 0,
  48186. /**
  48187. * Timer started and counting
  48188. */
  48189. STARTED = 1,
  48190. /**
  48191. * Timer ended (whether aborted or time reached)
  48192. */
  48193. ENDED = 2
  48194. }
  48195. /**
  48196. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48197. *
  48198. * @param options options with which to initialize this timer
  48199. */
  48200. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48201. /**
  48202. * An advanced implementation of a timer class
  48203. */
  48204. export class AdvancedTimer<T = any> implements IDisposable {
  48205. /**
  48206. * Will notify each time the timer calculates the remaining time
  48207. */
  48208. onEachCountObservable: Observable<ITimerData<T>>;
  48209. /**
  48210. * Will trigger when the timer was aborted due to the break condition
  48211. */
  48212. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48213. /**
  48214. * Will trigger when the timer ended successfully
  48215. */
  48216. onTimerEndedObservable: Observable<ITimerData<T>>;
  48217. /**
  48218. * Will trigger when the timer state has changed
  48219. */
  48220. onStateChangedObservable: Observable<TimerState>;
  48221. private _observer;
  48222. private _contextObservable;
  48223. private _observableParameters;
  48224. private _startTime;
  48225. private _timer;
  48226. private _state;
  48227. private _breakCondition;
  48228. private _timeToEnd;
  48229. private _breakOnNextTick;
  48230. /**
  48231. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48232. * @param options construction options for this advanced timer
  48233. */
  48234. constructor(options: ITimerOptions<T>);
  48235. /**
  48236. * set a breaking condition for this timer. Default is to never break during count
  48237. * @param predicate the new break condition. Returns true to break, false otherwise
  48238. */
  48239. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48240. /**
  48241. * Reset ALL associated observables in this advanced timer
  48242. */
  48243. clearObservables(): void;
  48244. /**
  48245. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48246. *
  48247. * @param timeToEnd how much time to measure until timer ended
  48248. */
  48249. start(timeToEnd?: number): void;
  48250. /**
  48251. * Will force a stop on the next tick.
  48252. */
  48253. stop(): void;
  48254. /**
  48255. * Dispose this timer, clearing all resources
  48256. */
  48257. dispose(): void;
  48258. private _setState;
  48259. private _tick;
  48260. private _stop;
  48261. }
  48262. }
  48263. declare module BABYLON {
  48264. /**
  48265. * The options container for the teleportation module
  48266. */
  48267. export interface IWebXRTeleportationOptions {
  48268. /**
  48269. * if provided, this scene will be used to render meshes.
  48270. */
  48271. customUtilityLayerScene?: Scene;
  48272. /**
  48273. * Values to configure the default target mesh
  48274. */
  48275. defaultTargetMeshOptions?: {
  48276. /**
  48277. * Fill color of the teleportation area
  48278. */
  48279. teleportationFillColor?: string;
  48280. /**
  48281. * Border color for the teleportation area
  48282. */
  48283. teleportationBorderColor?: string;
  48284. /**
  48285. * Disable the mesh's animation sequence
  48286. */
  48287. disableAnimation?: boolean;
  48288. /**
  48289. * Disable lighting on the material or the ring and arrow
  48290. */
  48291. disableLighting?: boolean;
  48292. /**
  48293. * Override the default material of the torus and arrow
  48294. */
  48295. torusArrowMaterial?: Material;
  48296. };
  48297. /**
  48298. * A list of meshes to use as floor meshes.
  48299. * Meshes can be added and removed after initializing the feature using the
  48300. * addFloorMesh and removeFloorMesh functions
  48301. * If empty, rotation will still work
  48302. */
  48303. floorMeshes?: AbstractMesh[];
  48304. /**
  48305. * use this rendering group id for the meshes (optional)
  48306. */
  48307. renderingGroupId?: number;
  48308. /**
  48309. * Should teleportation move only to snap points
  48310. */
  48311. snapPointsOnly?: boolean;
  48312. /**
  48313. * An array of points to which the teleportation will snap to.
  48314. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48315. */
  48316. snapPositions?: Vector3[];
  48317. /**
  48318. * How close should the teleportation ray be in order to snap to position.
  48319. * Default to 0.8 units (meters)
  48320. */
  48321. snapToPositionRadius?: number;
  48322. /**
  48323. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48324. * If you want to support rotation, make sure your mesh has a direction indicator.
  48325. *
  48326. * When left untouched, the default mesh will be initialized.
  48327. */
  48328. teleportationTargetMesh?: AbstractMesh;
  48329. /**
  48330. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48331. */
  48332. timeToTeleport?: number;
  48333. /**
  48334. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48335. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48336. */
  48337. useMainComponentOnly?: boolean;
  48338. /**
  48339. * Should meshes created here be added to a utility layer or the main scene
  48340. */
  48341. useUtilityLayer?: boolean;
  48342. /**
  48343. * Babylon XR Input class for controller
  48344. */
  48345. xrInput: WebXRInput;
  48346. }
  48347. /**
  48348. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48349. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48350. * the input of the attached controllers.
  48351. */
  48352. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48353. private _options;
  48354. private _controllers;
  48355. private _currentTeleportationControllerId;
  48356. private _floorMeshes;
  48357. private _quadraticBezierCurve;
  48358. private _selectionFeature;
  48359. private _snapToPositions;
  48360. private _snappedToPoint;
  48361. private _teleportationRingMaterial?;
  48362. private _tmpRay;
  48363. private _tmpVector;
  48364. /**
  48365. * The module's name
  48366. */
  48367. static readonly Name: string;
  48368. /**
  48369. * The (Babylon) version of this module.
  48370. * This is an integer representing the implementation version.
  48371. * This number does not correspond to the webxr specs version
  48372. */
  48373. static readonly Version: number;
  48374. /**
  48375. * Is movement backwards enabled
  48376. */
  48377. backwardsMovementEnabled: boolean;
  48378. /**
  48379. * Distance to travel when moving backwards
  48380. */
  48381. backwardsTeleportationDistance: number;
  48382. /**
  48383. * The distance from the user to the inspection point in the direction of the controller
  48384. * A higher number will allow the user to move further
  48385. * defaults to 5 (meters, in xr units)
  48386. */
  48387. parabolicCheckRadius: number;
  48388. /**
  48389. * Should the module support parabolic ray on top of direct ray
  48390. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48391. * Very helpful when moving between floors / different heights
  48392. */
  48393. parabolicRayEnabled: boolean;
  48394. /**
  48395. * How much rotation should be applied when rotating right and left
  48396. */
  48397. rotationAngle: number;
  48398. /**
  48399. * Is rotation enabled when moving forward?
  48400. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48401. */
  48402. rotationEnabled: boolean;
  48403. /**
  48404. * constructs a new anchor system
  48405. * @param _xrSessionManager an instance of WebXRSessionManager
  48406. * @param _options configuration object for this feature
  48407. */
  48408. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48409. /**
  48410. * Get the snapPointsOnly flag
  48411. */
  48412. get snapPointsOnly(): boolean;
  48413. /**
  48414. * Sets the snapPointsOnly flag
  48415. * @param snapToPoints should teleportation be exclusively to snap points
  48416. */
  48417. set snapPointsOnly(snapToPoints: boolean);
  48418. /**
  48419. * Add a new mesh to the floor meshes array
  48420. * @param mesh the mesh to use as floor mesh
  48421. */
  48422. addFloorMesh(mesh: AbstractMesh): void;
  48423. /**
  48424. * Add a new snap-to point to fix teleportation to this position
  48425. * @param newSnapPoint The new Snap-To point
  48426. */
  48427. addSnapPoint(newSnapPoint: Vector3): void;
  48428. attach(): boolean;
  48429. detach(): boolean;
  48430. dispose(): void;
  48431. /**
  48432. * Remove a mesh from the floor meshes array
  48433. * @param mesh the mesh to remove
  48434. */
  48435. removeFloorMesh(mesh: AbstractMesh): void;
  48436. /**
  48437. * Remove a mesh from the floor meshes array using its name
  48438. * @param name the mesh name to remove
  48439. */
  48440. removeFloorMeshByName(name: string): void;
  48441. /**
  48442. * 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
  48443. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48444. * @returns was the point found and removed or not
  48445. */
  48446. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48447. /**
  48448. * This function sets a selection feature that will be disabled when
  48449. * the forward ray is shown and will be reattached when hidden.
  48450. * This is used to remove the selection rays when moving.
  48451. * @param selectionFeature the feature to disable when forward movement is enabled
  48452. */
  48453. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48454. protected _onXRFrame(_xrFrame: XRFrame): void;
  48455. private _attachController;
  48456. private _createDefaultTargetMesh;
  48457. private _detachController;
  48458. private _findClosestSnapPointWithRadius;
  48459. private _setTargetMeshPosition;
  48460. private _setTargetMeshVisibility;
  48461. private _showParabolicPath;
  48462. private _teleportForward;
  48463. }
  48464. }
  48465. declare module BABYLON {
  48466. /**
  48467. * Options for the default xr helper
  48468. */
  48469. export class WebXRDefaultExperienceOptions {
  48470. /**
  48471. * Enable or disable default UI to enter XR
  48472. */
  48473. disableDefaultUI?: boolean;
  48474. /**
  48475. * Should teleportation not initialize. defaults to false.
  48476. */
  48477. disableTeleportation?: boolean;
  48478. /**
  48479. * Floor meshes that will be used for teleport
  48480. */
  48481. floorMeshes?: Array<AbstractMesh>;
  48482. /**
  48483. * If set to true, the first frame will not be used to reset position
  48484. * The first frame is mainly used when copying transformation from the old camera
  48485. * Mainly used in AR
  48486. */
  48487. ignoreNativeCameraTransformation?: boolean;
  48488. /**
  48489. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48490. */
  48491. inputOptions?: IWebXRInputOptions;
  48492. /**
  48493. * optional configuration for the output canvas
  48494. */
  48495. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48496. /**
  48497. * optional UI options. This can be used among other to change session mode and reference space type
  48498. */
  48499. uiOptions?: WebXREnterExitUIOptions;
  48500. /**
  48501. * When loading teleportation and pointer select, use stable versions instead of latest.
  48502. */
  48503. useStablePlugins?: boolean;
  48504. /**
  48505. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48506. */
  48507. renderingGroupId?: number;
  48508. /**
  48509. * A list of optional features to init the session with
  48510. * If set to true, all features we support will be added
  48511. */
  48512. optionalFeatures?: boolean | string[];
  48513. }
  48514. /**
  48515. * Default experience which provides a similar setup to the previous webVRExperience
  48516. */
  48517. export class WebXRDefaultExperience {
  48518. /**
  48519. * Base experience
  48520. */
  48521. baseExperience: WebXRExperienceHelper;
  48522. /**
  48523. * Enables ui for entering/exiting xr
  48524. */
  48525. enterExitUI: WebXREnterExitUI;
  48526. /**
  48527. * Input experience extension
  48528. */
  48529. input: WebXRInput;
  48530. /**
  48531. * Enables laser pointer and selection
  48532. */
  48533. pointerSelection: WebXRControllerPointerSelection;
  48534. /**
  48535. * Default target xr should render to
  48536. */
  48537. renderTarget: WebXRRenderTarget;
  48538. /**
  48539. * Enables teleportation
  48540. */
  48541. teleportation: WebXRMotionControllerTeleportation;
  48542. private constructor();
  48543. /**
  48544. * Creates the default xr experience
  48545. * @param scene scene
  48546. * @param options options for basic configuration
  48547. * @returns resulting WebXRDefaultExperience
  48548. */
  48549. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48550. /**
  48551. * DIsposes of the experience helper
  48552. */
  48553. dispose(): void;
  48554. }
  48555. }
  48556. declare module BABYLON {
  48557. /**
  48558. * Options to modify the vr teleportation behavior.
  48559. */
  48560. export interface VRTeleportationOptions {
  48561. /**
  48562. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48563. */
  48564. floorMeshName?: string;
  48565. /**
  48566. * A list of meshes to be used as the teleportation floor. (default: empty)
  48567. */
  48568. floorMeshes?: Mesh[];
  48569. /**
  48570. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48571. */
  48572. teleportationMode?: number;
  48573. /**
  48574. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48575. */
  48576. teleportationTime?: number;
  48577. /**
  48578. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48579. */
  48580. teleportationSpeed?: number;
  48581. /**
  48582. * The easing function used in the animation or null for Linear. (default CircleEase)
  48583. */
  48584. easingFunction?: EasingFunction;
  48585. }
  48586. /**
  48587. * Options to modify the vr experience helper's behavior.
  48588. */
  48589. export interface VRExperienceHelperOptions extends WebVROptions {
  48590. /**
  48591. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48592. */
  48593. createDeviceOrientationCamera?: boolean;
  48594. /**
  48595. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48596. */
  48597. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48598. /**
  48599. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48600. */
  48601. laserToggle?: boolean;
  48602. /**
  48603. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48604. */
  48605. floorMeshes?: Mesh[];
  48606. /**
  48607. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48608. */
  48609. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48610. /**
  48611. * Defines if WebXR should be used instead of WebVR (if available)
  48612. */
  48613. useXR?: boolean;
  48614. }
  48615. /**
  48616. * Event containing information after VR has been entered
  48617. */
  48618. export class OnAfterEnteringVRObservableEvent {
  48619. /**
  48620. * If entering vr was successful
  48621. */
  48622. success: boolean;
  48623. }
  48624. /**
  48625. * Helps to quickly add VR support to an existing scene.
  48626. * See http://doc.babylonjs.com/how_to/webvr_helper
  48627. */
  48628. export class VRExperienceHelper {
  48629. /** Options to modify the vr experience helper's behavior. */
  48630. webVROptions: VRExperienceHelperOptions;
  48631. private _scene;
  48632. private _position;
  48633. private _btnVR;
  48634. private _btnVRDisplayed;
  48635. private _webVRsupported;
  48636. private _webVRready;
  48637. private _webVRrequesting;
  48638. private _webVRpresenting;
  48639. private _hasEnteredVR;
  48640. private _fullscreenVRpresenting;
  48641. private _inputElement;
  48642. private _webVRCamera;
  48643. private _vrDeviceOrientationCamera;
  48644. private _deviceOrientationCamera;
  48645. private _existingCamera;
  48646. private _onKeyDown;
  48647. private _onVrDisplayPresentChange;
  48648. private _onVRDisplayChanged;
  48649. private _onVRRequestPresentStart;
  48650. private _onVRRequestPresentComplete;
  48651. /**
  48652. * 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)
  48653. */
  48654. enableGazeEvenWhenNoPointerLock: boolean;
  48655. /**
  48656. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48657. */
  48658. exitVROnDoubleTap: boolean;
  48659. /**
  48660. * Observable raised right before entering VR.
  48661. */
  48662. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48663. /**
  48664. * Observable raised when entering VR has completed.
  48665. */
  48666. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48667. /**
  48668. * Observable raised when exiting VR.
  48669. */
  48670. onExitingVRObservable: Observable<VRExperienceHelper>;
  48671. /**
  48672. * Observable raised when controller mesh is loaded.
  48673. */
  48674. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48675. /** Return this.onEnteringVRObservable
  48676. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48677. */
  48678. get onEnteringVR(): Observable<VRExperienceHelper>;
  48679. /** Return this.onExitingVRObservable
  48680. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48681. */
  48682. get onExitingVR(): Observable<VRExperienceHelper>;
  48683. /** Return this.onControllerMeshLoadedObservable
  48684. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48685. */
  48686. get onControllerMeshLoaded(): Observable<WebVRController>;
  48687. private _rayLength;
  48688. private _useCustomVRButton;
  48689. private _teleportationRequested;
  48690. private _teleportActive;
  48691. private _floorMeshName;
  48692. private _floorMeshesCollection;
  48693. private _teleportationMode;
  48694. private _teleportationTime;
  48695. private _teleportationSpeed;
  48696. private _teleportationEasing;
  48697. private _rotationAllowed;
  48698. private _teleportBackwardsVector;
  48699. private _teleportationTarget;
  48700. private _isDefaultTeleportationTarget;
  48701. private _postProcessMove;
  48702. private _teleportationFillColor;
  48703. private _teleportationBorderColor;
  48704. private _rotationAngle;
  48705. private _haloCenter;
  48706. private _cameraGazer;
  48707. private _padSensibilityUp;
  48708. private _padSensibilityDown;
  48709. private _leftController;
  48710. private _rightController;
  48711. private _gazeColor;
  48712. private _laserColor;
  48713. private _pickedLaserColor;
  48714. private _pickedGazeColor;
  48715. /**
  48716. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48717. */
  48718. onNewMeshSelected: Observable<AbstractMesh>;
  48719. /**
  48720. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48721. * This observable will provide the mesh and the controller used to select the mesh
  48722. */
  48723. onMeshSelectedWithController: Observable<{
  48724. mesh: AbstractMesh;
  48725. controller: WebVRController;
  48726. }>;
  48727. /**
  48728. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48729. */
  48730. onNewMeshPicked: Observable<PickingInfo>;
  48731. private _circleEase;
  48732. /**
  48733. * Observable raised before camera teleportation
  48734. */
  48735. onBeforeCameraTeleport: Observable<Vector3>;
  48736. /**
  48737. * Observable raised after camera teleportation
  48738. */
  48739. onAfterCameraTeleport: Observable<Vector3>;
  48740. /**
  48741. * Observable raised when current selected mesh gets unselected
  48742. */
  48743. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48744. private _raySelectionPredicate;
  48745. /**
  48746. * To be optionaly changed by user to define custom ray selection
  48747. */
  48748. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48749. /**
  48750. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48751. */
  48752. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48753. /**
  48754. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48755. */
  48756. teleportationEnabled: boolean;
  48757. private _defaultHeight;
  48758. private _teleportationInitialized;
  48759. private _interactionsEnabled;
  48760. private _interactionsRequested;
  48761. private _displayGaze;
  48762. private _displayLaserPointer;
  48763. /**
  48764. * The mesh used to display where the user is going to teleport.
  48765. */
  48766. get teleportationTarget(): Mesh;
  48767. /**
  48768. * Sets the mesh to be used to display where the user is going to teleport.
  48769. */
  48770. set teleportationTarget(value: Mesh);
  48771. /**
  48772. * 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
  48773. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48774. * See http://doc.babylonjs.com/resources/baking_transformations
  48775. */
  48776. get gazeTrackerMesh(): Mesh;
  48777. set gazeTrackerMesh(value: Mesh);
  48778. /**
  48779. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48780. */
  48781. updateGazeTrackerScale: boolean;
  48782. /**
  48783. * If the gaze trackers color should be updated when selecting meshes
  48784. */
  48785. updateGazeTrackerColor: boolean;
  48786. /**
  48787. * If the controller laser color should be updated when selecting meshes
  48788. */
  48789. updateControllerLaserColor: boolean;
  48790. /**
  48791. * The gaze tracking mesh corresponding to the left controller
  48792. */
  48793. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48794. /**
  48795. * The gaze tracking mesh corresponding to the right controller
  48796. */
  48797. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48798. /**
  48799. * If the ray of the gaze should be displayed.
  48800. */
  48801. get displayGaze(): boolean;
  48802. /**
  48803. * Sets if the ray of the gaze should be displayed.
  48804. */
  48805. set displayGaze(value: boolean);
  48806. /**
  48807. * If the ray of the LaserPointer should be displayed.
  48808. */
  48809. get displayLaserPointer(): boolean;
  48810. /**
  48811. * Sets if the ray of the LaserPointer should be displayed.
  48812. */
  48813. set displayLaserPointer(value: boolean);
  48814. /**
  48815. * The deviceOrientationCamera used as the camera when not in VR.
  48816. */
  48817. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48818. /**
  48819. * Based on the current WebVR support, returns the current VR camera used.
  48820. */
  48821. get currentVRCamera(): Nullable<Camera>;
  48822. /**
  48823. * The webVRCamera which is used when in VR.
  48824. */
  48825. get webVRCamera(): WebVRFreeCamera;
  48826. /**
  48827. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48828. */
  48829. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48830. /**
  48831. * The html button that is used to trigger entering into VR.
  48832. */
  48833. get vrButton(): Nullable<HTMLButtonElement>;
  48834. private get _teleportationRequestInitiated();
  48835. /**
  48836. * Defines whether or not Pointer lock should be requested when switching to
  48837. * full screen.
  48838. */
  48839. requestPointerLockOnFullScreen: boolean;
  48840. /**
  48841. * If asking to force XR, this will be populated with the default xr experience
  48842. */
  48843. xr: WebXRDefaultExperience;
  48844. /**
  48845. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48846. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48847. */
  48848. xrTestDone: boolean;
  48849. /**
  48850. * Instantiates a VRExperienceHelper.
  48851. * Helps to quickly add VR support to an existing scene.
  48852. * @param scene The scene the VRExperienceHelper belongs to.
  48853. * @param webVROptions Options to modify the vr experience helper's behavior.
  48854. */
  48855. constructor(scene: Scene,
  48856. /** Options to modify the vr experience helper's behavior. */
  48857. webVROptions?: VRExperienceHelperOptions);
  48858. private completeVRInit;
  48859. private _onDefaultMeshLoaded;
  48860. private _onResize;
  48861. private _onFullscreenChange;
  48862. /**
  48863. * Gets a value indicating if we are currently in VR mode.
  48864. */
  48865. get isInVRMode(): boolean;
  48866. private onVrDisplayPresentChange;
  48867. private onVRDisplayChanged;
  48868. private moveButtonToBottomRight;
  48869. private displayVRButton;
  48870. private updateButtonVisibility;
  48871. private _cachedAngularSensibility;
  48872. /**
  48873. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48874. * Otherwise, will use the fullscreen API.
  48875. */
  48876. enterVR(): void;
  48877. /**
  48878. * Attempt to exit VR, or fullscreen.
  48879. */
  48880. exitVR(): void;
  48881. /**
  48882. * The position of the vr experience helper.
  48883. */
  48884. get position(): Vector3;
  48885. /**
  48886. * Sets the position of the vr experience helper.
  48887. */
  48888. set position(value: Vector3);
  48889. /**
  48890. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48891. */
  48892. enableInteractions(): void;
  48893. private get _noControllerIsActive();
  48894. private beforeRender;
  48895. private _isTeleportationFloor;
  48896. /**
  48897. * Adds a floor mesh to be used for teleportation.
  48898. * @param floorMesh the mesh to be used for teleportation.
  48899. */
  48900. addFloorMesh(floorMesh: Mesh): void;
  48901. /**
  48902. * Removes a floor mesh from being used for teleportation.
  48903. * @param floorMesh the mesh to be removed.
  48904. */
  48905. removeFloorMesh(floorMesh: Mesh): void;
  48906. /**
  48907. * Enables interactions and teleportation using the VR controllers and gaze.
  48908. * @param vrTeleportationOptions options to modify teleportation behavior.
  48909. */
  48910. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48911. private _onNewGamepadConnected;
  48912. private _tryEnableInteractionOnController;
  48913. private _onNewGamepadDisconnected;
  48914. private _enableInteractionOnController;
  48915. private _checkTeleportWithRay;
  48916. private _checkRotate;
  48917. private _checkTeleportBackwards;
  48918. private _enableTeleportationOnController;
  48919. private _createTeleportationCircles;
  48920. private _displayTeleportationTarget;
  48921. private _hideTeleportationTarget;
  48922. private _rotateCamera;
  48923. private _moveTeleportationSelectorTo;
  48924. private _workingVector;
  48925. private _workingQuaternion;
  48926. private _workingMatrix;
  48927. /**
  48928. * Time Constant Teleportation Mode
  48929. */
  48930. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48931. /**
  48932. * Speed Constant Teleportation Mode
  48933. */
  48934. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48935. /**
  48936. * Teleports the users feet to the desired location
  48937. * @param location The location where the user's feet should be placed
  48938. */
  48939. teleportCamera(location: Vector3): void;
  48940. private _convertNormalToDirectionOfRay;
  48941. private _castRayAndSelectObject;
  48942. private _notifySelectedMeshUnselected;
  48943. /**
  48944. * Permanently set new colors for the laser pointer
  48945. * @param color the new laser color
  48946. * @param pickedColor the new laser color when picked mesh detected
  48947. */
  48948. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48949. /**
  48950. * Set lighting enabled / disabled on the laser pointer of both controllers
  48951. * @param enabled should the lighting be enabled on the laser pointer
  48952. */
  48953. setLaserLightingState(enabled?: boolean): void;
  48954. /**
  48955. * Permanently set new colors for the gaze pointer
  48956. * @param color the new gaze color
  48957. * @param pickedColor the new gaze color when picked mesh detected
  48958. */
  48959. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48960. /**
  48961. * Sets the color of the laser ray from the vr controllers.
  48962. * @param color new color for the ray.
  48963. */
  48964. changeLaserColor(color: Color3): void;
  48965. /**
  48966. * Sets the color of the ray from the vr headsets gaze.
  48967. * @param color new color for the ray.
  48968. */
  48969. changeGazeColor(color: Color3): void;
  48970. /**
  48971. * Exits VR and disposes of the vr experience helper
  48972. */
  48973. dispose(): void;
  48974. /**
  48975. * Gets the name of the VRExperienceHelper class
  48976. * @returns "VRExperienceHelper"
  48977. */
  48978. getClassName(): string;
  48979. }
  48980. }
  48981. declare module BABYLON {
  48982. /**
  48983. * Contains an array of blocks representing the octree
  48984. */
  48985. export interface IOctreeContainer<T> {
  48986. /**
  48987. * Blocks within the octree
  48988. */
  48989. blocks: Array<OctreeBlock<T>>;
  48990. }
  48991. /**
  48992. * Class used to store a cell in an octree
  48993. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48994. */
  48995. export class OctreeBlock<T> {
  48996. /**
  48997. * Gets the content of the current block
  48998. */
  48999. entries: T[];
  49000. /**
  49001. * Gets the list of block children
  49002. */
  49003. blocks: Array<OctreeBlock<T>>;
  49004. private _depth;
  49005. private _maxDepth;
  49006. private _capacity;
  49007. private _minPoint;
  49008. private _maxPoint;
  49009. private _boundingVectors;
  49010. private _creationFunc;
  49011. /**
  49012. * Creates a new block
  49013. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49014. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49015. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49016. * @param depth defines the current depth of this block in the octree
  49017. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49018. * @param creationFunc defines a callback to call when an element is added to the block
  49019. */
  49020. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49021. /**
  49022. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49023. */
  49024. get capacity(): number;
  49025. /**
  49026. * Gets the minimum vector (in world space) of the block's bounding box
  49027. */
  49028. get minPoint(): Vector3;
  49029. /**
  49030. * Gets the maximum vector (in world space) of the block's bounding box
  49031. */
  49032. get maxPoint(): Vector3;
  49033. /**
  49034. * Add a new element to this block
  49035. * @param entry defines the element to add
  49036. */
  49037. addEntry(entry: T): void;
  49038. /**
  49039. * Remove an element from this block
  49040. * @param entry defines the element to remove
  49041. */
  49042. removeEntry(entry: T): void;
  49043. /**
  49044. * Add an array of elements to this block
  49045. * @param entries defines the array of elements to add
  49046. */
  49047. addEntries(entries: T[]): void;
  49048. /**
  49049. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49050. * @param frustumPlanes defines the frustum planes to test
  49051. * @param selection defines the array to store current content if selection is positive
  49052. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49053. */
  49054. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49055. /**
  49056. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49057. * @param sphereCenter defines the bounding sphere center
  49058. * @param sphereRadius defines the bounding sphere radius
  49059. * @param selection defines the array to store current content if selection is positive
  49060. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49061. */
  49062. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49063. /**
  49064. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49065. * @param ray defines the ray to test with
  49066. * @param selection defines the array to store current content if selection is positive
  49067. */
  49068. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49069. /**
  49070. * Subdivide the content into child blocks (this block will then be empty)
  49071. */
  49072. createInnerBlocks(): void;
  49073. /**
  49074. * @hidden
  49075. */
  49076. 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;
  49077. }
  49078. }
  49079. declare module BABYLON {
  49080. /**
  49081. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49082. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49083. */
  49084. export class Octree<T> {
  49085. /** 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.) */
  49086. maxDepth: number;
  49087. /**
  49088. * Blocks within the octree containing objects
  49089. */
  49090. blocks: Array<OctreeBlock<T>>;
  49091. /**
  49092. * Content stored in the octree
  49093. */
  49094. dynamicContent: T[];
  49095. private _maxBlockCapacity;
  49096. private _selectionContent;
  49097. private _creationFunc;
  49098. /**
  49099. * Creates a octree
  49100. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49101. * @param creationFunc function to be used to instatiate the octree
  49102. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49103. * @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.)
  49104. */
  49105. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49106. /** 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.) */
  49107. maxDepth?: number);
  49108. /**
  49109. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49110. * @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);
  49111. * @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);
  49112. * @param entries meshes to be added to the octree blocks
  49113. */
  49114. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49115. /**
  49116. * Adds a mesh to the octree
  49117. * @param entry Mesh to add to the octree
  49118. */
  49119. addMesh(entry: T): void;
  49120. /**
  49121. * Remove an element from the octree
  49122. * @param entry defines the element to remove
  49123. */
  49124. removeMesh(entry: T): void;
  49125. /**
  49126. * Selects an array of meshes within the frustum
  49127. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49128. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49129. * @returns array of meshes within the frustum
  49130. */
  49131. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49132. /**
  49133. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49134. * @param sphereCenter defines the bounding sphere center
  49135. * @param sphereRadius defines the bounding sphere radius
  49136. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49137. * @returns an array of objects that intersect the sphere
  49138. */
  49139. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49140. /**
  49141. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49142. * @param ray defines the ray to test with
  49143. * @returns array of intersected objects
  49144. */
  49145. intersectsRay(ray: Ray): SmartArray<T>;
  49146. /**
  49147. * Adds a mesh into the octree block if it intersects the block
  49148. */
  49149. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49150. /**
  49151. * Adds a submesh into the octree block if it intersects the block
  49152. */
  49153. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49154. }
  49155. }
  49156. declare module BABYLON {
  49157. interface Scene {
  49158. /**
  49159. * @hidden
  49160. * Backing Filed
  49161. */
  49162. _selectionOctree: Octree<AbstractMesh>;
  49163. /**
  49164. * Gets the octree used to boost mesh selection (picking)
  49165. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49166. */
  49167. selectionOctree: Octree<AbstractMesh>;
  49168. /**
  49169. * Creates or updates the octree used to boost selection (picking)
  49170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49171. * @param maxCapacity defines the maximum capacity per leaf
  49172. * @param maxDepth defines the maximum depth of the octree
  49173. * @returns an octree of AbstractMesh
  49174. */
  49175. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49176. }
  49177. interface AbstractMesh {
  49178. /**
  49179. * @hidden
  49180. * Backing Field
  49181. */
  49182. _submeshesOctree: Octree<SubMesh>;
  49183. /**
  49184. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49185. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49186. * @param maxCapacity defines the maximum size of each block (64 by default)
  49187. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49188. * @returns the new octree
  49189. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49191. */
  49192. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49193. }
  49194. /**
  49195. * Defines the octree scene component responsible to manage any octrees
  49196. * in a given scene.
  49197. */
  49198. export class OctreeSceneComponent {
  49199. /**
  49200. * The component name help to identify the component in the list of scene components.
  49201. */
  49202. readonly name: string;
  49203. /**
  49204. * The scene the component belongs to.
  49205. */
  49206. scene: Scene;
  49207. /**
  49208. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49209. */
  49210. readonly checksIsEnabled: boolean;
  49211. /**
  49212. * Creates a new instance of the component for the given scene
  49213. * @param scene Defines the scene to register the component in
  49214. */
  49215. constructor(scene: Scene);
  49216. /**
  49217. * Registers the component in a given scene
  49218. */
  49219. register(): void;
  49220. /**
  49221. * Return the list of active meshes
  49222. * @returns the list of active meshes
  49223. */
  49224. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49225. /**
  49226. * Return the list of active sub meshes
  49227. * @param mesh The mesh to get the candidates sub meshes from
  49228. * @returns the list of active sub meshes
  49229. */
  49230. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49231. private _tempRay;
  49232. /**
  49233. * Return the list of sub meshes intersecting with a given local ray
  49234. * @param mesh defines the mesh to find the submesh for
  49235. * @param localRay defines the ray in local space
  49236. * @returns the list of intersecting sub meshes
  49237. */
  49238. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49239. /**
  49240. * Return the list of sub meshes colliding with a collider
  49241. * @param mesh defines the mesh to find the submesh for
  49242. * @param collider defines the collider to evaluate the collision against
  49243. * @returns the list of colliding sub meshes
  49244. */
  49245. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49246. /**
  49247. * Rebuilds the elements related to this component in case of
  49248. * context lost for instance.
  49249. */
  49250. rebuild(): void;
  49251. /**
  49252. * Disposes the component and the associated ressources.
  49253. */
  49254. dispose(): void;
  49255. }
  49256. }
  49257. declare module BABYLON {
  49258. /**
  49259. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49260. */
  49261. export class Gizmo implements IDisposable {
  49262. /** The utility layer the gizmo will be added to */
  49263. gizmoLayer: UtilityLayerRenderer;
  49264. /**
  49265. * The root mesh of the gizmo
  49266. */
  49267. _rootMesh: Mesh;
  49268. private _attachedMesh;
  49269. /**
  49270. * Ratio for the scale of the gizmo (Default: 1)
  49271. */
  49272. scaleRatio: number;
  49273. /**
  49274. * If a custom mesh has been set (Default: false)
  49275. */
  49276. protected _customMeshSet: boolean;
  49277. /**
  49278. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49279. * * When set, interactions will be enabled
  49280. */
  49281. get attachedMesh(): Nullable<AbstractMesh>;
  49282. set attachedMesh(value: Nullable<AbstractMesh>);
  49283. /**
  49284. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49285. * @param mesh The mesh to replace the default mesh of the gizmo
  49286. */
  49287. setCustomMesh(mesh: Mesh): void;
  49288. /**
  49289. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49290. */
  49291. updateGizmoRotationToMatchAttachedMesh: boolean;
  49292. /**
  49293. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49294. */
  49295. updateGizmoPositionToMatchAttachedMesh: boolean;
  49296. /**
  49297. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49298. */
  49299. updateScale: boolean;
  49300. protected _interactionsEnabled: boolean;
  49301. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49302. private _beforeRenderObserver;
  49303. private _tempVector;
  49304. /**
  49305. * Creates a gizmo
  49306. * @param gizmoLayer The utility layer the gizmo will be added to
  49307. */
  49308. constructor(
  49309. /** The utility layer the gizmo will be added to */
  49310. gizmoLayer?: UtilityLayerRenderer);
  49311. /**
  49312. * Updates the gizmo to match the attached mesh's position/rotation
  49313. */
  49314. protected _update(): void;
  49315. /**
  49316. * Disposes of the gizmo
  49317. */
  49318. dispose(): void;
  49319. }
  49320. }
  49321. declare module BABYLON {
  49322. /**
  49323. * Single plane drag gizmo
  49324. */
  49325. export class PlaneDragGizmo extends Gizmo {
  49326. /**
  49327. * Drag behavior responsible for the gizmos dragging interactions
  49328. */
  49329. dragBehavior: PointerDragBehavior;
  49330. private _pointerObserver;
  49331. /**
  49332. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49333. */
  49334. snapDistance: number;
  49335. /**
  49336. * Event that fires each time the gizmo snaps to a new location.
  49337. * * snapDistance is the the change in distance
  49338. */
  49339. onSnapObservable: Observable<{
  49340. snapDistance: number;
  49341. }>;
  49342. private _plane;
  49343. private _coloredMaterial;
  49344. private _hoverMaterial;
  49345. private _isEnabled;
  49346. private _parent;
  49347. /** @hidden */
  49348. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49349. /** @hidden */
  49350. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49351. /**
  49352. * Creates a PlaneDragGizmo
  49353. * @param gizmoLayer The utility layer the gizmo will be added to
  49354. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49355. * @param color The color of the gizmo
  49356. */
  49357. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49358. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49359. /**
  49360. * If the gizmo is enabled
  49361. */
  49362. set isEnabled(value: boolean);
  49363. get isEnabled(): boolean;
  49364. /**
  49365. * Disposes of the gizmo
  49366. */
  49367. dispose(): void;
  49368. }
  49369. }
  49370. declare module BABYLON {
  49371. /**
  49372. * Gizmo that enables dragging a mesh along 3 axis
  49373. */
  49374. export class PositionGizmo extends Gizmo {
  49375. /**
  49376. * Internal gizmo used for interactions on the x axis
  49377. */
  49378. xGizmo: AxisDragGizmo;
  49379. /**
  49380. * Internal gizmo used for interactions on the y axis
  49381. */
  49382. yGizmo: AxisDragGizmo;
  49383. /**
  49384. * Internal gizmo used for interactions on the z axis
  49385. */
  49386. zGizmo: AxisDragGizmo;
  49387. /**
  49388. * Internal gizmo used for interactions on the yz plane
  49389. */
  49390. xPlaneGizmo: PlaneDragGizmo;
  49391. /**
  49392. * Internal gizmo used for interactions on the xz plane
  49393. */
  49394. yPlaneGizmo: PlaneDragGizmo;
  49395. /**
  49396. * Internal gizmo used for interactions on the xy plane
  49397. */
  49398. zPlaneGizmo: PlaneDragGizmo;
  49399. /**
  49400. * private variables
  49401. */
  49402. private _meshAttached;
  49403. private _updateGizmoRotationToMatchAttachedMesh;
  49404. private _snapDistance;
  49405. private _scaleRatio;
  49406. /** Fires an event when any of it's sub gizmos are dragged */
  49407. onDragStartObservable: Observable<unknown>;
  49408. /** Fires an event when any of it's sub gizmos are released from dragging */
  49409. onDragEndObservable: Observable<unknown>;
  49410. /**
  49411. * If set to true, planar drag is enabled
  49412. */
  49413. private _planarGizmoEnabled;
  49414. get attachedMesh(): Nullable<AbstractMesh>;
  49415. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49416. /**
  49417. * Creates a PositionGizmo
  49418. * @param gizmoLayer The utility layer the gizmo will be added to
  49419. */
  49420. constructor(gizmoLayer?: UtilityLayerRenderer);
  49421. /**
  49422. * If the planar drag gizmo is enabled
  49423. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49424. */
  49425. set planarGizmoEnabled(value: boolean);
  49426. get planarGizmoEnabled(): boolean;
  49427. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49428. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49429. /**
  49430. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49431. */
  49432. set snapDistance(value: number);
  49433. get snapDistance(): number;
  49434. /**
  49435. * Ratio for the scale of the gizmo (Default: 1)
  49436. */
  49437. set scaleRatio(value: number);
  49438. get scaleRatio(): number;
  49439. /**
  49440. * Disposes of the gizmo
  49441. */
  49442. dispose(): void;
  49443. /**
  49444. * CustomMeshes are not supported by this gizmo
  49445. * @param mesh The mesh to replace the default mesh of the gizmo
  49446. */
  49447. setCustomMesh(mesh: Mesh): void;
  49448. }
  49449. }
  49450. declare module BABYLON {
  49451. /**
  49452. * Single axis drag gizmo
  49453. */
  49454. export class AxisDragGizmo extends Gizmo {
  49455. /**
  49456. * Drag behavior responsible for the gizmos dragging interactions
  49457. */
  49458. dragBehavior: PointerDragBehavior;
  49459. private _pointerObserver;
  49460. /**
  49461. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49462. */
  49463. snapDistance: number;
  49464. /**
  49465. * Event that fires each time the gizmo snaps to a new location.
  49466. * * snapDistance is the the change in distance
  49467. */
  49468. onSnapObservable: Observable<{
  49469. snapDistance: number;
  49470. }>;
  49471. private _isEnabled;
  49472. private _parent;
  49473. private _arrow;
  49474. private _coloredMaterial;
  49475. private _hoverMaterial;
  49476. /** @hidden */
  49477. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49478. /** @hidden */
  49479. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49480. /**
  49481. * Creates an AxisDragGizmo
  49482. * @param gizmoLayer The utility layer the gizmo will be added to
  49483. * @param dragAxis The axis which the gizmo will be able to drag on
  49484. * @param color The color of the gizmo
  49485. */
  49486. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49487. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49488. /**
  49489. * If the gizmo is enabled
  49490. */
  49491. set isEnabled(value: boolean);
  49492. get isEnabled(): boolean;
  49493. /**
  49494. * Disposes of the gizmo
  49495. */
  49496. dispose(): void;
  49497. }
  49498. }
  49499. declare module BABYLON.Debug {
  49500. /**
  49501. * The Axes viewer will show 3 axes in a specific point in space
  49502. */
  49503. export class AxesViewer {
  49504. private _xAxis;
  49505. private _yAxis;
  49506. private _zAxis;
  49507. private _scaleLinesFactor;
  49508. private _instanced;
  49509. /**
  49510. * Gets the hosting scene
  49511. */
  49512. scene: Scene;
  49513. /**
  49514. * Gets or sets a number used to scale line length
  49515. */
  49516. scaleLines: number;
  49517. /** Gets the node hierarchy used to render x-axis */
  49518. get xAxis(): TransformNode;
  49519. /** Gets the node hierarchy used to render y-axis */
  49520. get yAxis(): TransformNode;
  49521. /** Gets the node hierarchy used to render z-axis */
  49522. get zAxis(): TransformNode;
  49523. /**
  49524. * Creates a new AxesViewer
  49525. * @param scene defines the hosting scene
  49526. * @param scaleLines defines a number used to scale line length (1 by default)
  49527. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49528. * @param xAxis defines the node hierarchy used to render the x-axis
  49529. * @param yAxis defines the node hierarchy used to render the y-axis
  49530. * @param zAxis defines the node hierarchy used to render the z-axis
  49531. */
  49532. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49533. /**
  49534. * Force the viewer to update
  49535. * @param position defines the position of the viewer
  49536. * @param xaxis defines the x axis of the viewer
  49537. * @param yaxis defines the y axis of the viewer
  49538. * @param zaxis defines the z axis of the viewer
  49539. */
  49540. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49541. /**
  49542. * Creates an instance of this axes viewer.
  49543. * @returns a new axes viewer with instanced meshes
  49544. */
  49545. createInstance(): AxesViewer;
  49546. /** Releases resources */
  49547. dispose(): void;
  49548. private static _SetRenderingGroupId;
  49549. }
  49550. }
  49551. declare module BABYLON.Debug {
  49552. /**
  49553. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49554. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49555. */
  49556. export class BoneAxesViewer extends AxesViewer {
  49557. /**
  49558. * Gets or sets the target mesh where to display the axes viewer
  49559. */
  49560. mesh: Nullable<Mesh>;
  49561. /**
  49562. * Gets or sets the target bone where to display the axes viewer
  49563. */
  49564. bone: Nullable<Bone>;
  49565. /** Gets current position */
  49566. pos: Vector3;
  49567. /** Gets direction of X axis */
  49568. xaxis: Vector3;
  49569. /** Gets direction of Y axis */
  49570. yaxis: Vector3;
  49571. /** Gets direction of Z axis */
  49572. zaxis: Vector3;
  49573. /**
  49574. * Creates a new BoneAxesViewer
  49575. * @param scene defines the hosting scene
  49576. * @param bone defines the target bone
  49577. * @param mesh defines the target mesh
  49578. * @param scaleLines defines a scaling factor for line length (1 by default)
  49579. */
  49580. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49581. /**
  49582. * Force the viewer to update
  49583. */
  49584. update(): void;
  49585. /** Releases resources */
  49586. dispose(): void;
  49587. }
  49588. }
  49589. declare module BABYLON {
  49590. /**
  49591. * Interface used to define scene explorer extensibility option
  49592. */
  49593. export interface IExplorerExtensibilityOption {
  49594. /**
  49595. * Define the option label
  49596. */
  49597. label: string;
  49598. /**
  49599. * Defines the action to execute on click
  49600. */
  49601. action: (entity: any) => void;
  49602. }
  49603. /**
  49604. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49605. */
  49606. export interface IExplorerExtensibilityGroup {
  49607. /**
  49608. * Defines a predicate to test if a given type mut be extended
  49609. */
  49610. predicate: (entity: any) => boolean;
  49611. /**
  49612. * Gets the list of options added to a type
  49613. */
  49614. entries: IExplorerExtensibilityOption[];
  49615. }
  49616. /**
  49617. * Interface used to define the options to use to create the Inspector
  49618. */
  49619. export interface IInspectorOptions {
  49620. /**
  49621. * Display in overlay mode (default: false)
  49622. */
  49623. overlay?: boolean;
  49624. /**
  49625. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49626. */
  49627. globalRoot?: HTMLElement;
  49628. /**
  49629. * Display the Scene explorer
  49630. */
  49631. showExplorer?: boolean;
  49632. /**
  49633. * Display the property inspector
  49634. */
  49635. showInspector?: boolean;
  49636. /**
  49637. * Display in embed mode (both panes on the right)
  49638. */
  49639. embedMode?: boolean;
  49640. /**
  49641. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49642. */
  49643. handleResize?: boolean;
  49644. /**
  49645. * Allow the panes to popup (default: true)
  49646. */
  49647. enablePopup?: boolean;
  49648. /**
  49649. * Allow the panes to be closed by users (default: true)
  49650. */
  49651. enableClose?: boolean;
  49652. /**
  49653. * Optional list of extensibility entries
  49654. */
  49655. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49656. /**
  49657. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49658. */
  49659. inspectorURL?: string;
  49660. /**
  49661. * Optional initial tab (default to DebugLayerTab.Properties)
  49662. */
  49663. initialTab?: DebugLayerTab;
  49664. }
  49665. interface Scene {
  49666. /**
  49667. * @hidden
  49668. * Backing field
  49669. */
  49670. _debugLayer: DebugLayer;
  49671. /**
  49672. * Gets the debug layer (aka Inspector) associated with the scene
  49673. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49674. */
  49675. debugLayer: DebugLayer;
  49676. }
  49677. /**
  49678. * Enum of inspector action tab
  49679. */
  49680. export enum DebugLayerTab {
  49681. /**
  49682. * Properties tag (default)
  49683. */
  49684. Properties = 0,
  49685. /**
  49686. * Debug tab
  49687. */
  49688. Debug = 1,
  49689. /**
  49690. * Statistics tab
  49691. */
  49692. Statistics = 2,
  49693. /**
  49694. * Tools tab
  49695. */
  49696. Tools = 3,
  49697. /**
  49698. * Settings tab
  49699. */
  49700. Settings = 4
  49701. }
  49702. /**
  49703. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49704. * what is happening in your scene
  49705. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49706. */
  49707. export class DebugLayer {
  49708. /**
  49709. * Define the url to get the inspector script from.
  49710. * By default it uses the babylonjs CDN.
  49711. * @ignoreNaming
  49712. */
  49713. static InspectorURL: string;
  49714. private _scene;
  49715. private BJSINSPECTOR;
  49716. private _onPropertyChangedObservable?;
  49717. /**
  49718. * Observable triggered when a property is changed through the inspector.
  49719. */
  49720. get onPropertyChangedObservable(): any;
  49721. /**
  49722. * Instantiates a new debug layer.
  49723. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49724. * what is happening in your scene
  49725. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49726. * @param scene Defines the scene to inspect
  49727. */
  49728. constructor(scene: Scene);
  49729. /** Creates the inspector window. */
  49730. private _createInspector;
  49731. /**
  49732. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49733. * @param entity defines the entity to select
  49734. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49735. */
  49736. select(entity: any, lineContainerTitles?: string | string[]): void;
  49737. /** Get the inspector from bundle or global */
  49738. private _getGlobalInspector;
  49739. /**
  49740. * Get if the inspector is visible or not.
  49741. * @returns true if visible otherwise, false
  49742. */
  49743. isVisible(): boolean;
  49744. /**
  49745. * Hide the inspector and close its window.
  49746. */
  49747. hide(): void;
  49748. /**
  49749. * Update the scene in the inspector
  49750. */
  49751. setAsActiveScene(): void;
  49752. /**
  49753. * Launch the debugLayer.
  49754. * @param config Define the configuration of the inspector
  49755. * @return a promise fulfilled when the debug layer is visible
  49756. */
  49757. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49758. }
  49759. }
  49760. declare module BABYLON {
  49761. /**
  49762. * Class containing static functions to help procedurally build meshes
  49763. */
  49764. export class BoxBuilder {
  49765. /**
  49766. * Creates a box mesh
  49767. * * The parameter `size` sets the size (float) of each box side (default 1)
  49768. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49769. * * 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)
  49770. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49772. * * 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
  49773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49774. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49775. * @param name defines the name of the mesh
  49776. * @param options defines the options used to create the mesh
  49777. * @param scene defines the hosting scene
  49778. * @returns the box mesh
  49779. */
  49780. static CreateBox(name: string, options: {
  49781. size?: number;
  49782. width?: number;
  49783. height?: number;
  49784. depth?: number;
  49785. faceUV?: Vector4[];
  49786. faceColors?: Color4[];
  49787. sideOrientation?: number;
  49788. frontUVs?: Vector4;
  49789. backUVs?: Vector4;
  49790. wrap?: boolean;
  49791. topBaseAt?: number;
  49792. bottomBaseAt?: number;
  49793. updatable?: boolean;
  49794. }, scene?: Nullable<Scene>): Mesh;
  49795. }
  49796. }
  49797. declare module BABYLON.Debug {
  49798. /**
  49799. * Used to show the physics impostor around the specific mesh
  49800. */
  49801. export class PhysicsViewer {
  49802. /** @hidden */
  49803. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49804. /** @hidden */
  49805. protected _meshes: Array<Nullable<AbstractMesh>>;
  49806. /** @hidden */
  49807. protected _scene: Nullable<Scene>;
  49808. /** @hidden */
  49809. protected _numMeshes: number;
  49810. /** @hidden */
  49811. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49812. private _renderFunction;
  49813. private _utilityLayer;
  49814. private _debugBoxMesh;
  49815. private _debugSphereMesh;
  49816. private _debugCylinderMesh;
  49817. private _debugMaterial;
  49818. private _debugMeshMeshes;
  49819. /**
  49820. * Creates a new PhysicsViewer
  49821. * @param scene defines the hosting scene
  49822. */
  49823. constructor(scene: Scene);
  49824. /** @hidden */
  49825. protected _updateDebugMeshes(): void;
  49826. /**
  49827. * Renders a specified physic impostor
  49828. * @param impostor defines the impostor to render
  49829. * @param targetMesh defines the mesh represented by the impostor
  49830. * @returns the new debug mesh used to render the impostor
  49831. */
  49832. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49833. /**
  49834. * Hides a specified physic impostor
  49835. * @param impostor defines the impostor to hide
  49836. */
  49837. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49838. private _getDebugMaterial;
  49839. private _getDebugBoxMesh;
  49840. private _getDebugSphereMesh;
  49841. private _getDebugCylinderMesh;
  49842. private _getDebugMeshMesh;
  49843. private _getDebugMesh;
  49844. /** Releases all resources */
  49845. dispose(): void;
  49846. }
  49847. }
  49848. declare module BABYLON {
  49849. /**
  49850. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49851. * in order to better appreciate the issue one might have.
  49852. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49853. */
  49854. export class RayHelper {
  49855. /**
  49856. * Defines the ray we are currently tryin to visualize.
  49857. */
  49858. ray: Nullable<Ray>;
  49859. private _renderPoints;
  49860. private _renderLine;
  49861. private _renderFunction;
  49862. private _scene;
  49863. private _updateToMeshFunction;
  49864. private _attachedToMesh;
  49865. private _meshSpaceDirection;
  49866. private _meshSpaceOrigin;
  49867. /**
  49868. * Helper function to create a colored helper in a scene in one line.
  49869. * @param ray Defines the ray we are currently tryin to visualize
  49870. * @param scene Defines the scene the ray is used in
  49871. * @param color Defines the color we want to see the ray in
  49872. * @returns The newly created ray helper.
  49873. */
  49874. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49875. /**
  49876. * Instantiate a new ray helper.
  49877. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49878. * in order to better appreciate the issue one might have.
  49879. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49880. * @param ray Defines the ray we are currently tryin to visualize
  49881. */
  49882. constructor(ray: Ray);
  49883. /**
  49884. * Shows the ray we are willing to debug.
  49885. * @param scene Defines the scene the ray needs to be rendered in
  49886. * @param color Defines the color the ray needs to be rendered in
  49887. */
  49888. show(scene: Scene, color?: Color3): void;
  49889. /**
  49890. * Hides the ray we are debugging.
  49891. */
  49892. hide(): void;
  49893. private _render;
  49894. /**
  49895. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49896. * @param mesh Defines the mesh we want the helper attached to
  49897. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49898. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49899. * @param length Defines the length of the ray
  49900. */
  49901. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49902. /**
  49903. * Detach the ray helper from the mesh it has previously been attached to.
  49904. */
  49905. detachFromMesh(): void;
  49906. private _updateToMesh;
  49907. /**
  49908. * Dispose the helper and release its associated resources.
  49909. */
  49910. dispose(): void;
  49911. }
  49912. }
  49913. declare module BABYLON.Debug {
  49914. /**
  49915. * Class used to render a debug view of a given skeleton
  49916. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49917. */
  49918. export class SkeletonViewer {
  49919. /** defines the skeleton to render */
  49920. skeleton: Skeleton;
  49921. /** defines the mesh attached to the skeleton */
  49922. mesh: AbstractMesh;
  49923. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49924. autoUpdateBonesMatrices: boolean;
  49925. /** defines the rendering group id to use with the viewer */
  49926. renderingGroupId: number;
  49927. /** Gets or sets the color used to render the skeleton */
  49928. color: Color3;
  49929. private _scene;
  49930. private _debugLines;
  49931. private _debugMesh;
  49932. private _isEnabled;
  49933. private _renderFunction;
  49934. private _utilityLayer;
  49935. /**
  49936. * Returns the mesh used to render the bones
  49937. */
  49938. get debugMesh(): Nullable<LinesMesh>;
  49939. /**
  49940. * Creates a new SkeletonViewer
  49941. * @param skeleton defines the skeleton to render
  49942. * @param mesh defines the mesh attached to the skeleton
  49943. * @param scene defines the hosting scene
  49944. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49945. * @param renderingGroupId defines the rendering group id to use with the viewer
  49946. */
  49947. constructor(
  49948. /** defines the skeleton to render */
  49949. skeleton: Skeleton,
  49950. /** defines the mesh attached to the skeleton */
  49951. mesh: AbstractMesh, scene: Scene,
  49952. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49953. autoUpdateBonesMatrices?: boolean,
  49954. /** defines the rendering group id to use with the viewer */
  49955. renderingGroupId?: number);
  49956. /** Gets or sets a boolean indicating if the viewer is enabled */
  49957. set isEnabled(value: boolean);
  49958. get isEnabled(): boolean;
  49959. private _getBonePosition;
  49960. private _getLinesForBonesWithLength;
  49961. private _getLinesForBonesNoLength;
  49962. /** Update the viewer to sync with current skeleton state */
  49963. update(): void;
  49964. /** Release associated resources */
  49965. dispose(): void;
  49966. }
  49967. }
  49968. declare module BABYLON {
  49969. /**
  49970. * Enum for Device Types
  49971. */
  49972. export enum DeviceType {
  49973. /** Generic */
  49974. Generic = 0,
  49975. /** Keyboard */
  49976. Keyboard = 1,
  49977. /** Mouse */
  49978. Mouse = 2,
  49979. /** Touch Pointers */
  49980. Touch = 3,
  49981. /** PS4 Dual Shock */
  49982. DualShock = 4,
  49983. /** Xbox */
  49984. Xbox = 5,
  49985. /** Switch Controller */
  49986. Switch = 6
  49987. }
  49988. /**
  49989. * Enum for All Pointers (Touch/Mouse)
  49990. */
  49991. export enum PointerInput {
  49992. /** Horizontal Axis */
  49993. Horizontal = 0,
  49994. /** Vertical Axis */
  49995. Vertical = 1,
  49996. /** Left Click or Touch */
  49997. LeftClick = 2,
  49998. /** Middle Click */
  49999. MiddleClick = 3,
  50000. /** Right Click */
  50001. RightClick = 4,
  50002. /** Browser Back */
  50003. BrowserBack = 5,
  50004. /** Browser Forward */
  50005. BrowserForward = 6
  50006. }
  50007. /**
  50008. * Enum for Dual Shock Gamepad
  50009. */
  50010. export enum DualShockInput {
  50011. /** Cross */
  50012. Cross = 0,
  50013. /** Circle */
  50014. Circle = 1,
  50015. /** Square */
  50016. Square = 2,
  50017. /** Triangle */
  50018. Triangle = 3,
  50019. /** L1 */
  50020. L1 = 4,
  50021. /** R1 */
  50022. R1 = 5,
  50023. /** L2 */
  50024. L2 = 6,
  50025. /** R2 */
  50026. R2 = 7,
  50027. /** Share */
  50028. Share = 8,
  50029. /** Options */
  50030. Options = 9,
  50031. /** L3 */
  50032. L3 = 10,
  50033. /** R3 */
  50034. R3 = 11,
  50035. /** DPadUp */
  50036. DPadUp = 12,
  50037. /** DPadDown */
  50038. DPadDown = 13,
  50039. /** DPadLeft */
  50040. DPadLeft = 14,
  50041. /** DRight */
  50042. DPadRight = 15,
  50043. /** Home */
  50044. Home = 16,
  50045. /** TouchPad */
  50046. TouchPad = 17,
  50047. /** LStickXAxis */
  50048. LStickXAxis = 18,
  50049. /** LStickYAxis */
  50050. LStickYAxis = 19,
  50051. /** RStickXAxis */
  50052. RStickXAxis = 20,
  50053. /** RStickYAxis */
  50054. RStickYAxis = 21
  50055. }
  50056. /**
  50057. * Enum for Xbox Gamepad
  50058. */
  50059. export enum XboxInput {
  50060. /** A */
  50061. A = 0,
  50062. /** B */
  50063. B = 1,
  50064. /** X */
  50065. X = 2,
  50066. /** Y */
  50067. Y = 3,
  50068. /** LB */
  50069. LB = 4,
  50070. /** RB */
  50071. RB = 5,
  50072. /** LT */
  50073. LT = 6,
  50074. /** RT */
  50075. RT = 7,
  50076. /** Back */
  50077. Back = 8,
  50078. /** Start */
  50079. Start = 9,
  50080. /** LS */
  50081. LS = 10,
  50082. /** RS */
  50083. RS = 11,
  50084. /** DPadUp */
  50085. DPadUp = 12,
  50086. /** DPadDown */
  50087. DPadDown = 13,
  50088. /** DPadLeft */
  50089. DPadLeft = 14,
  50090. /** DRight */
  50091. DPadRight = 15,
  50092. /** Home */
  50093. Home = 16,
  50094. /** LStickXAxis */
  50095. LStickXAxis = 17,
  50096. /** LStickYAxis */
  50097. LStickYAxis = 18,
  50098. /** RStickXAxis */
  50099. RStickXAxis = 19,
  50100. /** RStickYAxis */
  50101. RStickYAxis = 20
  50102. }
  50103. /**
  50104. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50105. */
  50106. export enum SwitchInput {
  50107. /** B */
  50108. B = 0,
  50109. /** A */
  50110. A = 1,
  50111. /** Y */
  50112. Y = 2,
  50113. /** X */
  50114. X = 3,
  50115. /** L */
  50116. L = 4,
  50117. /** R */
  50118. R = 5,
  50119. /** ZL */
  50120. ZL = 6,
  50121. /** ZR */
  50122. ZR = 7,
  50123. /** Minus */
  50124. Minus = 8,
  50125. /** Plus */
  50126. Plus = 9,
  50127. /** LS */
  50128. LS = 10,
  50129. /** RS */
  50130. RS = 11,
  50131. /** DPadUp */
  50132. DPadUp = 12,
  50133. /** DPadDown */
  50134. DPadDown = 13,
  50135. /** DPadLeft */
  50136. DPadLeft = 14,
  50137. /** DRight */
  50138. DPadRight = 15,
  50139. /** Home */
  50140. Home = 16,
  50141. /** Capture */
  50142. Capture = 17,
  50143. /** LStickXAxis */
  50144. LStickXAxis = 18,
  50145. /** LStickYAxis */
  50146. LStickYAxis = 19,
  50147. /** RStickXAxis */
  50148. RStickXAxis = 20,
  50149. /** RStickYAxis */
  50150. RStickYAxis = 21
  50151. }
  50152. }
  50153. declare module BABYLON {
  50154. /**
  50155. * This class will take all inputs from Keyboard, Pointer, and
  50156. * any Gamepads and provide a polling system that all devices
  50157. * will use. This class assumes that there will only be one
  50158. * pointer device and one keyboard.
  50159. */
  50160. export class DeviceInputSystem implements IDisposable {
  50161. /**
  50162. * Callback to be triggered when a device is connected
  50163. */
  50164. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50165. /**
  50166. * Callback to be triggered when a device is disconnected
  50167. */
  50168. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50169. /**
  50170. * Callback to be triggered when event driven input is updated
  50171. */
  50172. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50173. private _inputs;
  50174. private _gamepads;
  50175. private _keyboardActive;
  50176. private _pointerActive;
  50177. private _elementToAttachTo;
  50178. private _keyboardDownEvent;
  50179. private _keyboardUpEvent;
  50180. private _pointerMoveEvent;
  50181. private _pointerDownEvent;
  50182. private _pointerUpEvent;
  50183. private _gamepadConnectedEvent;
  50184. private _gamepadDisconnectedEvent;
  50185. private static _MAX_KEYCODES;
  50186. private static _MAX_POINTER_INPUTS;
  50187. private constructor();
  50188. /**
  50189. * Creates a new DeviceInputSystem instance
  50190. * @param engine Engine to pull input element from
  50191. * @returns The new instance
  50192. */
  50193. static Create(engine: Engine): DeviceInputSystem;
  50194. /**
  50195. * Checks for current device input value, given an id and input index
  50196. * @param deviceName Id of connected device
  50197. * @param inputIndex Index of device input
  50198. * @returns Current value of input
  50199. */
  50200. /**
  50201. * Checks for current device input value, given an id and input index
  50202. * @param deviceType Enum specifiying device type
  50203. * @param deviceSlot "Slot" or index that device is referenced in
  50204. * @param inputIndex Id of input to be checked
  50205. * @returns Current value of input
  50206. */
  50207. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50208. /**
  50209. * Dispose of all the eventlisteners
  50210. */
  50211. dispose(): void;
  50212. /**
  50213. * Add device and inputs to device array
  50214. * @param deviceType Enum specifiying device type
  50215. * @param deviceSlot "Slot" or index that device is referenced in
  50216. * @param numberOfInputs Number of input entries to create for given device
  50217. */
  50218. private _registerDevice;
  50219. /**
  50220. * Given a specific device name, remove that device from the device map
  50221. * @param deviceType Enum specifiying device type
  50222. * @param deviceSlot "Slot" or index that device is referenced in
  50223. */
  50224. private _unregisterDevice;
  50225. /**
  50226. * Handle all actions that come from keyboard interaction
  50227. */
  50228. private _handleKeyActions;
  50229. /**
  50230. * Handle all actions that come from pointer interaction
  50231. */
  50232. private _handlePointerActions;
  50233. /**
  50234. * Handle all actions that come from gamepad interaction
  50235. */
  50236. private _handleGamepadActions;
  50237. /**
  50238. * Update all non-event based devices with each frame
  50239. * @param deviceType Enum specifiying device type
  50240. * @param deviceSlot "Slot" or index that device is referenced in
  50241. * @param inputIndex Id of input to be checked
  50242. */
  50243. private _updateDevice;
  50244. /**
  50245. * Gets DeviceType from the device name
  50246. * @param deviceName Name of Device from DeviceInputSystem
  50247. * @returns DeviceType enum value
  50248. */
  50249. private _getGamepadDeviceType;
  50250. }
  50251. }
  50252. declare module BABYLON {
  50253. /**
  50254. * Type to handle enforcement of inputs
  50255. */
  50256. 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;
  50257. }
  50258. declare module BABYLON {
  50259. /**
  50260. * Class that handles all input for a specific device
  50261. */
  50262. export class DeviceSource<T extends DeviceType> {
  50263. /** Type of device */
  50264. readonly deviceType: DeviceType;
  50265. /** "Slot" or index that device is referenced in */
  50266. readonly deviceSlot: number;
  50267. /**
  50268. * Observable to handle device input changes per device
  50269. */
  50270. readonly onInputChangedObservable: Observable<{
  50271. inputIndex: DeviceInput<T>;
  50272. previousState: Nullable<number>;
  50273. currentState: Nullable<number>;
  50274. }>;
  50275. private readonly _deviceInputSystem;
  50276. /**
  50277. * Default Constructor
  50278. * @param deviceInputSystem Reference to DeviceInputSystem
  50279. * @param deviceType Type of device
  50280. * @param deviceSlot "Slot" or index that device is referenced in
  50281. */
  50282. constructor(deviceInputSystem: DeviceInputSystem,
  50283. /** Type of device */
  50284. deviceType: DeviceType,
  50285. /** "Slot" or index that device is referenced in */
  50286. deviceSlot?: number);
  50287. /**
  50288. * Get input for specific input
  50289. * @param inputIndex index of specific input on device
  50290. * @returns Input value from DeviceInputSystem
  50291. */
  50292. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50293. }
  50294. /**
  50295. * Class to keep track of devices
  50296. */
  50297. export class DeviceSourceManager implements IDisposable {
  50298. /**
  50299. * Observable to be triggered when before a device is connected
  50300. */
  50301. readonly onBeforeDeviceConnectedObservable: Observable<{
  50302. deviceType: DeviceType;
  50303. deviceSlot: number;
  50304. }>;
  50305. /**
  50306. * Observable to be triggered when before a device is disconnected
  50307. */
  50308. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50309. deviceType: DeviceType;
  50310. deviceSlot: number;
  50311. }>;
  50312. /**
  50313. * Observable to be triggered when after a device is connected
  50314. */
  50315. readonly onAfterDeviceConnectedObservable: Observable<{
  50316. deviceType: DeviceType;
  50317. deviceSlot: number;
  50318. }>;
  50319. /**
  50320. * Observable to be triggered when after a device is disconnected
  50321. */
  50322. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50323. deviceType: DeviceType;
  50324. deviceSlot: number;
  50325. }>;
  50326. private readonly _devices;
  50327. private readonly _firstDevice;
  50328. private readonly _deviceInputSystem;
  50329. /**
  50330. * Default Constructor
  50331. * @param engine engine to pull input element from
  50332. */
  50333. constructor(engine: Engine);
  50334. /**
  50335. * Gets a DeviceSource, given a type and slot
  50336. * @param deviceType Enum specifying device type
  50337. * @param deviceSlot "Slot" or index that device is referenced in
  50338. * @returns DeviceSource object
  50339. */
  50340. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50341. /**
  50342. * Gets an array of DeviceSource objects for a given device type
  50343. * @param deviceType Enum specifying device type
  50344. * @returns Array of DeviceSource objects
  50345. */
  50346. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50347. /**
  50348. * Dispose of DeviceInputSystem and other parts
  50349. */
  50350. dispose(): void;
  50351. /**
  50352. * Function to add device name to device list
  50353. * @param deviceType Enum specifying device type
  50354. * @param deviceSlot "Slot" or index that device is referenced in
  50355. */
  50356. private _addDevice;
  50357. /**
  50358. * Function to remove device name to device list
  50359. * @param deviceType Enum specifying device type
  50360. * @param deviceSlot "Slot" or index that device is referenced in
  50361. */
  50362. private _removeDevice;
  50363. /**
  50364. * Updates array storing first connected device of each type
  50365. * @param type Type of Device
  50366. */
  50367. private _updateFirstDevices;
  50368. }
  50369. }
  50370. declare module BABYLON {
  50371. /**
  50372. * Options to create the null engine
  50373. */
  50374. export class NullEngineOptions {
  50375. /**
  50376. * Render width (Default: 512)
  50377. */
  50378. renderWidth: number;
  50379. /**
  50380. * Render height (Default: 256)
  50381. */
  50382. renderHeight: number;
  50383. /**
  50384. * Texture size (Default: 512)
  50385. */
  50386. textureSize: number;
  50387. /**
  50388. * If delta time between frames should be constant
  50389. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50390. */
  50391. deterministicLockstep: boolean;
  50392. /**
  50393. * Maximum about of steps between frames (Default: 4)
  50394. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50395. */
  50396. lockstepMaxSteps: number;
  50397. }
  50398. /**
  50399. * The null engine class provides support for headless version of babylon.js.
  50400. * This can be used in server side scenario or for testing purposes
  50401. */
  50402. export class NullEngine extends Engine {
  50403. private _options;
  50404. /**
  50405. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50406. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50407. * @returns true if engine is in deterministic lock step mode
  50408. */
  50409. isDeterministicLockStep(): boolean;
  50410. /**
  50411. * Gets the max steps when engine is running in deterministic lock step
  50412. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50413. * @returns the max steps
  50414. */
  50415. getLockstepMaxSteps(): number;
  50416. /**
  50417. * Gets the current hardware scaling level.
  50418. * By default the hardware scaling level is computed from the window device ratio.
  50419. * 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.
  50420. * @returns a number indicating the current hardware scaling level
  50421. */
  50422. getHardwareScalingLevel(): number;
  50423. constructor(options?: NullEngineOptions);
  50424. /**
  50425. * Creates a vertex buffer
  50426. * @param vertices the data for the vertex buffer
  50427. * @returns the new WebGL static buffer
  50428. */
  50429. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50430. /**
  50431. * Creates a new index buffer
  50432. * @param indices defines the content of the index buffer
  50433. * @param updatable defines if the index buffer must be updatable
  50434. * @returns a new webGL buffer
  50435. */
  50436. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50437. /**
  50438. * Clear the current render buffer or the current render target (if any is set up)
  50439. * @param color defines the color to use
  50440. * @param backBuffer defines if the back buffer must be cleared
  50441. * @param depth defines if the depth buffer must be cleared
  50442. * @param stencil defines if the stencil buffer must be cleared
  50443. */
  50444. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50445. /**
  50446. * Gets the current render width
  50447. * @param useScreen defines if screen size must be used (or the current render target if any)
  50448. * @returns a number defining the current render width
  50449. */
  50450. getRenderWidth(useScreen?: boolean): number;
  50451. /**
  50452. * Gets the current render height
  50453. * @param useScreen defines if screen size must be used (or the current render target if any)
  50454. * @returns a number defining the current render height
  50455. */
  50456. getRenderHeight(useScreen?: boolean): number;
  50457. /**
  50458. * Set the WebGL's viewport
  50459. * @param viewport defines the viewport element to be used
  50460. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50461. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50462. */
  50463. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50464. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50465. /**
  50466. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50467. * @param pipelineContext defines the pipeline context to use
  50468. * @param uniformsNames defines the list of uniform names
  50469. * @returns an array of webGL uniform locations
  50470. */
  50471. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50472. /**
  50473. * Gets the lsit of active attributes for a given webGL program
  50474. * @param pipelineContext defines the pipeline context to use
  50475. * @param attributesNames defines the list of attribute names to get
  50476. * @returns an array of indices indicating the offset of each attribute
  50477. */
  50478. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50479. /**
  50480. * Binds an effect to the webGL context
  50481. * @param effect defines the effect to bind
  50482. */
  50483. bindSamplers(effect: Effect): void;
  50484. /**
  50485. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50486. * @param effect defines the effect to activate
  50487. */
  50488. enableEffect(effect: Effect): void;
  50489. /**
  50490. * Set various states to the webGL context
  50491. * @param culling defines backface culling state
  50492. * @param zOffset defines the value to apply to zOffset (0 by default)
  50493. * @param force defines if states must be applied even if cache is up to date
  50494. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50495. */
  50496. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50497. /**
  50498. * Set the value of an uniform to an array of int32
  50499. * @param uniform defines the webGL uniform location where to store the value
  50500. * @param array defines the array of int32 to store
  50501. */
  50502. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50503. /**
  50504. * Set the value of an uniform to an array of int32 (stored as vec2)
  50505. * @param uniform defines the webGL uniform location where to store the value
  50506. * @param array defines the array of int32 to store
  50507. */
  50508. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50509. /**
  50510. * Set the value of an uniform to an array of int32 (stored as vec3)
  50511. * @param uniform defines the webGL uniform location where to store the value
  50512. * @param array defines the array of int32 to store
  50513. */
  50514. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50515. /**
  50516. * Set the value of an uniform to an array of int32 (stored as vec4)
  50517. * @param uniform defines the webGL uniform location where to store the value
  50518. * @param array defines the array of int32 to store
  50519. */
  50520. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50521. /**
  50522. * Set the value of an uniform to an array of float32
  50523. * @param uniform defines the webGL uniform location where to store the value
  50524. * @param array defines the array of float32 to store
  50525. */
  50526. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50527. /**
  50528. * Set the value of an uniform to an array of float32 (stored as vec2)
  50529. * @param uniform defines the webGL uniform location where to store the value
  50530. * @param array defines the array of float32 to store
  50531. */
  50532. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50533. /**
  50534. * Set the value of an uniform to an array of float32 (stored as vec3)
  50535. * @param uniform defines the webGL uniform location where to store the value
  50536. * @param array defines the array of float32 to store
  50537. */
  50538. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50539. /**
  50540. * Set the value of an uniform to an array of float32 (stored as vec4)
  50541. * @param uniform defines the webGL uniform location where to store the value
  50542. * @param array defines the array of float32 to store
  50543. */
  50544. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50545. /**
  50546. * Set the value of an uniform to an array of number
  50547. * @param uniform defines the webGL uniform location where to store the value
  50548. * @param array defines the array of number to store
  50549. */
  50550. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50551. /**
  50552. * Set the value of an uniform to an array of number (stored as vec2)
  50553. * @param uniform defines the webGL uniform location where to store the value
  50554. * @param array defines the array of number to store
  50555. */
  50556. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50557. /**
  50558. * Set the value of an uniform to an array of number (stored as vec3)
  50559. * @param uniform defines the webGL uniform location where to store the value
  50560. * @param array defines the array of number to store
  50561. */
  50562. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50563. /**
  50564. * Set the value of an uniform to an array of number (stored as vec4)
  50565. * @param uniform defines the webGL uniform location where to store the value
  50566. * @param array defines the array of number to store
  50567. */
  50568. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50569. /**
  50570. * Set the value of an uniform to an array of float32 (stored as matrices)
  50571. * @param uniform defines the webGL uniform location where to store the value
  50572. * @param matrices defines the array of float32 to store
  50573. */
  50574. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50575. /**
  50576. * Set the value of an uniform to a matrix (3x3)
  50577. * @param uniform defines the webGL uniform location where to store the value
  50578. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50579. */
  50580. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50581. /**
  50582. * Set the value of an uniform to a matrix (2x2)
  50583. * @param uniform defines the webGL uniform location where to store the value
  50584. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50585. */
  50586. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50587. /**
  50588. * Set the value of an uniform to a number (float)
  50589. * @param uniform defines the webGL uniform location where to store the value
  50590. * @param value defines the float number to store
  50591. */
  50592. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50593. /**
  50594. * Set the value of an uniform to a vec2
  50595. * @param uniform defines the webGL uniform location where to store the value
  50596. * @param x defines the 1st component of the value
  50597. * @param y defines the 2nd component of the value
  50598. */
  50599. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50600. /**
  50601. * Set the value of an uniform to a vec3
  50602. * @param uniform defines the webGL uniform location where to store the value
  50603. * @param x defines the 1st component of the value
  50604. * @param y defines the 2nd component of the value
  50605. * @param z defines the 3rd component of the value
  50606. */
  50607. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50608. /**
  50609. * Set the value of an uniform to a boolean
  50610. * @param uniform defines the webGL uniform location where to store the value
  50611. * @param bool defines the boolean to store
  50612. */
  50613. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50614. /**
  50615. * Set the value of an uniform to a vec4
  50616. * @param uniform defines the webGL uniform location where to store the value
  50617. * @param x defines the 1st component of the value
  50618. * @param y defines the 2nd component of the value
  50619. * @param z defines the 3rd component of the value
  50620. * @param w defines the 4th component of the value
  50621. */
  50622. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50623. /**
  50624. * Sets the current alpha mode
  50625. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50626. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50627. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50628. */
  50629. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50630. /**
  50631. * Bind webGl buffers directly to the webGL context
  50632. * @param vertexBuffers defines the vertex buffer to bind
  50633. * @param indexBuffer defines the index buffer to bind
  50634. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50635. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50636. * @param effect defines the effect associated with the vertex buffer
  50637. */
  50638. bindBuffers(vertexBuffers: {
  50639. [key: string]: VertexBuffer;
  50640. }, indexBuffer: DataBuffer, effect: Effect): void;
  50641. /**
  50642. * Force the entire cache to be cleared
  50643. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50644. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50645. */
  50646. wipeCaches(bruteForce?: boolean): void;
  50647. /**
  50648. * Send a draw order
  50649. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50650. * @param indexStart defines the starting index
  50651. * @param indexCount defines the number of index to draw
  50652. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50653. */
  50654. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50655. /**
  50656. * Draw a list of indexed primitives
  50657. * @param fillMode defines the primitive to use
  50658. * @param indexStart defines the starting index
  50659. * @param indexCount defines the number of index to draw
  50660. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50661. */
  50662. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50663. /**
  50664. * Draw a list of unindexed primitives
  50665. * @param fillMode defines the primitive to use
  50666. * @param verticesStart defines the index of first vertex to draw
  50667. * @param verticesCount defines the count of vertices to draw
  50668. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50669. */
  50670. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50671. /** @hidden */
  50672. _createTexture(): WebGLTexture;
  50673. /** @hidden */
  50674. _releaseTexture(texture: InternalTexture): void;
  50675. /**
  50676. * Usually called from Texture.ts.
  50677. * Passed information to create a WebGLTexture
  50678. * @param urlArg defines a value which contains one of the following:
  50679. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50680. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50681. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50682. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50683. * @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)
  50684. * @param scene needed for loading to the correct scene
  50685. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50686. * @param onLoad optional callback to be called upon successful completion
  50687. * @param onError optional callback to be called upon failure
  50688. * @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
  50689. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50690. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50691. * @param forcedExtension defines the extension to use to pick the right loader
  50692. * @param mimeType defines an optional mime type
  50693. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50694. */
  50695. 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;
  50696. /**
  50697. * Creates a new render target texture
  50698. * @param size defines the size of the texture
  50699. * @param options defines the options used to create the texture
  50700. * @returns a new render target texture stored in an InternalTexture
  50701. */
  50702. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50703. /**
  50704. * Update the sampling mode of a given texture
  50705. * @param samplingMode defines the required sampling mode
  50706. * @param texture defines the texture to update
  50707. */
  50708. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50709. /**
  50710. * Binds the frame buffer to the specified texture.
  50711. * @param texture The texture to render to or null for the default canvas
  50712. * @param faceIndex The face of the texture to render to in case of cube texture
  50713. * @param requiredWidth The width of the target to render to
  50714. * @param requiredHeight The height of the target to render to
  50715. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50716. * @param lodLevel defines le lod level to bind to the frame buffer
  50717. */
  50718. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50719. /**
  50720. * Unbind the current render target texture from the webGL context
  50721. * @param texture defines the render target texture to unbind
  50722. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50723. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50724. */
  50725. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50726. /**
  50727. * Creates a dynamic vertex buffer
  50728. * @param vertices the data for the dynamic vertex buffer
  50729. * @returns the new WebGL dynamic buffer
  50730. */
  50731. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50732. /**
  50733. * Update the content of a dynamic texture
  50734. * @param texture defines the texture to update
  50735. * @param canvas defines the canvas containing the source
  50736. * @param invertY defines if data must be stored with Y axis inverted
  50737. * @param premulAlpha defines if alpha is stored as premultiplied
  50738. * @param format defines the format of the data
  50739. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50740. */
  50741. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50742. /**
  50743. * Gets a boolean indicating if all created effects are ready
  50744. * @returns true if all effects are ready
  50745. */
  50746. areAllEffectsReady(): boolean;
  50747. /**
  50748. * @hidden
  50749. * Get the current error code of the webGL context
  50750. * @returns the error code
  50751. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50752. */
  50753. getError(): number;
  50754. /** @hidden */
  50755. _getUnpackAlignement(): number;
  50756. /** @hidden */
  50757. _unpackFlipY(value: boolean): void;
  50758. /**
  50759. * Update a dynamic index buffer
  50760. * @param indexBuffer defines the target index buffer
  50761. * @param indices defines the data to update
  50762. * @param offset defines the offset in the target index buffer where update should start
  50763. */
  50764. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50765. /**
  50766. * Updates a dynamic vertex buffer.
  50767. * @param vertexBuffer the vertex buffer to update
  50768. * @param vertices the data used to update the vertex buffer
  50769. * @param byteOffset the byte offset of the data (optional)
  50770. * @param byteLength the byte length of the data (optional)
  50771. */
  50772. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50773. /** @hidden */
  50774. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50775. /** @hidden */
  50776. _bindTexture(channel: number, texture: InternalTexture): void;
  50777. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50778. /**
  50779. * 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
  50780. */
  50781. releaseEffects(): void;
  50782. displayLoadingUI(): void;
  50783. hideLoadingUI(): void;
  50784. /** @hidden */
  50785. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50786. /** @hidden */
  50787. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50788. /** @hidden */
  50789. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50790. /** @hidden */
  50791. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50792. }
  50793. }
  50794. declare module BABYLON {
  50795. /**
  50796. * @hidden
  50797. **/
  50798. export class _TimeToken {
  50799. _startTimeQuery: Nullable<WebGLQuery>;
  50800. _endTimeQuery: Nullable<WebGLQuery>;
  50801. _timeElapsedQuery: Nullable<WebGLQuery>;
  50802. _timeElapsedQueryEnded: boolean;
  50803. }
  50804. }
  50805. declare module BABYLON {
  50806. /** @hidden */
  50807. export class _OcclusionDataStorage {
  50808. /** @hidden */
  50809. occlusionInternalRetryCounter: number;
  50810. /** @hidden */
  50811. isOcclusionQueryInProgress: boolean;
  50812. /** @hidden */
  50813. isOccluded: boolean;
  50814. /** @hidden */
  50815. occlusionRetryCount: number;
  50816. /** @hidden */
  50817. occlusionType: number;
  50818. /** @hidden */
  50819. occlusionQueryAlgorithmType: number;
  50820. }
  50821. interface Engine {
  50822. /**
  50823. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50824. * @return the new query
  50825. */
  50826. createQuery(): WebGLQuery;
  50827. /**
  50828. * Delete and release a webGL query
  50829. * @param query defines the query to delete
  50830. * @return the current engine
  50831. */
  50832. deleteQuery(query: WebGLQuery): Engine;
  50833. /**
  50834. * Check if a given query has resolved and got its value
  50835. * @param query defines the query to check
  50836. * @returns true if the query got its value
  50837. */
  50838. isQueryResultAvailable(query: WebGLQuery): boolean;
  50839. /**
  50840. * Gets the value of a given query
  50841. * @param query defines the query to check
  50842. * @returns the value of the query
  50843. */
  50844. getQueryResult(query: WebGLQuery): number;
  50845. /**
  50846. * Initiates an occlusion query
  50847. * @param algorithmType defines the algorithm to use
  50848. * @param query defines the query to use
  50849. * @returns the current engine
  50850. * @see http://doc.babylonjs.com/features/occlusionquery
  50851. */
  50852. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50853. /**
  50854. * Ends an occlusion query
  50855. * @see http://doc.babylonjs.com/features/occlusionquery
  50856. * @param algorithmType defines the algorithm to use
  50857. * @returns the current engine
  50858. */
  50859. endOcclusionQuery(algorithmType: number): Engine;
  50860. /**
  50861. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50862. * Please note that only one query can be issued at a time
  50863. * @returns a time token used to track the time span
  50864. */
  50865. startTimeQuery(): Nullable<_TimeToken>;
  50866. /**
  50867. * Ends a time query
  50868. * @param token defines the token used to measure the time span
  50869. * @returns the time spent (in ns)
  50870. */
  50871. endTimeQuery(token: _TimeToken): int;
  50872. /** @hidden */
  50873. _currentNonTimestampToken: Nullable<_TimeToken>;
  50874. /** @hidden */
  50875. _createTimeQuery(): WebGLQuery;
  50876. /** @hidden */
  50877. _deleteTimeQuery(query: WebGLQuery): void;
  50878. /** @hidden */
  50879. _getGlAlgorithmType(algorithmType: number): number;
  50880. /** @hidden */
  50881. _getTimeQueryResult(query: WebGLQuery): any;
  50882. /** @hidden */
  50883. _getTimeQueryAvailability(query: WebGLQuery): any;
  50884. }
  50885. interface AbstractMesh {
  50886. /**
  50887. * Backing filed
  50888. * @hidden
  50889. */
  50890. __occlusionDataStorage: _OcclusionDataStorage;
  50891. /**
  50892. * Access property
  50893. * @hidden
  50894. */
  50895. _occlusionDataStorage: _OcclusionDataStorage;
  50896. /**
  50897. * 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.
  50898. * The default value is -1 which means don't break the query and wait till the result
  50899. * @see http://doc.babylonjs.com/features/occlusionquery
  50900. */
  50901. occlusionRetryCount: number;
  50902. /**
  50903. * 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:
  50904. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50905. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50906. * * 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.
  50907. * @see http://doc.babylonjs.com/features/occlusionquery
  50908. */
  50909. occlusionType: number;
  50910. /**
  50911. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50912. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50913. * * 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.
  50914. * @see http://doc.babylonjs.com/features/occlusionquery
  50915. */
  50916. occlusionQueryAlgorithmType: number;
  50917. /**
  50918. * 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
  50919. * @see http://doc.babylonjs.com/features/occlusionquery
  50920. */
  50921. isOccluded: boolean;
  50922. /**
  50923. * Flag to check the progress status of the query
  50924. * @see http://doc.babylonjs.com/features/occlusionquery
  50925. */
  50926. isOcclusionQueryInProgress: boolean;
  50927. }
  50928. }
  50929. declare module BABYLON {
  50930. /** @hidden */
  50931. export var _forceTransformFeedbackToBundle: boolean;
  50932. interface Engine {
  50933. /**
  50934. * Creates a webGL transform feedback object
  50935. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50936. * @returns the webGL transform feedback object
  50937. */
  50938. createTransformFeedback(): WebGLTransformFeedback;
  50939. /**
  50940. * Delete a webGL transform feedback object
  50941. * @param value defines the webGL transform feedback object to delete
  50942. */
  50943. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50944. /**
  50945. * Bind a webGL transform feedback object to the webgl context
  50946. * @param value defines the webGL transform feedback object to bind
  50947. */
  50948. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50949. /**
  50950. * Begins a transform feedback operation
  50951. * @param usePoints defines if points or triangles must be used
  50952. */
  50953. beginTransformFeedback(usePoints: boolean): void;
  50954. /**
  50955. * Ends a transform feedback operation
  50956. */
  50957. endTransformFeedback(): void;
  50958. /**
  50959. * Specify the varyings to use with transform feedback
  50960. * @param program defines the associated webGL program
  50961. * @param value defines the list of strings representing the varying names
  50962. */
  50963. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50964. /**
  50965. * Bind a webGL buffer for a transform feedback operation
  50966. * @param value defines the webGL buffer to bind
  50967. */
  50968. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50969. }
  50970. }
  50971. declare module BABYLON {
  50972. /**
  50973. * Creation options of the multi render target texture.
  50974. */
  50975. export interface IMultiRenderTargetOptions {
  50976. /**
  50977. * Define if the texture needs to create mip maps after render.
  50978. */
  50979. generateMipMaps?: boolean;
  50980. /**
  50981. * Define the types of all the draw buffers we want to create
  50982. */
  50983. types?: number[];
  50984. /**
  50985. * Define the sampling modes of all the draw buffers we want to create
  50986. */
  50987. samplingModes?: number[];
  50988. /**
  50989. * Define if a depth buffer is required
  50990. */
  50991. generateDepthBuffer?: boolean;
  50992. /**
  50993. * Define if a stencil buffer is required
  50994. */
  50995. generateStencilBuffer?: boolean;
  50996. /**
  50997. * Define if a depth texture is required instead of a depth buffer
  50998. */
  50999. generateDepthTexture?: boolean;
  51000. /**
  51001. * Define the number of desired draw buffers
  51002. */
  51003. textureCount?: number;
  51004. /**
  51005. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51006. */
  51007. doNotChangeAspectRatio?: boolean;
  51008. /**
  51009. * Define the default type of the buffers we are creating
  51010. */
  51011. defaultType?: number;
  51012. }
  51013. /**
  51014. * A multi render target, like a render target provides the ability to render to a texture.
  51015. * Unlike the render target, it can render to several draw buffers in one draw.
  51016. * This is specially interesting in deferred rendering or for any effects requiring more than
  51017. * just one color from a single pass.
  51018. */
  51019. export class MultiRenderTarget extends RenderTargetTexture {
  51020. private _internalTextures;
  51021. private _textures;
  51022. private _multiRenderTargetOptions;
  51023. /**
  51024. * Get if draw buffers are currently supported by the used hardware and browser.
  51025. */
  51026. get isSupported(): boolean;
  51027. /**
  51028. * Get the list of textures generated by the multi render target.
  51029. */
  51030. get textures(): Texture[];
  51031. /**
  51032. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51033. */
  51034. get depthTexture(): Texture;
  51035. /**
  51036. * Set the wrapping mode on U of all the textures we are rendering to.
  51037. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51038. */
  51039. set wrapU(wrap: number);
  51040. /**
  51041. * Set the wrapping mode on V of all the textures we are rendering to.
  51042. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51043. */
  51044. set wrapV(wrap: number);
  51045. /**
  51046. * Instantiate a new multi render target texture.
  51047. * A multi render target, like a render target provides the ability to render to a texture.
  51048. * Unlike the render target, it can render to several draw buffers in one draw.
  51049. * This is specially interesting in deferred rendering or for any effects requiring more than
  51050. * just one color from a single pass.
  51051. * @param name Define the name of the texture
  51052. * @param size Define the size of the buffers to render to
  51053. * @param count Define the number of target we are rendering into
  51054. * @param scene Define the scene the texture belongs to
  51055. * @param options Define the options used to create the multi render target
  51056. */
  51057. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51058. /** @hidden */
  51059. _rebuild(): void;
  51060. private _createInternalTextures;
  51061. private _createTextures;
  51062. /**
  51063. * Define the number of samples used if MSAA is enabled.
  51064. */
  51065. get samples(): number;
  51066. set samples(value: number);
  51067. /**
  51068. * Resize all the textures in the multi render target.
  51069. * Be carrefull as it will recreate all the data in the new texture.
  51070. * @param size Define the new size
  51071. */
  51072. resize(size: any): void;
  51073. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51074. /**
  51075. * Dispose the render targets and their associated resources
  51076. */
  51077. dispose(): void;
  51078. /**
  51079. * Release all the underlying texture used as draw buffers.
  51080. */
  51081. releaseInternalTextures(): void;
  51082. }
  51083. }
  51084. declare module BABYLON {
  51085. interface ThinEngine {
  51086. /**
  51087. * Unbind a list of render target textures from the webGL context
  51088. * This is used only when drawBuffer extension or webGL2 are active
  51089. * @param textures defines the render target textures to unbind
  51090. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51091. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51092. */
  51093. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51094. /**
  51095. * Create a multi render target texture
  51096. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  51097. * @param size defines the size of the texture
  51098. * @param options defines the creation options
  51099. * @returns the cube texture as an InternalTexture
  51100. */
  51101. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51102. /**
  51103. * Update the sample count for a given multiple render target texture
  51104. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51105. * @param textures defines the textures to update
  51106. * @param samples defines the sample count to set
  51107. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51108. */
  51109. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51110. }
  51111. }
  51112. declare module BABYLON {
  51113. /**
  51114. * Class used to define an additional view for the engine
  51115. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51116. */
  51117. export class EngineView {
  51118. /** Defines the canvas where to render the view */
  51119. target: HTMLCanvasElement;
  51120. /** Defines an optional camera used to render the view (will use active camera else) */
  51121. camera?: Camera;
  51122. }
  51123. interface Engine {
  51124. /**
  51125. * Gets or sets the HTML element to use for attaching events
  51126. */
  51127. inputElement: Nullable<HTMLElement>;
  51128. /**
  51129. * Gets the current engine view
  51130. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51131. */
  51132. activeView: Nullable<EngineView>;
  51133. /** Gets or sets the list of views */
  51134. views: EngineView[];
  51135. /**
  51136. * Register a new child canvas
  51137. * @param canvas defines the canvas to register
  51138. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51139. * @returns the associated view
  51140. */
  51141. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51142. /**
  51143. * Remove a registered child canvas
  51144. * @param canvas defines the canvas to remove
  51145. * @returns the current engine
  51146. */
  51147. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51148. }
  51149. }
  51150. declare module BABYLON {
  51151. interface Engine {
  51152. /** @hidden */
  51153. _excludedCompressedTextures: string[];
  51154. /** @hidden */
  51155. _textureFormatInUse: string;
  51156. /**
  51157. * Gets the list of texture formats supported
  51158. */
  51159. readonly texturesSupported: Array<string>;
  51160. /**
  51161. * Gets the texture format in use
  51162. */
  51163. readonly textureFormatInUse: Nullable<string>;
  51164. /**
  51165. * Set the compressed texture extensions or file names to skip.
  51166. *
  51167. * @param skippedFiles defines the list of those texture files you want to skip
  51168. * Example: [".dds", ".env", "myfile.png"]
  51169. */
  51170. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51171. /**
  51172. * Set the compressed texture format to use, based on the formats you have, and the formats
  51173. * supported by the hardware / browser.
  51174. *
  51175. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51176. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51177. * to API arguments needed to compressed textures. This puts the burden on the container
  51178. * generator to house the arcane code for determining these for current & future formats.
  51179. *
  51180. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51181. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51182. *
  51183. * Note: The result of this call is not taken into account when a texture is base64.
  51184. *
  51185. * @param formatsAvailable defines the list of those format families you have created
  51186. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51187. *
  51188. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51189. * @returns The extension selected.
  51190. */
  51191. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51192. }
  51193. }
  51194. declare module BABYLON {
  51195. /**
  51196. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51197. */
  51198. export interface CubeMapInfo {
  51199. /**
  51200. * The pixel array for the front face.
  51201. * This is stored in format, left to right, up to down format.
  51202. */
  51203. front: Nullable<ArrayBufferView>;
  51204. /**
  51205. * The pixel array for the back face.
  51206. * This is stored in format, left to right, up to down format.
  51207. */
  51208. back: Nullable<ArrayBufferView>;
  51209. /**
  51210. * The pixel array for the left face.
  51211. * This is stored in format, left to right, up to down format.
  51212. */
  51213. left: Nullable<ArrayBufferView>;
  51214. /**
  51215. * The pixel array for the right face.
  51216. * This is stored in format, left to right, up to down format.
  51217. */
  51218. right: Nullable<ArrayBufferView>;
  51219. /**
  51220. * The pixel array for the up face.
  51221. * This is stored in format, left to right, up to down format.
  51222. */
  51223. up: Nullable<ArrayBufferView>;
  51224. /**
  51225. * The pixel array for the down face.
  51226. * This is stored in format, left to right, up to down format.
  51227. */
  51228. down: Nullable<ArrayBufferView>;
  51229. /**
  51230. * The size of the cubemap stored.
  51231. *
  51232. * Each faces will be size * size pixels.
  51233. */
  51234. size: number;
  51235. /**
  51236. * The format of the texture.
  51237. *
  51238. * RGBA, RGB.
  51239. */
  51240. format: number;
  51241. /**
  51242. * The type of the texture data.
  51243. *
  51244. * UNSIGNED_INT, FLOAT.
  51245. */
  51246. type: number;
  51247. /**
  51248. * Specifies whether the texture is in gamma space.
  51249. */
  51250. gammaSpace: boolean;
  51251. }
  51252. /**
  51253. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51254. */
  51255. export class PanoramaToCubeMapTools {
  51256. private static FACE_LEFT;
  51257. private static FACE_RIGHT;
  51258. private static FACE_FRONT;
  51259. private static FACE_BACK;
  51260. private static FACE_DOWN;
  51261. private static FACE_UP;
  51262. /**
  51263. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51264. *
  51265. * @param float32Array The source data.
  51266. * @param inputWidth The width of the input panorama.
  51267. * @param inputHeight The height of the input panorama.
  51268. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51269. * @return The cubemap data
  51270. */
  51271. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51272. private static CreateCubemapTexture;
  51273. private static CalcProjectionSpherical;
  51274. }
  51275. }
  51276. declare module BABYLON {
  51277. /**
  51278. * Helper class dealing with the extraction of spherical polynomial dataArray
  51279. * from a cube map.
  51280. */
  51281. export class CubeMapToSphericalPolynomialTools {
  51282. private static FileFaces;
  51283. /**
  51284. * Converts a texture to the according Spherical Polynomial data.
  51285. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51286. *
  51287. * @param texture The texture to extract the information from.
  51288. * @return The Spherical Polynomial data.
  51289. */
  51290. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51291. /**
  51292. * Converts a cubemap to the according Spherical Polynomial data.
  51293. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51294. *
  51295. * @param cubeInfo The Cube map to extract the information from.
  51296. * @return The Spherical Polynomial data.
  51297. */
  51298. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51299. }
  51300. }
  51301. declare module BABYLON {
  51302. interface BaseTexture {
  51303. /**
  51304. * Get the polynomial representation of the texture data.
  51305. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51306. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51307. */
  51308. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51309. }
  51310. }
  51311. declare module BABYLON {
  51312. /** @hidden */
  51313. export var rgbdEncodePixelShader: {
  51314. name: string;
  51315. shader: string;
  51316. };
  51317. }
  51318. declare module BABYLON {
  51319. /** @hidden */
  51320. export var rgbdDecodePixelShader: {
  51321. name: string;
  51322. shader: string;
  51323. };
  51324. }
  51325. declare module BABYLON {
  51326. /**
  51327. * Raw texture data and descriptor sufficient for WebGL texture upload
  51328. */
  51329. export interface EnvironmentTextureInfo {
  51330. /**
  51331. * Version of the environment map
  51332. */
  51333. version: number;
  51334. /**
  51335. * Width of image
  51336. */
  51337. width: number;
  51338. /**
  51339. * Irradiance information stored in the file.
  51340. */
  51341. irradiance: any;
  51342. /**
  51343. * Specular information stored in the file.
  51344. */
  51345. specular: any;
  51346. }
  51347. /**
  51348. * Defines One Image in the file. It requires only the position in the file
  51349. * as well as the length.
  51350. */
  51351. interface BufferImageData {
  51352. /**
  51353. * Length of the image data.
  51354. */
  51355. length: number;
  51356. /**
  51357. * Position of the data from the null terminator delimiting the end of the JSON.
  51358. */
  51359. position: number;
  51360. }
  51361. /**
  51362. * Defines the specular data enclosed in the file.
  51363. * This corresponds to the version 1 of the data.
  51364. */
  51365. export interface EnvironmentTextureSpecularInfoV1 {
  51366. /**
  51367. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51368. */
  51369. specularDataPosition?: number;
  51370. /**
  51371. * This contains all the images data needed to reconstruct the cubemap.
  51372. */
  51373. mipmaps: Array<BufferImageData>;
  51374. /**
  51375. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51376. */
  51377. lodGenerationScale: number;
  51378. }
  51379. /**
  51380. * Sets of helpers addressing the serialization and deserialization of environment texture
  51381. * stored in a BabylonJS env file.
  51382. * Those files are usually stored as .env files.
  51383. */
  51384. export class EnvironmentTextureTools {
  51385. /**
  51386. * Magic number identifying the env file.
  51387. */
  51388. private static _MagicBytes;
  51389. /**
  51390. * Gets the environment info from an env file.
  51391. * @param data The array buffer containing the .env bytes.
  51392. * @returns the environment file info (the json header) if successfully parsed.
  51393. */
  51394. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51395. /**
  51396. * Creates an environment texture from a loaded cube texture.
  51397. * @param texture defines the cube texture to convert in env file
  51398. * @return a promise containing the environment data if succesfull.
  51399. */
  51400. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51401. /**
  51402. * Creates a JSON representation of the spherical data.
  51403. * @param texture defines the texture containing the polynomials
  51404. * @return the JSON representation of the spherical info
  51405. */
  51406. private static _CreateEnvTextureIrradiance;
  51407. /**
  51408. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51409. * @param data the image data
  51410. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51411. * @return the views described by info providing access to the underlying buffer
  51412. */
  51413. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51414. /**
  51415. * Uploads the texture info contained in the env file to the GPU.
  51416. * @param texture defines the internal texture to upload to
  51417. * @param data defines the data to load
  51418. * @param info defines the texture info retrieved through the GetEnvInfo method
  51419. * @returns a promise
  51420. */
  51421. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51422. private static _OnImageReadyAsync;
  51423. /**
  51424. * Uploads the levels of image data to the GPU.
  51425. * @param texture defines the internal texture to upload to
  51426. * @param imageData defines the array buffer views of image data [mipmap][face]
  51427. * @returns a promise
  51428. */
  51429. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51430. /**
  51431. * Uploads spherical polynomials information to the texture.
  51432. * @param texture defines the texture we are trying to upload the information to
  51433. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51434. */
  51435. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51436. /** @hidden */
  51437. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51438. }
  51439. }
  51440. declare module BABYLON {
  51441. /**
  51442. * Class used to inline functions in shader code
  51443. */
  51444. export class ShaderCodeInliner {
  51445. private static readonly _RegexpFindFunctionNameAndType;
  51446. private _sourceCode;
  51447. private _functionDescr;
  51448. private _numMaxIterations;
  51449. /** Gets or sets the token used to mark the functions to inline */
  51450. inlineToken: string;
  51451. /** Gets or sets the debug mode */
  51452. debug: boolean;
  51453. /** Gets the code after the inlining process */
  51454. get code(): string;
  51455. /**
  51456. * Initializes the inliner
  51457. * @param sourceCode shader code source to inline
  51458. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51459. */
  51460. constructor(sourceCode: string, numMaxIterations?: number);
  51461. /**
  51462. * Start the processing of the shader code
  51463. */
  51464. processCode(): void;
  51465. private _collectFunctions;
  51466. private _processInlining;
  51467. private _extractBetweenMarkers;
  51468. private _skipWhitespaces;
  51469. private _removeComments;
  51470. private _replaceFunctionCallsByCode;
  51471. private _findBackward;
  51472. private _escapeRegExp;
  51473. private _replaceNames;
  51474. }
  51475. }
  51476. declare module BABYLON {
  51477. /**
  51478. * Container for accessors for natively-stored mesh data buffers.
  51479. */
  51480. class NativeDataBuffer extends DataBuffer {
  51481. /**
  51482. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51483. */
  51484. nativeIndexBuffer?: any;
  51485. /**
  51486. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51487. */
  51488. nativeVertexBuffer?: any;
  51489. }
  51490. /** @hidden */
  51491. class NativeTexture extends InternalTexture {
  51492. getInternalTexture(): InternalTexture;
  51493. getViewCount(): number;
  51494. }
  51495. /** @hidden */
  51496. export class NativeEngine extends Engine {
  51497. private readonly _native;
  51498. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51499. private readonly INVALID_HANDLE;
  51500. getHardwareScalingLevel(): number;
  51501. constructor();
  51502. dispose(): void;
  51503. /**
  51504. * Can be used to override the current requestAnimationFrame requester.
  51505. * @hidden
  51506. */
  51507. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51508. /**
  51509. * Override default engine behavior.
  51510. * @param color
  51511. * @param backBuffer
  51512. * @param depth
  51513. * @param stencil
  51514. */
  51515. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51516. /**
  51517. * Gets host document
  51518. * @returns the host document object
  51519. */
  51520. getHostDocument(): Nullable<Document>;
  51521. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51522. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51523. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51524. recordVertexArrayObject(vertexBuffers: {
  51525. [key: string]: VertexBuffer;
  51526. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51527. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51528. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51529. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51530. /**
  51531. * Draw a list of indexed primitives
  51532. * @param fillMode defines the primitive to use
  51533. * @param indexStart defines the starting index
  51534. * @param indexCount defines the number of index to draw
  51535. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51536. */
  51537. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51538. /**
  51539. * Draw a list of unindexed primitives
  51540. * @param fillMode defines the primitive to use
  51541. * @param verticesStart defines the index of first vertex to draw
  51542. * @param verticesCount defines the count of vertices to draw
  51543. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51544. */
  51545. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51546. createPipelineContext(): IPipelineContext;
  51547. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51548. /** @hidden */
  51549. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51550. /** @hidden */
  51551. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51552. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51553. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51554. protected _setProgram(program: WebGLProgram): void;
  51555. _releaseEffect(effect: Effect): void;
  51556. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51557. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51558. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51559. bindSamplers(effect: Effect): void;
  51560. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51561. getRenderWidth(useScreen?: boolean): number;
  51562. getRenderHeight(useScreen?: boolean): number;
  51563. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51564. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51565. /**
  51566. * Set the z offset to apply to current rendering
  51567. * @param value defines the offset to apply
  51568. */
  51569. setZOffset(value: number): void;
  51570. /**
  51571. * Gets the current value of the zOffset
  51572. * @returns the current zOffset state
  51573. */
  51574. getZOffset(): number;
  51575. /**
  51576. * Enable or disable depth buffering
  51577. * @param enable defines the state to set
  51578. */
  51579. setDepthBuffer(enable: boolean): void;
  51580. /**
  51581. * Gets a boolean indicating if depth writing is enabled
  51582. * @returns the current depth writing state
  51583. */
  51584. getDepthWrite(): boolean;
  51585. /**
  51586. * Enable or disable depth writing
  51587. * @param enable defines the state to set
  51588. */
  51589. setDepthWrite(enable: boolean): void;
  51590. /**
  51591. * Enable or disable color writing
  51592. * @param enable defines the state to set
  51593. */
  51594. setColorWrite(enable: boolean): void;
  51595. /**
  51596. * Gets a boolean indicating if color writing is enabled
  51597. * @returns the current color writing state
  51598. */
  51599. getColorWrite(): boolean;
  51600. /**
  51601. * Sets alpha constants used by some alpha blending modes
  51602. * @param r defines the red component
  51603. * @param g defines the green component
  51604. * @param b defines the blue component
  51605. * @param a defines the alpha component
  51606. */
  51607. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51608. /**
  51609. * Sets the current alpha mode
  51610. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51611. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51612. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51613. */
  51614. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51615. /**
  51616. * Gets the current alpha mode
  51617. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51618. * @returns the current alpha mode
  51619. */
  51620. getAlphaMode(): number;
  51621. setInt(uniform: WebGLUniformLocation, int: number): void;
  51622. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51623. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51624. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51625. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51626. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51627. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51628. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51629. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51630. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51631. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51632. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51633. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51634. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51635. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51636. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51637. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51638. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51639. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51640. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51641. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51642. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51643. wipeCaches(bruteForce?: boolean): void;
  51644. _createTexture(): WebGLTexture;
  51645. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51646. /**
  51647. * Usually called from Texture.ts.
  51648. * Passed information to create a WebGLTexture
  51649. * @param url defines a value which contains one of the following:
  51650. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51651. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51652. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51653. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51654. * @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)
  51655. * @param scene needed for loading to the correct scene
  51656. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51657. * @param onLoad optional callback to be called upon successful completion
  51658. * @param onError optional callback to be called upon failure
  51659. * @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
  51660. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51661. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51662. * @param forcedExtension defines the extension to use to pick the right loader
  51663. * @param mimeType defines an optional mime type
  51664. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51665. */
  51666. 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;
  51667. /**
  51668. * Creates a cube texture
  51669. * @param rootUrl defines the url where the files to load is located
  51670. * @param scene defines the current scene
  51671. * @param files defines the list of files to load (1 per face)
  51672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51673. * @param onLoad defines an optional callback raised when the texture is loaded
  51674. * @param onError defines an optional callback raised if there is an issue to load the texture
  51675. * @param format defines the format of the data
  51676. * @param forcedExtension defines the extension to use to pick the right loader
  51677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51680. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51681. * @returns the cube texture as an InternalTexture
  51682. */
  51683. 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;
  51684. private _getSamplingFilter;
  51685. private static _GetNativeTextureFormat;
  51686. createRenderTargetTexture(size: number | {
  51687. width: number;
  51688. height: number;
  51689. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51690. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51691. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51692. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51693. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51694. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51695. /**
  51696. * Updates a dynamic vertex buffer.
  51697. * @param vertexBuffer the vertex buffer to update
  51698. * @param data the data used to update the vertex buffer
  51699. * @param byteOffset the byte offset of the data (optional)
  51700. * @param byteLength the byte length of the data (optional)
  51701. */
  51702. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51703. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51704. private _updateAnisotropicLevel;
  51705. private _getAddressMode;
  51706. /** @hidden */
  51707. _bindTexture(channel: number, texture: InternalTexture): void;
  51708. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51709. releaseEffects(): void;
  51710. /** @hidden */
  51711. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51712. /** @hidden */
  51713. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51714. /** @hidden */
  51715. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51716. /** @hidden */
  51717. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51718. }
  51719. }
  51720. declare module BABYLON {
  51721. /**
  51722. * Gather the list of clipboard event types as constants.
  51723. */
  51724. export class ClipboardEventTypes {
  51725. /**
  51726. * The clipboard event is fired when a copy command is active (pressed).
  51727. */
  51728. static readonly COPY: number;
  51729. /**
  51730. * The clipboard event is fired when a cut command is active (pressed).
  51731. */
  51732. static readonly CUT: number;
  51733. /**
  51734. * The clipboard event is fired when a paste command is active (pressed).
  51735. */
  51736. static readonly PASTE: number;
  51737. }
  51738. /**
  51739. * This class is used to store clipboard related info for the onClipboardObservable event.
  51740. */
  51741. export class ClipboardInfo {
  51742. /**
  51743. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51744. */
  51745. type: number;
  51746. /**
  51747. * Defines the related dom event
  51748. */
  51749. event: ClipboardEvent;
  51750. /**
  51751. *Creates an instance of ClipboardInfo.
  51752. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51753. * @param event Defines the related dom event
  51754. */
  51755. constructor(
  51756. /**
  51757. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51758. */
  51759. type: number,
  51760. /**
  51761. * Defines the related dom event
  51762. */
  51763. event: ClipboardEvent);
  51764. /**
  51765. * Get the clipboard event's type from the keycode.
  51766. * @param keyCode Defines the keyCode for the current keyboard event.
  51767. * @return {number}
  51768. */
  51769. static GetTypeFromCharacter(keyCode: number): number;
  51770. }
  51771. }
  51772. declare module BABYLON {
  51773. /**
  51774. * Google Daydream controller
  51775. */
  51776. export class DaydreamController extends WebVRController {
  51777. /**
  51778. * Base Url for the controller model.
  51779. */
  51780. static MODEL_BASE_URL: string;
  51781. /**
  51782. * File name for the controller model.
  51783. */
  51784. static MODEL_FILENAME: string;
  51785. /**
  51786. * Gamepad Id prefix used to identify Daydream Controller.
  51787. */
  51788. static readonly GAMEPAD_ID_PREFIX: string;
  51789. /**
  51790. * Creates a new DaydreamController from a gamepad
  51791. * @param vrGamepad the gamepad that the controller should be created from
  51792. */
  51793. constructor(vrGamepad: any);
  51794. /**
  51795. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51796. * @param scene scene in which to add meshes
  51797. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51798. */
  51799. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51800. /**
  51801. * Called once for each button that changed state since the last frame
  51802. * @param buttonIdx Which button index changed
  51803. * @param state New state of the button
  51804. * @param changes Which properties on the state changed since last frame
  51805. */
  51806. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51807. }
  51808. }
  51809. declare module BABYLON {
  51810. /**
  51811. * Gear VR Controller
  51812. */
  51813. export class GearVRController extends WebVRController {
  51814. /**
  51815. * Base Url for the controller model.
  51816. */
  51817. static MODEL_BASE_URL: string;
  51818. /**
  51819. * File name for the controller model.
  51820. */
  51821. static MODEL_FILENAME: string;
  51822. /**
  51823. * Gamepad Id prefix used to identify this controller.
  51824. */
  51825. static readonly GAMEPAD_ID_PREFIX: string;
  51826. private readonly _buttonIndexToObservableNameMap;
  51827. /**
  51828. * Creates a new GearVRController from a gamepad
  51829. * @param vrGamepad the gamepad that the controller should be created from
  51830. */
  51831. constructor(vrGamepad: any);
  51832. /**
  51833. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51834. * @param scene scene in which to add meshes
  51835. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51836. */
  51837. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51838. /**
  51839. * Called once for each button that changed state since the last frame
  51840. * @param buttonIdx Which button index changed
  51841. * @param state New state of the button
  51842. * @param changes Which properties on the state changed since last frame
  51843. */
  51844. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51845. }
  51846. }
  51847. declare module BABYLON {
  51848. /**
  51849. * Generic Controller
  51850. */
  51851. export class GenericController extends WebVRController {
  51852. /**
  51853. * Base Url for the controller model.
  51854. */
  51855. static readonly MODEL_BASE_URL: string;
  51856. /**
  51857. * File name for the controller model.
  51858. */
  51859. static readonly MODEL_FILENAME: string;
  51860. /**
  51861. * Creates a new GenericController from a gamepad
  51862. * @param vrGamepad the gamepad that the controller should be created from
  51863. */
  51864. constructor(vrGamepad: any);
  51865. /**
  51866. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51867. * @param scene scene in which to add meshes
  51868. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51869. */
  51870. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51871. /**
  51872. * Called once for each button that changed state since the last frame
  51873. * @param buttonIdx Which button index changed
  51874. * @param state New state of the button
  51875. * @param changes Which properties on the state changed since last frame
  51876. */
  51877. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51878. }
  51879. }
  51880. declare module BABYLON {
  51881. /**
  51882. * Oculus Touch Controller
  51883. */
  51884. export class OculusTouchController extends WebVRController {
  51885. /**
  51886. * Base Url for the controller model.
  51887. */
  51888. static MODEL_BASE_URL: string;
  51889. /**
  51890. * File name for the left controller model.
  51891. */
  51892. static MODEL_LEFT_FILENAME: string;
  51893. /**
  51894. * File name for the right controller model.
  51895. */
  51896. static MODEL_RIGHT_FILENAME: string;
  51897. /**
  51898. * Base Url for the Quest controller model.
  51899. */
  51900. static QUEST_MODEL_BASE_URL: string;
  51901. /**
  51902. * @hidden
  51903. * If the controllers are running on a device that needs the updated Quest controller models
  51904. */
  51905. static _IsQuest: boolean;
  51906. /**
  51907. * Fired when the secondary trigger on this controller is modified
  51908. */
  51909. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51910. /**
  51911. * Fired when the thumb rest on this controller is modified
  51912. */
  51913. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51914. /**
  51915. * Creates a new OculusTouchController from a gamepad
  51916. * @param vrGamepad the gamepad that the controller should be created from
  51917. */
  51918. constructor(vrGamepad: any);
  51919. /**
  51920. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51921. * @param scene scene in which to add meshes
  51922. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51923. */
  51924. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51925. /**
  51926. * Fired when the A button on this controller is modified
  51927. */
  51928. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51929. /**
  51930. * Fired when the B button on this controller is modified
  51931. */
  51932. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51933. /**
  51934. * Fired when the X button on this controller is modified
  51935. */
  51936. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51937. /**
  51938. * Fired when the Y button on this controller is modified
  51939. */
  51940. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51941. /**
  51942. * Called once for each button that changed state since the last frame
  51943. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51944. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51945. * 2) secondary trigger (same)
  51946. * 3) A (right) X (left), touch, pressed = value
  51947. * 4) B / Y
  51948. * 5) thumb rest
  51949. * @param buttonIdx Which button index changed
  51950. * @param state New state of the button
  51951. * @param changes Which properties on the state changed since last frame
  51952. */
  51953. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51954. }
  51955. }
  51956. declare module BABYLON {
  51957. /**
  51958. * Vive Controller
  51959. */
  51960. export class ViveController extends WebVRController {
  51961. /**
  51962. * Base Url for the controller model.
  51963. */
  51964. static MODEL_BASE_URL: string;
  51965. /**
  51966. * File name for the controller model.
  51967. */
  51968. static MODEL_FILENAME: string;
  51969. /**
  51970. * Creates a new ViveController from a gamepad
  51971. * @param vrGamepad the gamepad that the controller should be created from
  51972. */
  51973. constructor(vrGamepad: any);
  51974. /**
  51975. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51976. * @param scene scene in which to add meshes
  51977. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51978. */
  51979. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51980. /**
  51981. * Fired when the left button on this controller is modified
  51982. */
  51983. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51984. /**
  51985. * Fired when the right button on this controller is modified
  51986. */
  51987. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51988. /**
  51989. * Fired when the menu button on this controller is modified
  51990. */
  51991. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51992. /**
  51993. * Called once for each button that changed state since the last frame
  51994. * Vive mapping:
  51995. * 0: touchpad
  51996. * 1: trigger
  51997. * 2: left AND right buttons
  51998. * 3: menu button
  51999. * @param buttonIdx Which button index changed
  52000. * @param state New state of the button
  52001. * @param changes Which properties on the state changed since last frame
  52002. */
  52003. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52004. }
  52005. }
  52006. declare module BABYLON {
  52007. /**
  52008. * Defines the WindowsMotionController object that the state of the windows motion controller
  52009. */
  52010. export class WindowsMotionController extends WebVRController {
  52011. /**
  52012. * The base url used to load the left and right controller models
  52013. */
  52014. static MODEL_BASE_URL: string;
  52015. /**
  52016. * The name of the left controller model file
  52017. */
  52018. static MODEL_LEFT_FILENAME: string;
  52019. /**
  52020. * The name of the right controller model file
  52021. */
  52022. static MODEL_RIGHT_FILENAME: string;
  52023. /**
  52024. * The controller name prefix for this controller type
  52025. */
  52026. static readonly GAMEPAD_ID_PREFIX: string;
  52027. /**
  52028. * The controller id pattern for this controller type
  52029. */
  52030. private static readonly GAMEPAD_ID_PATTERN;
  52031. private _loadedMeshInfo;
  52032. protected readonly _mapping: {
  52033. buttons: string[];
  52034. buttonMeshNames: {
  52035. trigger: string;
  52036. menu: string;
  52037. grip: string;
  52038. thumbstick: string;
  52039. trackpad: string;
  52040. };
  52041. buttonObservableNames: {
  52042. trigger: string;
  52043. menu: string;
  52044. grip: string;
  52045. thumbstick: string;
  52046. trackpad: string;
  52047. };
  52048. axisMeshNames: string[];
  52049. pointingPoseMeshName: string;
  52050. };
  52051. /**
  52052. * Fired when the trackpad on this controller is clicked
  52053. */
  52054. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52055. /**
  52056. * Fired when the trackpad on this controller is modified
  52057. */
  52058. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52059. /**
  52060. * The current x and y values of this controller's trackpad
  52061. */
  52062. trackpad: StickValues;
  52063. /**
  52064. * Creates a new WindowsMotionController from a gamepad
  52065. * @param vrGamepad the gamepad that the controller should be created from
  52066. */
  52067. constructor(vrGamepad: any);
  52068. /**
  52069. * Fired when the trigger on this controller is modified
  52070. */
  52071. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52072. /**
  52073. * Fired when the menu button on this controller is modified
  52074. */
  52075. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52076. /**
  52077. * Fired when the grip button on this controller is modified
  52078. */
  52079. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52080. /**
  52081. * Fired when the thumbstick button on this controller is modified
  52082. */
  52083. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52084. /**
  52085. * Fired when the touchpad button on this controller is modified
  52086. */
  52087. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52088. /**
  52089. * Fired when the touchpad values on this controller are modified
  52090. */
  52091. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52092. protected _updateTrackpad(): void;
  52093. /**
  52094. * Called once per frame by the engine.
  52095. */
  52096. update(): void;
  52097. /**
  52098. * Called once for each button that changed state since the last frame
  52099. * @param buttonIdx Which button index changed
  52100. * @param state New state of the button
  52101. * @param changes Which properties on the state changed since last frame
  52102. */
  52103. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52104. /**
  52105. * Moves the buttons on the controller mesh based on their current state
  52106. * @param buttonName the name of the button to move
  52107. * @param buttonValue the value of the button which determines the buttons new position
  52108. */
  52109. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52110. /**
  52111. * Moves the axis on the controller mesh based on its current state
  52112. * @param axis the index of the axis
  52113. * @param axisValue the value of the axis which determines the meshes new position
  52114. * @hidden
  52115. */
  52116. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52117. /**
  52118. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52119. * @param scene scene in which to add meshes
  52120. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52121. */
  52122. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52123. /**
  52124. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52125. * can be transformed by button presses and axes values, based on this._mapping.
  52126. *
  52127. * @param scene scene in which the meshes exist
  52128. * @param meshes list of meshes that make up the controller model to process
  52129. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52130. */
  52131. private processModel;
  52132. private createMeshInfo;
  52133. /**
  52134. * Gets the ray of the controller in the direction the controller is pointing
  52135. * @param length the length the resulting ray should be
  52136. * @returns a ray in the direction the controller is pointing
  52137. */
  52138. getForwardRay(length?: number): Ray;
  52139. /**
  52140. * Disposes of the controller
  52141. */
  52142. dispose(): void;
  52143. }
  52144. /**
  52145. * This class represents a new windows motion controller in XR.
  52146. */
  52147. export class XRWindowsMotionController extends WindowsMotionController {
  52148. /**
  52149. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52150. */
  52151. protected readonly _mapping: {
  52152. buttons: string[];
  52153. buttonMeshNames: {
  52154. trigger: string;
  52155. menu: string;
  52156. grip: string;
  52157. thumbstick: string;
  52158. trackpad: string;
  52159. };
  52160. buttonObservableNames: {
  52161. trigger: string;
  52162. menu: string;
  52163. grip: string;
  52164. thumbstick: string;
  52165. trackpad: string;
  52166. };
  52167. axisMeshNames: string[];
  52168. pointingPoseMeshName: string;
  52169. };
  52170. /**
  52171. * Construct a new XR-Based windows motion controller
  52172. *
  52173. * @param gamepadInfo the gamepad object from the browser
  52174. */
  52175. constructor(gamepadInfo: any);
  52176. /**
  52177. * holds the thumbstick values (X,Y)
  52178. */
  52179. thumbstickValues: StickValues;
  52180. /**
  52181. * Fired when the thumbstick on this controller is clicked
  52182. */
  52183. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52184. /**
  52185. * Fired when the thumbstick on this controller is modified
  52186. */
  52187. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52188. /**
  52189. * Fired when the touchpad button on this controller is modified
  52190. */
  52191. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52192. /**
  52193. * Fired when the touchpad values on this controller are modified
  52194. */
  52195. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52196. /**
  52197. * Fired when the thumbstick button on this controller is modified
  52198. * here to prevent breaking changes
  52199. */
  52200. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52201. /**
  52202. * updating the thumbstick(!) and not the trackpad.
  52203. * This is named this way due to the difference between WebVR and XR and to avoid
  52204. * changing the parent class.
  52205. */
  52206. protected _updateTrackpad(): void;
  52207. /**
  52208. * Disposes the class with joy
  52209. */
  52210. dispose(): void;
  52211. }
  52212. }
  52213. declare module BABYLON {
  52214. /**
  52215. * Class containing static functions to help procedurally build meshes
  52216. */
  52217. export class PolyhedronBuilder {
  52218. /**
  52219. * Creates a polyhedron mesh
  52220. * * 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
  52221. * * The parameter `size` (positive float, default 1) sets the polygon size
  52222. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52223. * * 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`
  52224. * * 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
  52225. * * 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)`)
  52226. * * 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
  52227. * * 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
  52228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52229. * * 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
  52230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52231. * @param name defines the name of the mesh
  52232. * @param options defines the options used to create the mesh
  52233. * @param scene defines the hosting scene
  52234. * @returns the polyhedron mesh
  52235. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52236. */
  52237. static CreatePolyhedron(name: string, options: {
  52238. type?: number;
  52239. size?: number;
  52240. sizeX?: number;
  52241. sizeY?: number;
  52242. sizeZ?: number;
  52243. custom?: any;
  52244. faceUV?: Vector4[];
  52245. faceColors?: Color4[];
  52246. flat?: boolean;
  52247. updatable?: boolean;
  52248. sideOrientation?: number;
  52249. frontUVs?: Vector4;
  52250. backUVs?: Vector4;
  52251. }, scene?: Nullable<Scene>): Mesh;
  52252. }
  52253. }
  52254. declare module BABYLON {
  52255. /**
  52256. * Gizmo that enables scaling a mesh along 3 axis
  52257. */
  52258. export class ScaleGizmo extends Gizmo {
  52259. /**
  52260. * Internal gizmo used for interactions on the x axis
  52261. */
  52262. xGizmo: AxisScaleGizmo;
  52263. /**
  52264. * Internal gizmo used for interactions on the y axis
  52265. */
  52266. yGizmo: AxisScaleGizmo;
  52267. /**
  52268. * Internal gizmo used for interactions on the z axis
  52269. */
  52270. zGizmo: AxisScaleGizmo;
  52271. /**
  52272. * Internal gizmo used to scale all axis equally
  52273. */
  52274. uniformScaleGizmo: AxisScaleGizmo;
  52275. private _meshAttached;
  52276. private _updateGizmoRotationToMatchAttachedMesh;
  52277. private _snapDistance;
  52278. private _scaleRatio;
  52279. private _uniformScalingMesh;
  52280. private _octahedron;
  52281. private _sensitivity;
  52282. /** Fires an event when any of it's sub gizmos are dragged */
  52283. onDragStartObservable: Observable<unknown>;
  52284. /** Fires an event when any of it's sub gizmos are released from dragging */
  52285. onDragEndObservable: Observable<unknown>;
  52286. get attachedMesh(): Nullable<AbstractMesh>;
  52287. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52288. /**
  52289. * Creates a ScaleGizmo
  52290. * @param gizmoLayer The utility layer the gizmo will be added to
  52291. */
  52292. constructor(gizmoLayer?: UtilityLayerRenderer);
  52293. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52294. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52295. /**
  52296. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52297. */
  52298. set snapDistance(value: number);
  52299. get snapDistance(): number;
  52300. /**
  52301. * Ratio for the scale of the gizmo (Default: 1)
  52302. */
  52303. set scaleRatio(value: number);
  52304. get scaleRatio(): number;
  52305. /**
  52306. * Sensitivity factor for dragging (Default: 1)
  52307. */
  52308. set sensitivity(value: number);
  52309. get sensitivity(): number;
  52310. /**
  52311. * Disposes of the gizmo
  52312. */
  52313. dispose(): void;
  52314. }
  52315. }
  52316. declare module BABYLON {
  52317. /**
  52318. * Single axis scale gizmo
  52319. */
  52320. export class AxisScaleGizmo extends Gizmo {
  52321. /**
  52322. * Drag behavior responsible for the gizmos dragging interactions
  52323. */
  52324. dragBehavior: PointerDragBehavior;
  52325. private _pointerObserver;
  52326. /**
  52327. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52328. */
  52329. snapDistance: number;
  52330. /**
  52331. * Event that fires each time the gizmo snaps to a new location.
  52332. * * snapDistance is the the change in distance
  52333. */
  52334. onSnapObservable: Observable<{
  52335. snapDistance: number;
  52336. }>;
  52337. /**
  52338. * If the scaling operation should be done on all axis (default: false)
  52339. */
  52340. uniformScaling: boolean;
  52341. /**
  52342. * Custom sensitivity value for the drag strength
  52343. */
  52344. sensitivity: number;
  52345. private _isEnabled;
  52346. private _parent;
  52347. private _arrow;
  52348. private _coloredMaterial;
  52349. private _hoverMaterial;
  52350. /**
  52351. * Creates an AxisScaleGizmo
  52352. * @param gizmoLayer The utility layer the gizmo will be added to
  52353. * @param dragAxis The axis which the gizmo will be able to scale on
  52354. * @param color The color of the gizmo
  52355. */
  52356. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52357. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52358. /**
  52359. * If the gizmo is enabled
  52360. */
  52361. set isEnabled(value: boolean);
  52362. get isEnabled(): boolean;
  52363. /**
  52364. * Disposes of the gizmo
  52365. */
  52366. dispose(): void;
  52367. /**
  52368. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52369. * @param mesh The mesh to replace the default mesh of the gizmo
  52370. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52371. */
  52372. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52373. }
  52374. }
  52375. declare module BABYLON {
  52376. /**
  52377. * Bounding box gizmo
  52378. */
  52379. export class BoundingBoxGizmo extends Gizmo {
  52380. private _lineBoundingBox;
  52381. private _rotateSpheresParent;
  52382. private _scaleBoxesParent;
  52383. private _boundingDimensions;
  52384. private _renderObserver;
  52385. private _pointerObserver;
  52386. private _scaleDragSpeed;
  52387. private _tmpQuaternion;
  52388. private _tmpVector;
  52389. private _tmpRotationMatrix;
  52390. /**
  52391. * 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)
  52392. */
  52393. ignoreChildren: boolean;
  52394. /**
  52395. * 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)
  52396. */
  52397. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52398. /**
  52399. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52400. */
  52401. rotationSphereSize: number;
  52402. /**
  52403. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52404. */
  52405. scaleBoxSize: number;
  52406. /**
  52407. * 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)
  52408. */
  52409. fixedDragMeshScreenSize: boolean;
  52410. /**
  52411. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52412. */
  52413. fixedDragMeshScreenSizeDistanceFactor: number;
  52414. /**
  52415. * Fired when a rotation sphere or scale box is dragged
  52416. */
  52417. onDragStartObservable: Observable<{}>;
  52418. /**
  52419. * Fired when a scale box is dragged
  52420. */
  52421. onScaleBoxDragObservable: Observable<{}>;
  52422. /**
  52423. * Fired when a scale box drag is ended
  52424. */
  52425. onScaleBoxDragEndObservable: Observable<{}>;
  52426. /**
  52427. * Fired when a rotation sphere is dragged
  52428. */
  52429. onRotationSphereDragObservable: Observable<{}>;
  52430. /**
  52431. * Fired when a rotation sphere drag is ended
  52432. */
  52433. onRotationSphereDragEndObservable: Observable<{}>;
  52434. /**
  52435. * 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)
  52436. */
  52437. scalePivot: Nullable<Vector3>;
  52438. /**
  52439. * Mesh used as a pivot to rotate the attached mesh
  52440. */
  52441. private _anchorMesh;
  52442. private _existingMeshScale;
  52443. private _dragMesh;
  52444. private pointerDragBehavior;
  52445. private coloredMaterial;
  52446. private hoverColoredMaterial;
  52447. /**
  52448. * Sets the color of the bounding box gizmo
  52449. * @param color the color to set
  52450. */
  52451. setColor(color: Color3): void;
  52452. /**
  52453. * Creates an BoundingBoxGizmo
  52454. * @param gizmoLayer The utility layer the gizmo will be added to
  52455. * @param color The color of the gizmo
  52456. */
  52457. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52458. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52459. private _selectNode;
  52460. /**
  52461. * Updates the bounding box information for the Gizmo
  52462. */
  52463. updateBoundingBox(): void;
  52464. private _updateRotationSpheres;
  52465. private _updateScaleBoxes;
  52466. /**
  52467. * Enables rotation on the specified axis and disables rotation on the others
  52468. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52469. */
  52470. setEnabledRotationAxis(axis: string): void;
  52471. /**
  52472. * Enables/disables scaling
  52473. * @param enable if scaling should be enabled
  52474. * @param homogeneousScaling defines if scaling should only be homogeneous
  52475. */
  52476. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52477. private _updateDummy;
  52478. /**
  52479. * Enables a pointer drag behavior on the bounding box of the gizmo
  52480. */
  52481. enableDragBehavior(): void;
  52482. /**
  52483. * Disposes of the gizmo
  52484. */
  52485. dispose(): void;
  52486. /**
  52487. * 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)
  52488. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52489. * @returns the bounding box mesh with the passed in mesh as a child
  52490. */
  52491. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52492. /**
  52493. * CustomMeshes are not supported by this gizmo
  52494. * @param mesh The mesh to replace the default mesh of the gizmo
  52495. */
  52496. setCustomMesh(mesh: Mesh): void;
  52497. }
  52498. }
  52499. declare module BABYLON {
  52500. /**
  52501. * Single plane rotation gizmo
  52502. */
  52503. export class PlaneRotationGizmo extends Gizmo {
  52504. /**
  52505. * Drag behavior responsible for the gizmos dragging interactions
  52506. */
  52507. dragBehavior: PointerDragBehavior;
  52508. private _pointerObserver;
  52509. /**
  52510. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52511. */
  52512. snapDistance: number;
  52513. /**
  52514. * Event that fires each time the gizmo snaps to a new location.
  52515. * * snapDistance is the the change in distance
  52516. */
  52517. onSnapObservable: Observable<{
  52518. snapDistance: number;
  52519. }>;
  52520. private _isEnabled;
  52521. private _parent;
  52522. /**
  52523. * Creates a PlaneRotationGizmo
  52524. * @param gizmoLayer The utility layer the gizmo will be added to
  52525. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52526. * @param color The color of the gizmo
  52527. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52528. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52529. */
  52530. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52531. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52532. /**
  52533. * If the gizmo is enabled
  52534. */
  52535. set isEnabled(value: boolean);
  52536. get isEnabled(): boolean;
  52537. /**
  52538. * Disposes of the gizmo
  52539. */
  52540. dispose(): void;
  52541. }
  52542. }
  52543. declare module BABYLON {
  52544. /**
  52545. * Gizmo that enables rotating a mesh along 3 axis
  52546. */
  52547. export class RotationGizmo extends Gizmo {
  52548. /**
  52549. * Internal gizmo used for interactions on the x axis
  52550. */
  52551. xGizmo: PlaneRotationGizmo;
  52552. /**
  52553. * Internal gizmo used for interactions on the y axis
  52554. */
  52555. yGizmo: PlaneRotationGizmo;
  52556. /**
  52557. * Internal gizmo used for interactions on the z axis
  52558. */
  52559. zGizmo: PlaneRotationGizmo;
  52560. /** Fires an event when any of it's sub gizmos are dragged */
  52561. onDragStartObservable: Observable<unknown>;
  52562. /** Fires an event when any of it's sub gizmos are released from dragging */
  52563. onDragEndObservable: Observable<unknown>;
  52564. private _meshAttached;
  52565. get attachedMesh(): Nullable<AbstractMesh>;
  52566. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52567. /**
  52568. * Creates a RotationGizmo
  52569. * @param gizmoLayer The utility layer the gizmo will be added to
  52570. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52571. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52572. */
  52573. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52574. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52575. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52576. /**
  52577. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52578. */
  52579. set snapDistance(value: number);
  52580. get snapDistance(): number;
  52581. /**
  52582. * Ratio for the scale of the gizmo (Default: 1)
  52583. */
  52584. set scaleRatio(value: number);
  52585. get scaleRatio(): number;
  52586. /**
  52587. * Disposes of the gizmo
  52588. */
  52589. dispose(): void;
  52590. /**
  52591. * CustomMeshes are not supported by this gizmo
  52592. * @param mesh The mesh to replace the default mesh of the gizmo
  52593. */
  52594. setCustomMesh(mesh: Mesh): void;
  52595. }
  52596. }
  52597. declare module BABYLON {
  52598. /**
  52599. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52600. */
  52601. export class GizmoManager implements IDisposable {
  52602. private scene;
  52603. /**
  52604. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52605. */
  52606. gizmos: {
  52607. positionGizmo: Nullable<PositionGizmo>;
  52608. rotationGizmo: Nullable<RotationGizmo>;
  52609. scaleGizmo: Nullable<ScaleGizmo>;
  52610. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52611. };
  52612. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52613. clearGizmoOnEmptyPointerEvent: boolean;
  52614. /** Fires an event when the manager is attached to a mesh */
  52615. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52616. private _gizmosEnabled;
  52617. private _pointerObserver;
  52618. private _attachedMesh;
  52619. private _boundingBoxColor;
  52620. private _defaultUtilityLayer;
  52621. private _defaultKeepDepthUtilityLayer;
  52622. /**
  52623. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52624. */
  52625. boundingBoxDragBehavior: SixDofDragBehavior;
  52626. /**
  52627. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52628. */
  52629. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52630. /**
  52631. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52632. */
  52633. usePointerToAttachGizmos: boolean;
  52634. /**
  52635. * Utility layer that the bounding box gizmo belongs to
  52636. */
  52637. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52638. /**
  52639. * Utility layer that all gizmos besides bounding box belong to
  52640. */
  52641. get utilityLayer(): UtilityLayerRenderer;
  52642. /**
  52643. * Instatiates a gizmo manager
  52644. * @param scene the scene to overlay the gizmos on top of
  52645. */
  52646. constructor(scene: Scene);
  52647. /**
  52648. * Attaches a set of gizmos to the specified mesh
  52649. * @param mesh The mesh the gizmo's should be attached to
  52650. */
  52651. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52652. /**
  52653. * If the position gizmo is enabled
  52654. */
  52655. set positionGizmoEnabled(value: boolean);
  52656. get positionGizmoEnabled(): boolean;
  52657. /**
  52658. * If the rotation gizmo is enabled
  52659. */
  52660. set rotationGizmoEnabled(value: boolean);
  52661. get rotationGizmoEnabled(): boolean;
  52662. /**
  52663. * If the scale gizmo is enabled
  52664. */
  52665. set scaleGizmoEnabled(value: boolean);
  52666. get scaleGizmoEnabled(): boolean;
  52667. /**
  52668. * If the boundingBox gizmo is enabled
  52669. */
  52670. set boundingBoxGizmoEnabled(value: boolean);
  52671. get boundingBoxGizmoEnabled(): boolean;
  52672. /**
  52673. * Disposes of the gizmo manager
  52674. */
  52675. dispose(): void;
  52676. }
  52677. }
  52678. declare module BABYLON {
  52679. /**
  52680. * A directional light is defined by a direction (what a surprise!).
  52681. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52682. * 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.
  52683. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52684. */
  52685. export class DirectionalLight extends ShadowLight {
  52686. private _shadowFrustumSize;
  52687. /**
  52688. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52689. */
  52690. get shadowFrustumSize(): number;
  52691. /**
  52692. * Specifies a fix frustum size for the shadow generation.
  52693. */
  52694. set shadowFrustumSize(value: number);
  52695. private _shadowOrthoScale;
  52696. /**
  52697. * Gets the shadow projection scale against the optimal computed one.
  52698. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52699. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52700. */
  52701. get shadowOrthoScale(): number;
  52702. /**
  52703. * Sets the shadow projection scale against the optimal computed one.
  52704. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52705. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52706. */
  52707. set shadowOrthoScale(value: number);
  52708. /**
  52709. * Automatically compute the projection matrix to best fit (including all the casters)
  52710. * on each frame.
  52711. */
  52712. autoUpdateExtends: boolean;
  52713. /**
  52714. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52715. * on each frame. autoUpdateExtends must be set to true for this to work
  52716. */
  52717. autoCalcShadowZBounds: boolean;
  52718. private _orthoLeft;
  52719. private _orthoRight;
  52720. private _orthoTop;
  52721. private _orthoBottom;
  52722. /**
  52723. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52724. * The directional light is emitted from everywhere in the given direction.
  52725. * It can cast shadows.
  52726. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52727. * @param name The friendly name of the light
  52728. * @param direction The direction of the light
  52729. * @param scene The scene the light belongs to
  52730. */
  52731. constructor(name: string, direction: Vector3, scene: Scene);
  52732. /**
  52733. * Returns the string "DirectionalLight".
  52734. * @return The class name
  52735. */
  52736. getClassName(): string;
  52737. /**
  52738. * Returns the integer 1.
  52739. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52740. */
  52741. getTypeID(): number;
  52742. /**
  52743. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52744. * Returns the DirectionalLight Shadow projection matrix.
  52745. */
  52746. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52747. /**
  52748. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52749. * Returns the DirectionalLight Shadow projection matrix.
  52750. */
  52751. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52752. /**
  52753. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52754. * Returns the DirectionalLight Shadow projection matrix.
  52755. */
  52756. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52757. protected _buildUniformLayout(): void;
  52758. /**
  52759. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52760. * @param effect The effect to update
  52761. * @param lightIndex The index of the light in the effect to update
  52762. * @returns The directional light
  52763. */
  52764. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52765. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52766. /**
  52767. * Gets the minZ used for shadow according to both the scene and the light.
  52768. *
  52769. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52770. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52771. * @param activeCamera The camera we are returning the min for
  52772. * @returns the depth min z
  52773. */
  52774. getDepthMinZ(activeCamera: Camera): number;
  52775. /**
  52776. * Gets the maxZ used for shadow according to both the scene and the light.
  52777. *
  52778. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52779. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52780. * @param activeCamera The camera we are returning the max for
  52781. * @returns the depth max z
  52782. */
  52783. getDepthMaxZ(activeCamera: Camera): number;
  52784. /**
  52785. * Prepares the list of defines specific to the light type.
  52786. * @param defines the list of defines
  52787. * @param lightIndex defines the index of the light for the effect
  52788. */
  52789. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52790. }
  52791. }
  52792. declare module BABYLON {
  52793. /**
  52794. * Class containing static functions to help procedurally build meshes
  52795. */
  52796. export class HemisphereBuilder {
  52797. /**
  52798. * Creates a hemisphere mesh
  52799. * @param name defines the name of the mesh
  52800. * @param options defines the options used to create the mesh
  52801. * @param scene defines the hosting scene
  52802. * @returns the hemisphere mesh
  52803. */
  52804. static CreateHemisphere(name: string, options: {
  52805. segments?: number;
  52806. diameter?: number;
  52807. sideOrientation?: number;
  52808. }, scene: any): Mesh;
  52809. }
  52810. }
  52811. declare module BABYLON {
  52812. /**
  52813. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52814. * These values define a cone of light starting from the position, emitting toward the direction.
  52815. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52816. * and the exponent defines the speed of the decay of the light with distance (reach).
  52817. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52818. */
  52819. export class SpotLight extends ShadowLight {
  52820. private _angle;
  52821. private _innerAngle;
  52822. private _cosHalfAngle;
  52823. private _lightAngleScale;
  52824. private _lightAngleOffset;
  52825. /**
  52826. * Gets the cone angle of the spot light in Radians.
  52827. */
  52828. get angle(): number;
  52829. /**
  52830. * Sets the cone angle of the spot light in Radians.
  52831. */
  52832. set angle(value: number);
  52833. /**
  52834. * Only used in gltf falloff mode, this defines the angle where
  52835. * the directional falloff will start before cutting at angle which could be seen
  52836. * as outer angle.
  52837. */
  52838. get innerAngle(): number;
  52839. /**
  52840. * Only used in gltf falloff mode, this defines the angle where
  52841. * the directional falloff will start before cutting at angle which could be seen
  52842. * as outer angle.
  52843. */
  52844. set innerAngle(value: number);
  52845. private _shadowAngleScale;
  52846. /**
  52847. * Allows scaling the angle of the light for shadow generation only.
  52848. */
  52849. get shadowAngleScale(): number;
  52850. /**
  52851. * Allows scaling the angle of the light for shadow generation only.
  52852. */
  52853. set shadowAngleScale(value: number);
  52854. /**
  52855. * The light decay speed with the distance from the emission spot.
  52856. */
  52857. exponent: number;
  52858. private _projectionTextureMatrix;
  52859. /**
  52860. * Allows reading the projecton texture
  52861. */
  52862. get projectionTextureMatrix(): Matrix;
  52863. protected _projectionTextureLightNear: number;
  52864. /**
  52865. * Gets the near clip of the Spotlight for texture projection.
  52866. */
  52867. get projectionTextureLightNear(): number;
  52868. /**
  52869. * Sets the near clip of the Spotlight for texture projection.
  52870. */
  52871. set projectionTextureLightNear(value: number);
  52872. protected _projectionTextureLightFar: number;
  52873. /**
  52874. * Gets the far clip of the Spotlight for texture projection.
  52875. */
  52876. get projectionTextureLightFar(): number;
  52877. /**
  52878. * Sets the far clip of the Spotlight for texture projection.
  52879. */
  52880. set projectionTextureLightFar(value: number);
  52881. protected _projectionTextureUpDirection: Vector3;
  52882. /**
  52883. * Gets the Up vector of the Spotlight for texture projection.
  52884. */
  52885. get projectionTextureUpDirection(): Vector3;
  52886. /**
  52887. * Sets the Up vector of the Spotlight for texture projection.
  52888. */
  52889. set projectionTextureUpDirection(value: Vector3);
  52890. private _projectionTexture;
  52891. /**
  52892. * Gets the projection texture of the light.
  52893. */
  52894. get projectionTexture(): Nullable<BaseTexture>;
  52895. /**
  52896. * Sets the projection texture of the light.
  52897. */
  52898. set projectionTexture(value: Nullable<BaseTexture>);
  52899. private _projectionTextureViewLightDirty;
  52900. private _projectionTextureProjectionLightDirty;
  52901. private _projectionTextureDirty;
  52902. private _projectionTextureViewTargetVector;
  52903. private _projectionTextureViewLightMatrix;
  52904. private _projectionTextureProjectionLightMatrix;
  52905. private _projectionTextureScalingMatrix;
  52906. /**
  52907. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52908. * It can cast shadows.
  52909. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52910. * @param name The light friendly name
  52911. * @param position The position of the spot light in the scene
  52912. * @param direction The direction of the light in the scene
  52913. * @param angle The cone angle of the light in Radians
  52914. * @param exponent The light decay speed with the distance from the emission spot
  52915. * @param scene The scene the lights belongs to
  52916. */
  52917. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52918. /**
  52919. * Returns the string "SpotLight".
  52920. * @returns the class name
  52921. */
  52922. getClassName(): string;
  52923. /**
  52924. * Returns the integer 2.
  52925. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52926. */
  52927. getTypeID(): number;
  52928. /**
  52929. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52930. */
  52931. protected _setDirection(value: Vector3): void;
  52932. /**
  52933. * Overrides the position setter to recompute the projection texture view light Matrix.
  52934. */
  52935. protected _setPosition(value: Vector3): void;
  52936. /**
  52937. * 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.
  52938. * Returns the SpotLight.
  52939. */
  52940. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52941. protected _computeProjectionTextureViewLightMatrix(): void;
  52942. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52943. /**
  52944. * Main function for light texture projection matrix computing.
  52945. */
  52946. protected _computeProjectionTextureMatrix(): void;
  52947. protected _buildUniformLayout(): void;
  52948. private _computeAngleValues;
  52949. /**
  52950. * Sets the passed Effect "effect" with the Light textures.
  52951. * @param effect The effect to update
  52952. * @param lightIndex The index of the light in the effect to update
  52953. * @returns The light
  52954. */
  52955. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52956. /**
  52957. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52958. * @param effect The effect to update
  52959. * @param lightIndex The index of the light in the effect to update
  52960. * @returns The spot light
  52961. */
  52962. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52963. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52964. /**
  52965. * Disposes the light and the associated resources.
  52966. */
  52967. dispose(): void;
  52968. /**
  52969. * Prepares the list of defines specific to the light type.
  52970. * @param defines the list of defines
  52971. * @param lightIndex defines the index of the light for the effect
  52972. */
  52973. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52974. }
  52975. }
  52976. declare module BABYLON {
  52977. /**
  52978. * Gizmo that enables viewing a light
  52979. */
  52980. export class LightGizmo extends Gizmo {
  52981. private _lightMesh;
  52982. private _material;
  52983. private _cachedPosition;
  52984. private _cachedForward;
  52985. private _attachedMeshParent;
  52986. /**
  52987. * Creates a LightGizmo
  52988. * @param gizmoLayer The utility layer the gizmo will be added to
  52989. */
  52990. constructor(gizmoLayer?: UtilityLayerRenderer);
  52991. private _light;
  52992. /**
  52993. * The light that the gizmo is attached to
  52994. */
  52995. set light(light: Nullable<Light>);
  52996. get light(): Nullable<Light>;
  52997. /**
  52998. * Gets the material used to render the light gizmo
  52999. */
  53000. get material(): StandardMaterial;
  53001. /**
  53002. * @hidden
  53003. * Updates the gizmo to match the attached mesh's position/rotation
  53004. */
  53005. protected _update(): void;
  53006. private static _Scale;
  53007. /**
  53008. * Creates the lines for a light mesh
  53009. */
  53010. private static _CreateLightLines;
  53011. /**
  53012. * Disposes of the light gizmo
  53013. */
  53014. dispose(): void;
  53015. private static _CreateHemisphericLightMesh;
  53016. private static _CreatePointLightMesh;
  53017. private static _CreateSpotLightMesh;
  53018. private static _CreateDirectionalLightMesh;
  53019. }
  53020. }
  53021. declare module BABYLON {
  53022. /** @hidden */
  53023. export var backgroundFragmentDeclaration: {
  53024. name: string;
  53025. shader: string;
  53026. };
  53027. }
  53028. declare module BABYLON {
  53029. /** @hidden */
  53030. export var backgroundUboDeclaration: {
  53031. name: string;
  53032. shader: string;
  53033. };
  53034. }
  53035. declare module BABYLON {
  53036. /** @hidden */
  53037. export var backgroundPixelShader: {
  53038. name: string;
  53039. shader: string;
  53040. };
  53041. }
  53042. declare module BABYLON {
  53043. /** @hidden */
  53044. export var backgroundVertexDeclaration: {
  53045. name: string;
  53046. shader: string;
  53047. };
  53048. }
  53049. declare module BABYLON {
  53050. /** @hidden */
  53051. export var backgroundVertexShader: {
  53052. name: string;
  53053. shader: string;
  53054. };
  53055. }
  53056. declare module BABYLON {
  53057. /**
  53058. * Background material used to create an efficient environement around your scene.
  53059. */
  53060. export class BackgroundMaterial extends PushMaterial {
  53061. /**
  53062. * Standard reflectance value at parallel view angle.
  53063. */
  53064. static StandardReflectance0: number;
  53065. /**
  53066. * Standard reflectance value at grazing angle.
  53067. */
  53068. static StandardReflectance90: number;
  53069. protected _primaryColor: Color3;
  53070. /**
  53071. * Key light Color (multiply against the environement texture)
  53072. */
  53073. primaryColor: Color3;
  53074. protected __perceptualColor: Nullable<Color3>;
  53075. /**
  53076. * Experimental Internal Use Only.
  53077. *
  53078. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53079. * This acts as a helper to set the primary color to a more "human friendly" value.
  53080. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53081. * output color as close as possible from the chosen value.
  53082. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53083. * part of lighting setup.)
  53084. */
  53085. get _perceptualColor(): Nullable<Color3>;
  53086. set _perceptualColor(value: Nullable<Color3>);
  53087. protected _primaryColorShadowLevel: float;
  53088. /**
  53089. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53090. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53091. */
  53092. get primaryColorShadowLevel(): float;
  53093. set primaryColorShadowLevel(value: float);
  53094. protected _primaryColorHighlightLevel: float;
  53095. /**
  53096. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53097. * The primary color is used at the level chosen to define what the white area would look.
  53098. */
  53099. get primaryColorHighlightLevel(): float;
  53100. set primaryColorHighlightLevel(value: float);
  53101. protected _reflectionTexture: Nullable<BaseTexture>;
  53102. /**
  53103. * Reflection Texture used in the material.
  53104. * Should be author in a specific way for the best result (refer to the documentation).
  53105. */
  53106. reflectionTexture: Nullable<BaseTexture>;
  53107. protected _reflectionBlur: float;
  53108. /**
  53109. * Reflection Texture level of blur.
  53110. *
  53111. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53112. * texture twice.
  53113. */
  53114. reflectionBlur: float;
  53115. protected _diffuseTexture: Nullable<BaseTexture>;
  53116. /**
  53117. * Diffuse Texture used in the material.
  53118. * Should be author in a specific way for the best result (refer to the documentation).
  53119. */
  53120. diffuseTexture: Nullable<BaseTexture>;
  53121. protected _shadowLights: Nullable<IShadowLight[]>;
  53122. /**
  53123. * Specify the list of lights casting shadow on the material.
  53124. * All scene shadow lights will be included if null.
  53125. */
  53126. shadowLights: Nullable<IShadowLight[]>;
  53127. protected _shadowLevel: float;
  53128. /**
  53129. * Helps adjusting the shadow to a softer level if required.
  53130. * 0 means black shadows and 1 means no shadows.
  53131. */
  53132. shadowLevel: float;
  53133. protected _sceneCenter: Vector3;
  53134. /**
  53135. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53136. * It is usually zero but might be interesting to modify according to your setup.
  53137. */
  53138. sceneCenter: Vector3;
  53139. protected _opacityFresnel: boolean;
  53140. /**
  53141. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53142. * This helps ensuring a nice transition when the camera goes under the ground.
  53143. */
  53144. opacityFresnel: boolean;
  53145. protected _reflectionFresnel: boolean;
  53146. /**
  53147. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53148. * This helps adding a mirror texture on the ground.
  53149. */
  53150. reflectionFresnel: boolean;
  53151. protected _reflectionFalloffDistance: number;
  53152. /**
  53153. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53154. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53155. */
  53156. reflectionFalloffDistance: number;
  53157. protected _reflectionAmount: number;
  53158. /**
  53159. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53160. */
  53161. reflectionAmount: number;
  53162. protected _reflectionReflectance0: number;
  53163. /**
  53164. * This specifies the weight of the reflection at grazing angle.
  53165. */
  53166. reflectionReflectance0: number;
  53167. protected _reflectionReflectance90: number;
  53168. /**
  53169. * This specifies the weight of the reflection at a perpendicular point of view.
  53170. */
  53171. reflectionReflectance90: number;
  53172. /**
  53173. * Sets the reflection reflectance fresnel values according to the default standard
  53174. * empirically know to work well :-)
  53175. */
  53176. set reflectionStandardFresnelWeight(value: number);
  53177. protected _useRGBColor: boolean;
  53178. /**
  53179. * Helps to directly use the maps channels instead of their level.
  53180. */
  53181. useRGBColor: boolean;
  53182. protected _enableNoise: boolean;
  53183. /**
  53184. * This helps reducing the banding effect that could occur on the background.
  53185. */
  53186. enableNoise: boolean;
  53187. /**
  53188. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53189. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53190. * Recommended to be keep at 1.0 except for special cases.
  53191. */
  53192. get fovMultiplier(): number;
  53193. set fovMultiplier(value: number);
  53194. private _fovMultiplier;
  53195. /**
  53196. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53197. */
  53198. useEquirectangularFOV: boolean;
  53199. private _maxSimultaneousLights;
  53200. /**
  53201. * Number of Simultaneous lights allowed on the material.
  53202. */
  53203. maxSimultaneousLights: int;
  53204. /**
  53205. * Default configuration related to image processing available in the Background Material.
  53206. */
  53207. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53208. /**
  53209. * Keep track of the image processing observer to allow dispose and replace.
  53210. */
  53211. private _imageProcessingObserver;
  53212. /**
  53213. * Attaches a new image processing configuration to the PBR Material.
  53214. * @param configuration (if null the scene configuration will be use)
  53215. */
  53216. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53217. /**
  53218. * Gets the image processing configuration used either in this material.
  53219. */
  53220. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53221. /**
  53222. * Sets the Default image processing configuration used either in the this material.
  53223. *
  53224. * If sets to null, the scene one is in use.
  53225. */
  53226. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53227. /**
  53228. * Gets wether the color curves effect is enabled.
  53229. */
  53230. get cameraColorCurvesEnabled(): boolean;
  53231. /**
  53232. * Sets wether the color curves effect is enabled.
  53233. */
  53234. set cameraColorCurvesEnabled(value: boolean);
  53235. /**
  53236. * Gets wether the color grading effect is enabled.
  53237. */
  53238. get cameraColorGradingEnabled(): boolean;
  53239. /**
  53240. * Gets wether the color grading effect is enabled.
  53241. */
  53242. set cameraColorGradingEnabled(value: boolean);
  53243. /**
  53244. * Gets wether tonemapping is enabled or not.
  53245. */
  53246. get cameraToneMappingEnabled(): boolean;
  53247. /**
  53248. * Sets wether tonemapping is enabled or not
  53249. */
  53250. set cameraToneMappingEnabled(value: boolean);
  53251. /**
  53252. * The camera exposure used on this material.
  53253. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53254. * This corresponds to a photographic exposure.
  53255. */
  53256. get cameraExposure(): float;
  53257. /**
  53258. * The camera exposure used on this material.
  53259. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53260. * This corresponds to a photographic exposure.
  53261. */
  53262. set cameraExposure(value: float);
  53263. /**
  53264. * Gets The camera contrast used on this material.
  53265. */
  53266. get cameraContrast(): float;
  53267. /**
  53268. * Sets The camera contrast used on this material.
  53269. */
  53270. set cameraContrast(value: float);
  53271. /**
  53272. * Gets the Color Grading 2D Lookup Texture.
  53273. */
  53274. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53275. /**
  53276. * Sets the Color Grading 2D Lookup Texture.
  53277. */
  53278. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53279. /**
  53280. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53281. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53282. * 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;
  53283. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53284. */
  53285. get cameraColorCurves(): Nullable<ColorCurves>;
  53286. /**
  53287. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53288. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53289. * 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;
  53290. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53291. */
  53292. set cameraColorCurves(value: Nullable<ColorCurves>);
  53293. /**
  53294. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53295. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53296. */
  53297. switchToBGR: boolean;
  53298. private _renderTargets;
  53299. private _reflectionControls;
  53300. private _white;
  53301. private _primaryShadowColor;
  53302. private _primaryHighlightColor;
  53303. /**
  53304. * Instantiates a Background Material in the given scene
  53305. * @param name The friendly name of the material
  53306. * @param scene The scene to add the material to
  53307. */
  53308. constructor(name: string, scene: Scene);
  53309. /**
  53310. * Gets a boolean indicating that current material needs to register RTT
  53311. */
  53312. get hasRenderTargetTextures(): boolean;
  53313. /**
  53314. * The entire material has been created in order to prevent overdraw.
  53315. * @returns false
  53316. */
  53317. needAlphaTesting(): boolean;
  53318. /**
  53319. * The entire material has been created in order to prevent overdraw.
  53320. * @returns true if blending is enable
  53321. */
  53322. needAlphaBlending(): boolean;
  53323. /**
  53324. * Checks wether the material is ready to be rendered for a given mesh.
  53325. * @param mesh The mesh to render
  53326. * @param subMesh The submesh to check against
  53327. * @param useInstances Specify wether or not the material is used with instances
  53328. * @returns true if all the dependencies are ready (Textures, Effects...)
  53329. */
  53330. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53331. /**
  53332. * Compute the primary color according to the chosen perceptual color.
  53333. */
  53334. private _computePrimaryColorFromPerceptualColor;
  53335. /**
  53336. * Compute the highlights and shadow colors according to their chosen levels.
  53337. */
  53338. private _computePrimaryColors;
  53339. /**
  53340. * Build the uniform buffer used in the material.
  53341. */
  53342. buildUniformLayout(): void;
  53343. /**
  53344. * Unbind the material.
  53345. */
  53346. unbind(): void;
  53347. /**
  53348. * Bind only the world matrix to the material.
  53349. * @param world The world matrix to bind.
  53350. */
  53351. bindOnlyWorldMatrix(world: Matrix): void;
  53352. /**
  53353. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53354. * @param world The world matrix to bind.
  53355. * @param subMesh The submesh to bind for.
  53356. */
  53357. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53358. /**
  53359. * Checks to see if a texture is used in the material.
  53360. * @param texture - Base texture to use.
  53361. * @returns - Boolean specifying if a texture is used in the material.
  53362. */
  53363. hasTexture(texture: BaseTexture): boolean;
  53364. /**
  53365. * Dispose the material.
  53366. * @param forceDisposeEffect Force disposal of the associated effect.
  53367. * @param forceDisposeTextures Force disposal of the associated textures.
  53368. */
  53369. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53370. /**
  53371. * Clones the material.
  53372. * @param name The cloned name.
  53373. * @returns The cloned material.
  53374. */
  53375. clone(name: string): BackgroundMaterial;
  53376. /**
  53377. * Serializes the current material to its JSON representation.
  53378. * @returns The JSON representation.
  53379. */
  53380. serialize(): any;
  53381. /**
  53382. * Gets the class name of the material
  53383. * @returns "BackgroundMaterial"
  53384. */
  53385. getClassName(): string;
  53386. /**
  53387. * Parse a JSON input to create back a background material.
  53388. * @param source The JSON data to parse
  53389. * @param scene The scene to create the parsed material in
  53390. * @param rootUrl The root url of the assets the material depends upon
  53391. * @returns the instantiated BackgroundMaterial.
  53392. */
  53393. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53394. }
  53395. }
  53396. declare module BABYLON {
  53397. /**
  53398. * Represents the different options available during the creation of
  53399. * a Environment helper.
  53400. *
  53401. * This can control the default ground, skybox and image processing setup of your scene.
  53402. */
  53403. export interface IEnvironmentHelperOptions {
  53404. /**
  53405. * Specifies whether or not to create a ground.
  53406. * True by default.
  53407. */
  53408. createGround: boolean;
  53409. /**
  53410. * Specifies the ground size.
  53411. * 15 by default.
  53412. */
  53413. groundSize: number;
  53414. /**
  53415. * The texture used on the ground for the main color.
  53416. * Comes from the BabylonJS CDN by default.
  53417. *
  53418. * Remarks: Can be either a texture or a url.
  53419. */
  53420. groundTexture: string | BaseTexture;
  53421. /**
  53422. * The color mixed in the ground texture by default.
  53423. * BabylonJS clearColor by default.
  53424. */
  53425. groundColor: Color3;
  53426. /**
  53427. * Specifies the ground opacity.
  53428. * 1 by default.
  53429. */
  53430. groundOpacity: number;
  53431. /**
  53432. * Enables the ground to receive shadows.
  53433. * True by default.
  53434. */
  53435. enableGroundShadow: boolean;
  53436. /**
  53437. * Helps preventing the shadow to be fully black on the ground.
  53438. * 0.5 by default.
  53439. */
  53440. groundShadowLevel: number;
  53441. /**
  53442. * Creates a mirror texture attach to the ground.
  53443. * false by default.
  53444. */
  53445. enableGroundMirror: boolean;
  53446. /**
  53447. * Specifies the ground mirror size ratio.
  53448. * 0.3 by default as the default kernel is 64.
  53449. */
  53450. groundMirrorSizeRatio: number;
  53451. /**
  53452. * Specifies the ground mirror blur kernel size.
  53453. * 64 by default.
  53454. */
  53455. groundMirrorBlurKernel: number;
  53456. /**
  53457. * Specifies the ground mirror visibility amount.
  53458. * 1 by default
  53459. */
  53460. groundMirrorAmount: number;
  53461. /**
  53462. * Specifies the ground mirror reflectance weight.
  53463. * This uses the standard weight of the background material to setup the fresnel effect
  53464. * of the mirror.
  53465. * 1 by default.
  53466. */
  53467. groundMirrorFresnelWeight: number;
  53468. /**
  53469. * Specifies the ground mirror Falloff distance.
  53470. * This can helps reducing the size of the reflection.
  53471. * 0 by Default.
  53472. */
  53473. groundMirrorFallOffDistance: number;
  53474. /**
  53475. * Specifies the ground mirror texture type.
  53476. * Unsigned Int by Default.
  53477. */
  53478. groundMirrorTextureType: number;
  53479. /**
  53480. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53481. * the shown objects.
  53482. */
  53483. groundYBias: number;
  53484. /**
  53485. * Specifies whether or not to create a skybox.
  53486. * True by default.
  53487. */
  53488. createSkybox: boolean;
  53489. /**
  53490. * Specifies the skybox size.
  53491. * 20 by default.
  53492. */
  53493. skyboxSize: number;
  53494. /**
  53495. * The texture used on the skybox for the main color.
  53496. * Comes from the BabylonJS CDN by default.
  53497. *
  53498. * Remarks: Can be either a texture or a url.
  53499. */
  53500. skyboxTexture: string | BaseTexture;
  53501. /**
  53502. * The color mixed in the skybox texture by default.
  53503. * BabylonJS clearColor by default.
  53504. */
  53505. skyboxColor: Color3;
  53506. /**
  53507. * The background rotation around the Y axis of the scene.
  53508. * This helps aligning the key lights of your scene with the background.
  53509. * 0 by default.
  53510. */
  53511. backgroundYRotation: number;
  53512. /**
  53513. * Compute automatically the size of the elements to best fit with the scene.
  53514. */
  53515. sizeAuto: boolean;
  53516. /**
  53517. * Default position of the rootMesh if autoSize is not true.
  53518. */
  53519. rootPosition: Vector3;
  53520. /**
  53521. * Sets up the image processing in the scene.
  53522. * true by default.
  53523. */
  53524. setupImageProcessing: boolean;
  53525. /**
  53526. * The texture used as your environment texture in the scene.
  53527. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53528. *
  53529. * Remarks: Can be either a texture or a url.
  53530. */
  53531. environmentTexture: string | BaseTexture;
  53532. /**
  53533. * The value of the exposure to apply to the scene.
  53534. * 0.6 by default if setupImageProcessing is true.
  53535. */
  53536. cameraExposure: number;
  53537. /**
  53538. * The value of the contrast to apply to the scene.
  53539. * 1.6 by default if setupImageProcessing is true.
  53540. */
  53541. cameraContrast: number;
  53542. /**
  53543. * Specifies whether or not tonemapping should be enabled in the scene.
  53544. * true by default if setupImageProcessing is true.
  53545. */
  53546. toneMappingEnabled: boolean;
  53547. }
  53548. /**
  53549. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53550. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53551. * It also helps with the default setup of your imageProcessing configuration.
  53552. */
  53553. export class EnvironmentHelper {
  53554. /**
  53555. * Default ground texture URL.
  53556. */
  53557. private static _groundTextureCDNUrl;
  53558. /**
  53559. * Default skybox texture URL.
  53560. */
  53561. private static _skyboxTextureCDNUrl;
  53562. /**
  53563. * Default environment texture URL.
  53564. */
  53565. private static _environmentTextureCDNUrl;
  53566. /**
  53567. * Creates the default options for the helper.
  53568. */
  53569. private static _getDefaultOptions;
  53570. private _rootMesh;
  53571. /**
  53572. * Gets the root mesh created by the helper.
  53573. */
  53574. get rootMesh(): Mesh;
  53575. private _skybox;
  53576. /**
  53577. * Gets the skybox created by the helper.
  53578. */
  53579. get skybox(): Nullable<Mesh>;
  53580. private _skyboxTexture;
  53581. /**
  53582. * Gets the skybox texture created by the helper.
  53583. */
  53584. get skyboxTexture(): Nullable<BaseTexture>;
  53585. private _skyboxMaterial;
  53586. /**
  53587. * Gets the skybox material created by the helper.
  53588. */
  53589. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53590. private _ground;
  53591. /**
  53592. * Gets the ground mesh created by the helper.
  53593. */
  53594. get ground(): Nullable<Mesh>;
  53595. private _groundTexture;
  53596. /**
  53597. * Gets the ground texture created by the helper.
  53598. */
  53599. get groundTexture(): Nullable<BaseTexture>;
  53600. private _groundMirror;
  53601. /**
  53602. * Gets the ground mirror created by the helper.
  53603. */
  53604. get groundMirror(): Nullable<MirrorTexture>;
  53605. /**
  53606. * Gets the ground mirror render list to helps pushing the meshes
  53607. * you wish in the ground reflection.
  53608. */
  53609. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53610. private _groundMaterial;
  53611. /**
  53612. * Gets the ground material created by the helper.
  53613. */
  53614. get groundMaterial(): Nullable<BackgroundMaterial>;
  53615. /**
  53616. * Stores the creation options.
  53617. */
  53618. private readonly _scene;
  53619. private _options;
  53620. /**
  53621. * This observable will be notified with any error during the creation of the environment,
  53622. * mainly texture creation errors.
  53623. */
  53624. onErrorObservable: Observable<{
  53625. message?: string;
  53626. exception?: any;
  53627. }>;
  53628. /**
  53629. * constructor
  53630. * @param options Defines the options we want to customize the helper
  53631. * @param scene The scene to add the material to
  53632. */
  53633. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53634. /**
  53635. * Updates the background according to the new options
  53636. * @param options
  53637. */
  53638. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53639. /**
  53640. * Sets the primary color of all the available elements.
  53641. * @param color the main color to affect to the ground and the background
  53642. */
  53643. setMainColor(color: Color3): void;
  53644. /**
  53645. * Setup the image processing according to the specified options.
  53646. */
  53647. private _setupImageProcessing;
  53648. /**
  53649. * Setup the environment texture according to the specified options.
  53650. */
  53651. private _setupEnvironmentTexture;
  53652. /**
  53653. * Setup the background according to the specified options.
  53654. */
  53655. private _setupBackground;
  53656. /**
  53657. * Get the scene sizes according to the setup.
  53658. */
  53659. private _getSceneSize;
  53660. /**
  53661. * Setup the ground according to the specified options.
  53662. */
  53663. private _setupGround;
  53664. /**
  53665. * Setup the ground material according to the specified options.
  53666. */
  53667. private _setupGroundMaterial;
  53668. /**
  53669. * Setup the ground diffuse texture according to the specified options.
  53670. */
  53671. private _setupGroundDiffuseTexture;
  53672. /**
  53673. * Setup the ground mirror texture according to the specified options.
  53674. */
  53675. private _setupGroundMirrorTexture;
  53676. /**
  53677. * Setup the ground to receive the mirror texture.
  53678. */
  53679. private _setupMirrorInGroundMaterial;
  53680. /**
  53681. * Setup the skybox according to the specified options.
  53682. */
  53683. private _setupSkybox;
  53684. /**
  53685. * Setup the skybox material according to the specified options.
  53686. */
  53687. private _setupSkyboxMaterial;
  53688. /**
  53689. * Setup the skybox reflection texture according to the specified options.
  53690. */
  53691. private _setupSkyboxReflectionTexture;
  53692. private _errorHandler;
  53693. /**
  53694. * Dispose all the elements created by the Helper.
  53695. */
  53696. dispose(): void;
  53697. }
  53698. }
  53699. declare module BABYLON {
  53700. /**
  53701. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53702. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53703. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53704. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53705. */
  53706. export class PhotoDome extends TransformNode {
  53707. /**
  53708. * Define the image as a Monoscopic panoramic 360 image.
  53709. */
  53710. static readonly MODE_MONOSCOPIC: number;
  53711. /**
  53712. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53713. */
  53714. static readonly MODE_TOPBOTTOM: number;
  53715. /**
  53716. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53717. */
  53718. static readonly MODE_SIDEBYSIDE: number;
  53719. private _useDirectMapping;
  53720. /**
  53721. * The texture being displayed on the sphere
  53722. */
  53723. protected _photoTexture: Texture;
  53724. /**
  53725. * Gets or sets the texture being displayed on the sphere
  53726. */
  53727. get photoTexture(): Texture;
  53728. set photoTexture(value: Texture);
  53729. /**
  53730. * Observable raised when an error occured while loading the 360 image
  53731. */
  53732. onLoadErrorObservable: Observable<string>;
  53733. /**
  53734. * The skybox material
  53735. */
  53736. protected _material: BackgroundMaterial;
  53737. /**
  53738. * The surface used for the skybox
  53739. */
  53740. protected _mesh: Mesh;
  53741. /**
  53742. * Gets the mesh used for the skybox.
  53743. */
  53744. get mesh(): Mesh;
  53745. /**
  53746. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53747. * Also see the options.resolution property.
  53748. */
  53749. get fovMultiplier(): number;
  53750. set fovMultiplier(value: number);
  53751. private _imageMode;
  53752. /**
  53753. * Gets or set the current video mode for the video. It can be:
  53754. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53755. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53756. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53757. */
  53758. get imageMode(): number;
  53759. set imageMode(value: number);
  53760. /**
  53761. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53762. * @param name Element's name, child elements will append suffixes for their own names.
  53763. * @param urlsOfPhoto defines the url of the photo to display
  53764. * @param options defines an object containing optional or exposed sub element properties
  53765. * @param onError defines a callback called when an error occured while loading the texture
  53766. */
  53767. constructor(name: string, urlOfPhoto: string, options: {
  53768. resolution?: number;
  53769. size?: number;
  53770. useDirectMapping?: boolean;
  53771. faceForward?: boolean;
  53772. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53773. private _onBeforeCameraRenderObserver;
  53774. private _changeImageMode;
  53775. /**
  53776. * Releases resources associated with this node.
  53777. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53778. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53779. */
  53780. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53781. }
  53782. }
  53783. declare module BABYLON {
  53784. /**
  53785. * Class used to host RGBD texture specific utilities
  53786. */
  53787. export class RGBDTextureTools {
  53788. /**
  53789. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53790. * @param texture the texture to expand.
  53791. */
  53792. static ExpandRGBDTexture(texture: Texture): void;
  53793. }
  53794. }
  53795. declare module BABYLON {
  53796. /**
  53797. * Class used to host texture specific utilities
  53798. */
  53799. export class BRDFTextureTools {
  53800. /**
  53801. * Prevents texture cache collision
  53802. */
  53803. private static _instanceNumber;
  53804. /**
  53805. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53806. * @param scene defines the hosting scene
  53807. * @returns the environment BRDF texture
  53808. */
  53809. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53810. private static _environmentBRDFBase64Texture;
  53811. }
  53812. }
  53813. declare module BABYLON {
  53814. /**
  53815. * @hidden
  53816. */
  53817. export interface IMaterialClearCoatDefines {
  53818. CLEARCOAT: boolean;
  53819. CLEARCOAT_DEFAULTIOR: boolean;
  53820. CLEARCOAT_TEXTURE: boolean;
  53821. CLEARCOAT_TEXTUREDIRECTUV: number;
  53822. CLEARCOAT_BUMP: boolean;
  53823. CLEARCOAT_BUMPDIRECTUV: number;
  53824. CLEARCOAT_TINT: boolean;
  53825. CLEARCOAT_TINT_TEXTURE: boolean;
  53826. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53827. /** @hidden */
  53828. _areTexturesDirty: boolean;
  53829. }
  53830. /**
  53831. * Define the code related to the clear coat parameters of the pbr material.
  53832. */
  53833. export class PBRClearCoatConfiguration {
  53834. /**
  53835. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53836. * The default fits with a polyurethane material.
  53837. */
  53838. private static readonly _DefaultIndexOfRefraction;
  53839. private _isEnabled;
  53840. /**
  53841. * Defines if the clear coat is enabled in the material.
  53842. */
  53843. isEnabled: boolean;
  53844. /**
  53845. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53846. */
  53847. intensity: number;
  53848. /**
  53849. * Defines the clear coat layer roughness.
  53850. */
  53851. roughness: number;
  53852. private _indexOfRefraction;
  53853. /**
  53854. * Defines the index of refraction of the clear coat.
  53855. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53856. * The default fits with a polyurethane material.
  53857. * Changing the default value is more performance intensive.
  53858. */
  53859. indexOfRefraction: number;
  53860. private _texture;
  53861. /**
  53862. * Stores the clear coat values in a texture.
  53863. */
  53864. texture: Nullable<BaseTexture>;
  53865. private _bumpTexture;
  53866. /**
  53867. * Define the clear coat specific bump texture.
  53868. */
  53869. bumpTexture: Nullable<BaseTexture>;
  53870. private _isTintEnabled;
  53871. /**
  53872. * Defines if the clear coat tint is enabled in the material.
  53873. */
  53874. isTintEnabled: boolean;
  53875. /**
  53876. * Defines the clear coat tint of the material.
  53877. * This is only use if tint is enabled
  53878. */
  53879. tintColor: Color3;
  53880. /**
  53881. * Defines the distance at which the tint color should be found in the
  53882. * clear coat media.
  53883. * This is only use if tint is enabled
  53884. */
  53885. tintColorAtDistance: number;
  53886. /**
  53887. * Defines the clear coat layer thickness.
  53888. * This is only use if tint is enabled
  53889. */
  53890. tintThickness: number;
  53891. private _tintTexture;
  53892. /**
  53893. * Stores the clear tint values in a texture.
  53894. * rgb is tint
  53895. * a is a thickness factor
  53896. */
  53897. tintTexture: Nullable<BaseTexture>;
  53898. /** @hidden */
  53899. private _internalMarkAllSubMeshesAsTexturesDirty;
  53900. /** @hidden */
  53901. _markAllSubMeshesAsTexturesDirty(): void;
  53902. /**
  53903. * Instantiate a new istance of clear coat configuration.
  53904. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53905. */
  53906. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53907. /**
  53908. * Gets wehter the submesh is ready to be used or not.
  53909. * @param defines the list of "defines" to update.
  53910. * @param scene defines the scene the material belongs to.
  53911. * @param engine defines the engine the material belongs to.
  53912. * @param disableBumpMap defines wether the material disables bump or not.
  53913. * @returns - boolean indicating that the submesh is ready or not.
  53914. */
  53915. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53916. /**
  53917. * Checks to see if a texture is used in the material.
  53918. * @param defines the list of "defines" to update.
  53919. * @param scene defines the scene to the material belongs to.
  53920. */
  53921. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53922. /**
  53923. * Binds the material data.
  53924. * @param uniformBuffer defines the Uniform buffer to fill in.
  53925. * @param scene defines the scene the material belongs to.
  53926. * @param engine defines the engine the material belongs to.
  53927. * @param disableBumpMap defines wether the material disables bump or not.
  53928. * @param isFrozen defines wether the material is frozen or not.
  53929. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53930. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53931. */
  53932. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53933. /**
  53934. * Checks to see if a texture is used in the material.
  53935. * @param texture - Base texture to use.
  53936. * @returns - Boolean specifying if a texture is used in the material.
  53937. */
  53938. hasTexture(texture: BaseTexture): boolean;
  53939. /**
  53940. * Returns an array of the actively used textures.
  53941. * @param activeTextures Array of BaseTextures
  53942. */
  53943. getActiveTextures(activeTextures: BaseTexture[]): void;
  53944. /**
  53945. * Returns the animatable textures.
  53946. * @param animatables Array of animatable textures.
  53947. */
  53948. getAnimatables(animatables: IAnimatable[]): void;
  53949. /**
  53950. * Disposes the resources of the material.
  53951. * @param forceDisposeTextures - Forces the disposal of all textures.
  53952. */
  53953. dispose(forceDisposeTextures?: boolean): void;
  53954. /**
  53955. * Get the current class name of the texture useful for serialization or dynamic coding.
  53956. * @returns "PBRClearCoatConfiguration"
  53957. */
  53958. getClassName(): string;
  53959. /**
  53960. * Add fallbacks to the effect fallbacks list.
  53961. * @param defines defines the Base texture to use.
  53962. * @param fallbacks defines the current fallback list.
  53963. * @param currentRank defines the current fallback rank.
  53964. * @returns the new fallback rank.
  53965. */
  53966. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53967. /**
  53968. * Add the required uniforms to the current list.
  53969. * @param uniforms defines the current uniform list.
  53970. */
  53971. static AddUniforms(uniforms: string[]): void;
  53972. /**
  53973. * Add the required samplers to the current list.
  53974. * @param samplers defines the current sampler list.
  53975. */
  53976. static AddSamplers(samplers: string[]): void;
  53977. /**
  53978. * Add the required uniforms to the current buffer.
  53979. * @param uniformBuffer defines the current uniform buffer.
  53980. */
  53981. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53982. /**
  53983. * Makes a duplicate of the current configuration into another one.
  53984. * @param clearCoatConfiguration define the config where to copy the info
  53985. */
  53986. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53987. /**
  53988. * Serializes this clear coat configuration.
  53989. * @returns - An object with the serialized config.
  53990. */
  53991. serialize(): any;
  53992. /**
  53993. * Parses a anisotropy Configuration from a serialized object.
  53994. * @param source - Serialized object.
  53995. * @param scene Defines the scene we are parsing for
  53996. * @param rootUrl Defines the rootUrl to load from
  53997. */
  53998. parse(source: any, scene: Scene, rootUrl: string): void;
  53999. }
  54000. }
  54001. declare module BABYLON {
  54002. /**
  54003. * @hidden
  54004. */
  54005. export interface IMaterialAnisotropicDefines {
  54006. ANISOTROPIC: boolean;
  54007. ANISOTROPIC_TEXTURE: boolean;
  54008. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54009. MAINUV1: boolean;
  54010. _areTexturesDirty: boolean;
  54011. _needUVs: boolean;
  54012. }
  54013. /**
  54014. * Define the code related to the anisotropic parameters of the pbr material.
  54015. */
  54016. export class PBRAnisotropicConfiguration {
  54017. private _isEnabled;
  54018. /**
  54019. * Defines if the anisotropy is enabled in the material.
  54020. */
  54021. isEnabled: boolean;
  54022. /**
  54023. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54024. */
  54025. intensity: number;
  54026. /**
  54027. * Defines if the effect is along the tangents, bitangents or in between.
  54028. * By default, the effect is "strectching" the highlights along the tangents.
  54029. */
  54030. direction: Vector2;
  54031. private _texture;
  54032. /**
  54033. * Stores the anisotropy values in a texture.
  54034. * rg is direction (like normal from -1 to 1)
  54035. * b is a intensity
  54036. */
  54037. texture: Nullable<BaseTexture>;
  54038. /** @hidden */
  54039. private _internalMarkAllSubMeshesAsTexturesDirty;
  54040. /** @hidden */
  54041. _markAllSubMeshesAsTexturesDirty(): void;
  54042. /**
  54043. * Instantiate a new istance of anisotropy configuration.
  54044. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54045. */
  54046. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54047. /**
  54048. * Specifies that the submesh is ready to be used.
  54049. * @param defines the list of "defines" to update.
  54050. * @param scene defines the scene the material belongs to.
  54051. * @returns - boolean indicating that the submesh is ready or not.
  54052. */
  54053. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54054. /**
  54055. * Checks to see if a texture is used in the material.
  54056. * @param defines the list of "defines" to update.
  54057. * @param mesh the mesh we are preparing the defines for.
  54058. * @param scene defines the scene the material belongs to.
  54059. */
  54060. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54061. /**
  54062. * Binds the material data.
  54063. * @param uniformBuffer defines the Uniform buffer to fill in.
  54064. * @param scene defines the scene the material belongs to.
  54065. * @param isFrozen defines wether the material is frozen or not.
  54066. */
  54067. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54068. /**
  54069. * Checks to see if a texture is used in the material.
  54070. * @param texture - Base texture to use.
  54071. * @returns - Boolean specifying if a texture is used in the material.
  54072. */
  54073. hasTexture(texture: BaseTexture): boolean;
  54074. /**
  54075. * Returns an array of the actively used textures.
  54076. * @param activeTextures Array of BaseTextures
  54077. */
  54078. getActiveTextures(activeTextures: BaseTexture[]): void;
  54079. /**
  54080. * Returns the animatable textures.
  54081. * @param animatables Array of animatable textures.
  54082. */
  54083. getAnimatables(animatables: IAnimatable[]): void;
  54084. /**
  54085. * Disposes the resources of the material.
  54086. * @param forceDisposeTextures - Forces the disposal of all textures.
  54087. */
  54088. dispose(forceDisposeTextures?: boolean): void;
  54089. /**
  54090. * Get the current class name of the texture useful for serialization or dynamic coding.
  54091. * @returns "PBRAnisotropicConfiguration"
  54092. */
  54093. getClassName(): string;
  54094. /**
  54095. * Add fallbacks to the effect fallbacks list.
  54096. * @param defines defines the Base texture to use.
  54097. * @param fallbacks defines the current fallback list.
  54098. * @param currentRank defines the current fallback rank.
  54099. * @returns the new fallback rank.
  54100. */
  54101. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54102. /**
  54103. * Add the required uniforms to the current list.
  54104. * @param uniforms defines the current uniform list.
  54105. */
  54106. static AddUniforms(uniforms: string[]): void;
  54107. /**
  54108. * Add the required uniforms to the current buffer.
  54109. * @param uniformBuffer defines the current uniform buffer.
  54110. */
  54111. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54112. /**
  54113. * Add the required samplers to the current list.
  54114. * @param samplers defines the current sampler list.
  54115. */
  54116. static AddSamplers(samplers: string[]): void;
  54117. /**
  54118. * Makes a duplicate of the current configuration into another one.
  54119. * @param anisotropicConfiguration define the config where to copy the info
  54120. */
  54121. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54122. /**
  54123. * Serializes this anisotropy configuration.
  54124. * @returns - An object with the serialized config.
  54125. */
  54126. serialize(): any;
  54127. /**
  54128. * Parses a anisotropy Configuration from a serialized object.
  54129. * @param source - Serialized object.
  54130. * @param scene Defines the scene we are parsing for
  54131. * @param rootUrl Defines the rootUrl to load from
  54132. */
  54133. parse(source: any, scene: Scene, rootUrl: string): void;
  54134. }
  54135. }
  54136. declare module BABYLON {
  54137. /**
  54138. * @hidden
  54139. */
  54140. export interface IMaterialBRDFDefines {
  54141. BRDF_V_HEIGHT_CORRELATED: boolean;
  54142. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54143. SPHERICAL_HARMONICS: boolean;
  54144. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54145. /** @hidden */
  54146. _areMiscDirty: boolean;
  54147. }
  54148. /**
  54149. * Define the code related to the BRDF parameters of the pbr material.
  54150. */
  54151. export class PBRBRDFConfiguration {
  54152. /**
  54153. * Default value used for the energy conservation.
  54154. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54155. */
  54156. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54157. /**
  54158. * Default value used for the Smith Visibility Height Correlated mode.
  54159. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54160. */
  54161. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54162. /**
  54163. * Default value used for the IBL diffuse part.
  54164. * This can help switching back to the polynomials mode globally which is a tiny bit
  54165. * less GPU intensive at the drawback of a lower quality.
  54166. */
  54167. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54168. /**
  54169. * Default value used for activating energy conservation for the specular workflow.
  54170. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54171. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54172. */
  54173. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54174. private _useEnergyConservation;
  54175. /**
  54176. * Defines if the material uses energy conservation.
  54177. */
  54178. useEnergyConservation: boolean;
  54179. private _useSmithVisibilityHeightCorrelated;
  54180. /**
  54181. * LEGACY Mode set to false
  54182. * Defines if the material uses height smith correlated visibility term.
  54183. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54184. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54185. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54186. * Not relying on height correlated will also disable energy conservation.
  54187. */
  54188. useSmithVisibilityHeightCorrelated: boolean;
  54189. private _useSphericalHarmonics;
  54190. /**
  54191. * LEGACY Mode set to false
  54192. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54193. * diffuse part of the IBL.
  54194. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54195. * to the ground truth.
  54196. */
  54197. useSphericalHarmonics: boolean;
  54198. private _useSpecularGlossinessInputEnergyConservation;
  54199. /**
  54200. * Defines if the material uses energy conservation, when the specular workflow is active.
  54201. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54202. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54203. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54204. */
  54205. useSpecularGlossinessInputEnergyConservation: boolean;
  54206. /** @hidden */
  54207. private _internalMarkAllSubMeshesAsMiscDirty;
  54208. /** @hidden */
  54209. _markAllSubMeshesAsMiscDirty(): void;
  54210. /**
  54211. * Instantiate a new istance of clear coat configuration.
  54212. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54213. */
  54214. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54215. /**
  54216. * Checks to see if a texture is used in the material.
  54217. * @param defines the list of "defines" to update.
  54218. */
  54219. prepareDefines(defines: IMaterialBRDFDefines): void;
  54220. /**
  54221. * Get the current class name of the texture useful for serialization or dynamic coding.
  54222. * @returns "PBRClearCoatConfiguration"
  54223. */
  54224. getClassName(): string;
  54225. /**
  54226. * Makes a duplicate of the current configuration into another one.
  54227. * @param brdfConfiguration define the config where to copy the info
  54228. */
  54229. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54230. /**
  54231. * Serializes this BRDF configuration.
  54232. * @returns - An object with the serialized config.
  54233. */
  54234. serialize(): any;
  54235. /**
  54236. * Parses a anisotropy Configuration from a serialized object.
  54237. * @param source - Serialized object.
  54238. * @param scene Defines the scene we are parsing for
  54239. * @param rootUrl Defines the rootUrl to load from
  54240. */
  54241. parse(source: any, scene: Scene, rootUrl: string): void;
  54242. }
  54243. }
  54244. declare module BABYLON {
  54245. /**
  54246. * @hidden
  54247. */
  54248. export interface IMaterialSheenDefines {
  54249. SHEEN: boolean;
  54250. SHEEN_TEXTURE: boolean;
  54251. SHEEN_TEXTUREDIRECTUV: number;
  54252. SHEEN_LINKWITHALBEDO: boolean;
  54253. SHEEN_ROUGHNESS: boolean;
  54254. SHEEN_ALBEDOSCALING: boolean;
  54255. /** @hidden */
  54256. _areTexturesDirty: boolean;
  54257. }
  54258. /**
  54259. * Define the code related to the Sheen parameters of the pbr material.
  54260. */
  54261. export class PBRSheenConfiguration {
  54262. private _isEnabled;
  54263. /**
  54264. * Defines if the material uses sheen.
  54265. */
  54266. isEnabled: boolean;
  54267. private _linkSheenWithAlbedo;
  54268. /**
  54269. * Defines if the sheen is linked to the sheen color.
  54270. */
  54271. linkSheenWithAlbedo: boolean;
  54272. /**
  54273. * Defines the sheen intensity.
  54274. */
  54275. intensity: number;
  54276. /**
  54277. * Defines the sheen color.
  54278. */
  54279. color: Color3;
  54280. private _texture;
  54281. /**
  54282. * Stores the sheen tint values in a texture.
  54283. * rgb is tint
  54284. * a is a intensity
  54285. */
  54286. texture: Nullable<BaseTexture>;
  54287. private _roughness;
  54288. /**
  54289. * Defines the sheen roughness.
  54290. * It is not taken into account if linkSheenWithAlbedo is true.
  54291. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54292. */
  54293. roughness: Nullable<number>;
  54294. private _albedoScaling;
  54295. /**
  54296. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54297. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54298. * making it easier to setup and tweak the effect
  54299. */
  54300. albedoScaling: boolean;
  54301. /** @hidden */
  54302. private _internalMarkAllSubMeshesAsTexturesDirty;
  54303. /** @hidden */
  54304. _markAllSubMeshesAsTexturesDirty(): void;
  54305. /**
  54306. * Instantiate a new istance of clear coat configuration.
  54307. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54308. */
  54309. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54310. /**
  54311. * Specifies that the submesh is ready to be used.
  54312. * @param defines the list of "defines" to update.
  54313. * @param scene defines the scene the material belongs to.
  54314. * @returns - boolean indicating that the submesh is ready or not.
  54315. */
  54316. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54317. /**
  54318. * Checks to see if a texture is used in the material.
  54319. * @param defines the list of "defines" to update.
  54320. * @param scene defines the scene the material belongs to.
  54321. */
  54322. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54323. /**
  54324. * Binds the material data.
  54325. * @param uniformBuffer defines the Uniform buffer to fill in.
  54326. * @param scene defines the scene the material belongs to.
  54327. * @param isFrozen defines wether the material is frozen or not.
  54328. */
  54329. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54330. /**
  54331. * Checks to see if a texture is used in the material.
  54332. * @param texture - Base texture to use.
  54333. * @returns - Boolean specifying if a texture is used in the material.
  54334. */
  54335. hasTexture(texture: BaseTexture): boolean;
  54336. /**
  54337. * Returns an array of the actively used textures.
  54338. * @param activeTextures Array of BaseTextures
  54339. */
  54340. getActiveTextures(activeTextures: BaseTexture[]): void;
  54341. /**
  54342. * Returns the animatable textures.
  54343. * @param animatables Array of animatable textures.
  54344. */
  54345. getAnimatables(animatables: IAnimatable[]): void;
  54346. /**
  54347. * Disposes the resources of the material.
  54348. * @param forceDisposeTextures - Forces the disposal of all textures.
  54349. */
  54350. dispose(forceDisposeTextures?: boolean): void;
  54351. /**
  54352. * Get the current class name of the texture useful for serialization or dynamic coding.
  54353. * @returns "PBRSheenConfiguration"
  54354. */
  54355. getClassName(): string;
  54356. /**
  54357. * Add fallbacks to the effect fallbacks list.
  54358. * @param defines defines the Base texture to use.
  54359. * @param fallbacks defines the current fallback list.
  54360. * @param currentRank defines the current fallback rank.
  54361. * @returns the new fallback rank.
  54362. */
  54363. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54364. /**
  54365. * Add the required uniforms to the current list.
  54366. * @param uniforms defines the current uniform list.
  54367. */
  54368. static AddUniforms(uniforms: string[]): void;
  54369. /**
  54370. * Add the required uniforms to the current buffer.
  54371. * @param uniformBuffer defines the current uniform buffer.
  54372. */
  54373. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54374. /**
  54375. * Add the required samplers to the current list.
  54376. * @param samplers defines the current sampler list.
  54377. */
  54378. static AddSamplers(samplers: string[]): void;
  54379. /**
  54380. * Makes a duplicate of the current configuration into another one.
  54381. * @param sheenConfiguration define the config where to copy the info
  54382. */
  54383. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54384. /**
  54385. * Serializes this BRDF configuration.
  54386. * @returns - An object with the serialized config.
  54387. */
  54388. serialize(): any;
  54389. /**
  54390. * Parses a anisotropy Configuration from a serialized object.
  54391. * @param source - Serialized object.
  54392. * @param scene Defines the scene we are parsing for
  54393. * @param rootUrl Defines the rootUrl to load from
  54394. */
  54395. parse(source: any, scene: Scene, rootUrl: string): void;
  54396. }
  54397. }
  54398. declare module BABYLON {
  54399. /**
  54400. * @hidden
  54401. */
  54402. export interface IMaterialSubSurfaceDefines {
  54403. SUBSURFACE: boolean;
  54404. SS_REFRACTION: boolean;
  54405. SS_TRANSLUCENCY: boolean;
  54406. SS_SCATTERING: boolean;
  54407. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54408. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54409. SS_REFRACTIONMAP_3D: boolean;
  54410. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54411. SS_LODINREFRACTIONALPHA: boolean;
  54412. SS_GAMMAREFRACTION: boolean;
  54413. SS_RGBDREFRACTION: boolean;
  54414. SS_LINEARSPECULARREFRACTION: boolean;
  54415. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54416. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54417. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54418. /** @hidden */
  54419. _areTexturesDirty: boolean;
  54420. }
  54421. /**
  54422. * Define the code related to the sub surface parameters of the pbr material.
  54423. */
  54424. export class PBRSubSurfaceConfiguration {
  54425. private _isRefractionEnabled;
  54426. /**
  54427. * Defines if the refraction is enabled in the material.
  54428. */
  54429. isRefractionEnabled: boolean;
  54430. private _isTranslucencyEnabled;
  54431. /**
  54432. * Defines if the translucency is enabled in the material.
  54433. */
  54434. isTranslucencyEnabled: boolean;
  54435. private _isScatteringEnabled;
  54436. /**
  54437. * Defines the refraction intensity of the material.
  54438. * The refraction when enabled replaces the Diffuse part of the material.
  54439. * The intensity helps transitionning between diffuse and refraction.
  54440. */
  54441. refractionIntensity: number;
  54442. /**
  54443. * Defines the translucency intensity of the material.
  54444. * When translucency has been enabled, this defines how much of the "translucency"
  54445. * is addded to the diffuse part of the material.
  54446. */
  54447. translucencyIntensity: number;
  54448. /**
  54449. * Defines the scattering intensity of the material.
  54450. * When scattering has been enabled, this defines how much of the "scattered light"
  54451. * is addded to the diffuse part of the material.
  54452. */
  54453. scatteringIntensity: number;
  54454. /**
  54455. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54456. */
  54457. useAlbedoToTintRefraction: boolean;
  54458. private _thicknessTexture;
  54459. /**
  54460. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54461. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54462. * 0 would mean minimumThickness
  54463. * 1 would mean maximumThickness
  54464. * The other channels might be use as a mask to vary the different effects intensity.
  54465. */
  54466. thicknessTexture: Nullable<BaseTexture>;
  54467. private _refractionTexture;
  54468. /**
  54469. * Defines the texture to use for refraction.
  54470. */
  54471. refractionTexture: Nullable<BaseTexture>;
  54472. private _indexOfRefraction;
  54473. /**
  54474. * Index of refraction of the material base layer.
  54475. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54476. *
  54477. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54478. *
  54479. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54480. */
  54481. indexOfRefraction: number;
  54482. private _volumeIndexOfRefraction;
  54483. /**
  54484. * Index of refraction of the material's volume.
  54485. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54486. *
  54487. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54488. * the volume will use the same IOR as the surface.
  54489. */
  54490. get volumeIndexOfRefraction(): number;
  54491. set volumeIndexOfRefraction(value: number);
  54492. private _invertRefractionY;
  54493. /**
  54494. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54495. */
  54496. invertRefractionY: boolean;
  54497. private _linkRefractionWithTransparency;
  54498. /**
  54499. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54500. * Materials half opaque for instance using refraction could benefit from this control.
  54501. */
  54502. linkRefractionWithTransparency: boolean;
  54503. /**
  54504. * Defines the minimum thickness stored in the thickness map.
  54505. * If no thickness map is defined, this value will be used to simulate thickness.
  54506. */
  54507. minimumThickness: number;
  54508. /**
  54509. * Defines the maximum thickness stored in the thickness map.
  54510. */
  54511. maximumThickness: number;
  54512. /**
  54513. * Defines the volume tint of the material.
  54514. * This is used for both translucency and scattering.
  54515. */
  54516. tintColor: Color3;
  54517. /**
  54518. * Defines the distance at which the tint color should be found in the media.
  54519. * This is used for refraction only.
  54520. */
  54521. tintColorAtDistance: number;
  54522. /**
  54523. * Defines how far each channel transmit through the media.
  54524. * It is defined as a color to simplify it selection.
  54525. */
  54526. diffusionDistance: Color3;
  54527. private _useMaskFromThicknessTexture;
  54528. /**
  54529. * Stores the intensity of the different subsurface effects in the thickness texture.
  54530. * * the green channel is the translucency intensity.
  54531. * * the blue channel is the scattering intensity.
  54532. * * the alpha channel is the refraction intensity.
  54533. */
  54534. useMaskFromThicknessTexture: boolean;
  54535. /** @hidden */
  54536. private _internalMarkAllSubMeshesAsTexturesDirty;
  54537. /** @hidden */
  54538. _markAllSubMeshesAsTexturesDirty(): void;
  54539. /**
  54540. * Instantiate a new istance of sub surface configuration.
  54541. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54542. */
  54543. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54544. /**
  54545. * Gets wehter the submesh is ready to be used or not.
  54546. * @param defines the list of "defines" to update.
  54547. * @param scene defines the scene the material belongs to.
  54548. * @returns - boolean indicating that the submesh is ready or not.
  54549. */
  54550. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54551. /**
  54552. * Checks to see if a texture is used in the material.
  54553. * @param defines the list of "defines" to update.
  54554. * @param scene defines the scene to the material belongs to.
  54555. */
  54556. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54557. /**
  54558. * Binds the material data.
  54559. * @param uniformBuffer defines the Uniform buffer to fill in.
  54560. * @param scene defines the scene the material belongs to.
  54561. * @param engine defines the engine the material belongs to.
  54562. * @param isFrozen defines whether the material is frozen or not.
  54563. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54564. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54565. */
  54566. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54567. /**
  54568. * Unbinds the material from the mesh.
  54569. * @param activeEffect defines the effect that should be unbound from.
  54570. * @returns true if unbound, otherwise false
  54571. */
  54572. unbind(activeEffect: Effect): boolean;
  54573. /**
  54574. * Returns the texture used for refraction or null if none is used.
  54575. * @param scene defines the scene the material belongs to.
  54576. * @returns - Refraction texture if present. If no refraction texture and refraction
  54577. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54578. */
  54579. private _getRefractionTexture;
  54580. /**
  54581. * Returns true if alpha blending should be disabled.
  54582. */
  54583. get disableAlphaBlending(): boolean;
  54584. /**
  54585. * Fills the list of render target textures.
  54586. * @param renderTargets the list of render targets to update
  54587. */
  54588. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54589. /**
  54590. * Checks to see if a texture is used in the material.
  54591. * @param texture - Base texture to use.
  54592. * @returns - Boolean specifying if a texture is used in the material.
  54593. */
  54594. hasTexture(texture: BaseTexture): boolean;
  54595. /**
  54596. * Gets a boolean indicating that current material needs to register RTT
  54597. * @returns true if this uses a render target otherwise false.
  54598. */
  54599. hasRenderTargetTextures(): boolean;
  54600. /**
  54601. * Returns an array of the actively used textures.
  54602. * @param activeTextures Array of BaseTextures
  54603. */
  54604. getActiveTextures(activeTextures: BaseTexture[]): void;
  54605. /**
  54606. * Returns the animatable textures.
  54607. * @param animatables Array of animatable textures.
  54608. */
  54609. getAnimatables(animatables: IAnimatable[]): void;
  54610. /**
  54611. * Disposes the resources of the material.
  54612. * @param forceDisposeTextures - Forces the disposal of all textures.
  54613. */
  54614. dispose(forceDisposeTextures?: boolean): void;
  54615. /**
  54616. * Get the current class name of the texture useful for serialization or dynamic coding.
  54617. * @returns "PBRSubSurfaceConfiguration"
  54618. */
  54619. getClassName(): string;
  54620. /**
  54621. * Add fallbacks to the effect fallbacks list.
  54622. * @param defines defines the Base texture to use.
  54623. * @param fallbacks defines the current fallback list.
  54624. * @param currentRank defines the current fallback rank.
  54625. * @returns the new fallback rank.
  54626. */
  54627. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54628. /**
  54629. * Add the required uniforms to the current list.
  54630. * @param uniforms defines the current uniform list.
  54631. */
  54632. static AddUniforms(uniforms: string[]): void;
  54633. /**
  54634. * Add the required samplers to the current list.
  54635. * @param samplers defines the current sampler list.
  54636. */
  54637. static AddSamplers(samplers: string[]): void;
  54638. /**
  54639. * Add the required uniforms to the current buffer.
  54640. * @param uniformBuffer defines the current uniform buffer.
  54641. */
  54642. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54643. /**
  54644. * Makes a duplicate of the current configuration into another one.
  54645. * @param configuration define the config where to copy the info
  54646. */
  54647. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54648. /**
  54649. * Serializes this Sub Surface configuration.
  54650. * @returns - An object with the serialized config.
  54651. */
  54652. serialize(): any;
  54653. /**
  54654. * Parses a anisotropy Configuration from a serialized object.
  54655. * @param source - Serialized object.
  54656. * @param scene Defines the scene we are parsing for
  54657. * @param rootUrl Defines the rootUrl to load from
  54658. */
  54659. parse(source: any, scene: Scene, rootUrl: string): void;
  54660. }
  54661. }
  54662. declare module BABYLON {
  54663. /** @hidden */
  54664. export var pbrFragmentDeclaration: {
  54665. name: string;
  54666. shader: string;
  54667. };
  54668. }
  54669. declare module BABYLON {
  54670. /** @hidden */
  54671. export var pbrUboDeclaration: {
  54672. name: string;
  54673. shader: string;
  54674. };
  54675. }
  54676. declare module BABYLON {
  54677. /** @hidden */
  54678. export var pbrFragmentExtraDeclaration: {
  54679. name: string;
  54680. shader: string;
  54681. };
  54682. }
  54683. declare module BABYLON {
  54684. /** @hidden */
  54685. export var pbrFragmentSamplersDeclaration: {
  54686. name: string;
  54687. shader: string;
  54688. };
  54689. }
  54690. declare module BABYLON {
  54691. /** @hidden */
  54692. export var importanceSampling: {
  54693. name: string;
  54694. shader: string;
  54695. };
  54696. }
  54697. declare module BABYLON {
  54698. /** @hidden */
  54699. export var pbrHelperFunctions: {
  54700. name: string;
  54701. shader: string;
  54702. };
  54703. }
  54704. declare module BABYLON {
  54705. /** @hidden */
  54706. export var harmonicsFunctions: {
  54707. name: string;
  54708. shader: string;
  54709. };
  54710. }
  54711. declare module BABYLON {
  54712. /** @hidden */
  54713. export var pbrDirectLightingSetupFunctions: {
  54714. name: string;
  54715. shader: string;
  54716. };
  54717. }
  54718. declare module BABYLON {
  54719. /** @hidden */
  54720. export var pbrDirectLightingFalloffFunctions: {
  54721. name: string;
  54722. shader: string;
  54723. };
  54724. }
  54725. declare module BABYLON {
  54726. /** @hidden */
  54727. export var pbrBRDFFunctions: {
  54728. name: string;
  54729. shader: string;
  54730. };
  54731. }
  54732. declare module BABYLON {
  54733. /** @hidden */
  54734. export var hdrFilteringFunctions: {
  54735. name: string;
  54736. shader: string;
  54737. };
  54738. }
  54739. declare module BABYLON {
  54740. /** @hidden */
  54741. export var pbrDirectLightingFunctions: {
  54742. name: string;
  54743. shader: string;
  54744. };
  54745. }
  54746. declare module BABYLON {
  54747. /** @hidden */
  54748. export var pbrIBLFunctions: {
  54749. name: string;
  54750. shader: string;
  54751. };
  54752. }
  54753. declare module BABYLON {
  54754. /** @hidden */
  54755. export var pbrBlockAlbedoOpacity: {
  54756. name: string;
  54757. shader: string;
  54758. };
  54759. }
  54760. declare module BABYLON {
  54761. /** @hidden */
  54762. export var pbrBlockReflectivity: {
  54763. name: string;
  54764. shader: string;
  54765. };
  54766. }
  54767. declare module BABYLON {
  54768. /** @hidden */
  54769. export var pbrBlockAmbientOcclusion: {
  54770. name: string;
  54771. shader: string;
  54772. };
  54773. }
  54774. declare module BABYLON {
  54775. /** @hidden */
  54776. export var pbrBlockAlphaFresnel: {
  54777. name: string;
  54778. shader: string;
  54779. };
  54780. }
  54781. declare module BABYLON {
  54782. /** @hidden */
  54783. export var pbrBlockAnisotropic: {
  54784. name: string;
  54785. shader: string;
  54786. };
  54787. }
  54788. declare module BABYLON {
  54789. /** @hidden */
  54790. export var pbrBlockReflection: {
  54791. name: string;
  54792. shader: string;
  54793. };
  54794. }
  54795. declare module BABYLON {
  54796. /** @hidden */
  54797. export var pbrBlockSheen: {
  54798. name: string;
  54799. shader: string;
  54800. };
  54801. }
  54802. declare module BABYLON {
  54803. /** @hidden */
  54804. export var pbrBlockClearcoat: {
  54805. name: string;
  54806. shader: string;
  54807. };
  54808. }
  54809. declare module BABYLON {
  54810. /** @hidden */
  54811. export var pbrBlockSubSurface: {
  54812. name: string;
  54813. shader: string;
  54814. };
  54815. }
  54816. declare module BABYLON {
  54817. /** @hidden */
  54818. export var pbrBlockNormalGeometric: {
  54819. name: string;
  54820. shader: string;
  54821. };
  54822. }
  54823. declare module BABYLON {
  54824. /** @hidden */
  54825. export var pbrBlockNormalFinal: {
  54826. name: string;
  54827. shader: string;
  54828. };
  54829. }
  54830. declare module BABYLON {
  54831. /** @hidden */
  54832. export var pbrBlockGeometryInfo: {
  54833. name: string;
  54834. shader: string;
  54835. };
  54836. }
  54837. declare module BABYLON {
  54838. /** @hidden */
  54839. export var pbrBlockReflectance0: {
  54840. name: string;
  54841. shader: string;
  54842. };
  54843. }
  54844. declare module BABYLON {
  54845. /** @hidden */
  54846. export var pbrBlockReflectance: {
  54847. name: string;
  54848. shader: string;
  54849. };
  54850. }
  54851. declare module BABYLON {
  54852. /** @hidden */
  54853. export var pbrBlockDirectLighting: {
  54854. name: string;
  54855. shader: string;
  54856. };
  54857. }
  54858. declare module BABYLON {
  54859. /** @hidden */
  54860. export var pbrBlockFinalLitComponents: {
  54861. name: string;
  54862. shader: string;
  54863. };
  54864. }
  54865. declare module BABYLON {
  54866. /** @hidden */
  54867. export var pbrBlockFinalUnlitComponents: {
  54868. name: string;
  54869. shader: string;
  54870. };
  54871. }
  54872. declare module BABYLON {
  54873. /** @hidden */
  54874. export var pbrBlockFinalColorComposition: {
  54875. name: string;
  54876. shader: string;
  54877. };
  54878. }
  54879. declare module BABYLON {
  54880. /** @hidden */
  54881. export var pbrBlockImageProcessing: {
  54882. name: string;
  54883. shader: string;
  54884. };
  54885. }
  54886. declare module BABYLON {
  54887. /** @hidden */
  54888. export var pbrDebug: {
  54889. name: string;
  54890. shader: string;
  54891. };
  54892. }
  54893. declare module BABYLON {
  54894. /** @hidden */
  54895. export var pbrPixelShader: {
  54896. name: string;
  54897. shader: string;
  54898. };
  54899. }
  54900. declare module BABYLON {
  54901. /** @hidden */
  54902. export var pbrVertexDeclaration: {
  54903. name: string;
  54904. shader: string;
  54905. };
  54906. }
  54907. declare module BABYLON {
  54908. /** @hidden */
  54909. export var pbrVertexShader: {
  54910. name: string;
  54911. shader: string;
  54912. };
  54913. }
  54914. declare module BABYLON {
  54915. /**
  54916. * Manages the defines for the PBR Material.
  54917. * @hidden
  54918. */
  54919. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  54920. PBR: boolean;
  54921. NUM_SAMPLES: string;
  54922. REALTIME_FILTERING: boolean;
  54923. MAINUV1: boolean;
  54924. MAINUV2: boolean;
  54925. UV1: boolean;
  54926. UV2: boolean;
  54927. ALBEDO: boolean;
  54928. GAMMAALBEDO: boolean;
  54929. ALBEDODIRECTUV: number;
  54930. VERTEXCOLOR: boolean;
  54931. DETAIL: boolean;
  54932. DETAILDIRECTUV: number;
  54933. DETAIL_NORMALBLENDMETHOD: number;
  54934. AMBIENT: boolean;
  54935. AMBIENTDIRECTUV: number;
  54936. AMBIENTINGRAYSCALE: boolean;
  54937. OPACITY: boolean;
  54938. VERTEXALPHA: boolean;
  54939. OPACITYDIRECTUV: number;
  54940. OPACITYRGB: boolean;
  54941. ALPHATEST: boolean;
  54942. DEPTHPREPASS: boolean;
  54943. ALPHABLEND: boolean;
  54944. ALPHAFROMALBEDO: boolean;
  54945. ALPHATESTVALUE: string;
  54946. SPECULAROVERALPHA: boolean;
  54947. RADIANCEOVERALPHA: boolean;
  54948. ALPHAFRESNEL: boolean;
  54949. LINEARALPHAFRESNEL: boolean;
  54950. PREMULTIPLYALPHA: boolean;
  54951. EMISSIVE: boolean;
  54952. EMISSIVEDIRECTUV: number;
  54953. REFLECTIVITY: boolean;
  54954. REFLECTIVITYDIRECTUV: number;
  54955. SPECULARTERM: boolean;
  54956. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54957. MICROSURFACEAUTOMATIC: boolean;
  54958. LODBASEDMICROSFURACE: boolean;
  54959. MICROSURFACEMAP: boolean;
  54960. MICROSURFACEMAPDIRECTUV: number;
  54961. METALLICWORKFLOW: boolean;
  54962. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54963. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54964. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54965. AOSTOREINMETALMAPRED: boolean;
  54966. METALLIC_REFLECTANCE: boolean;
  54967. METALLIC_REFLECTANCEDIRECTUV: number;
  54968. ENVIRONMENTBRDF: boolean;
  54969. ENVIRONMENTBRDF_RGBD: boolean;
  54970. NORMAL: boolean;
  54971. TANGENT: boolean;
  54972. BUMP: boolean;
  54973. BUMPDIRECTUV: number;
  54974. OBJECTSPACE_NORMALMAP: boolean;
  54975. PARALLAX: boolean;
  54976. PARALLAXOCCLUSION: boolean;
  54977. NORMALXYSCALE: boolean;
  54978. LIGHTMAP: boolean;
  54979. LIGHTMAPDIRECTUV: number;
  54980. USELIGHTMAPASSHADOWMAP: boolean;
  54981. GAMMALIGHTMAP: boolean;
  54982. RGBDLIGHTMAP: boolean;
  54983. REFLECTION: boolean;
  54984. REFLECTIONMAP_3D: boolean;
  54985. REFLECTIONMAP_SPHERICAL: boolean;
  54986. REFLECTIONMAP_PLANAR: boolean;
  54987. REFLECTIONMAP_CUBIC: boolean;
  54988. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54989. REFLECTIONMAP_PROJECTION: boolean;
  54990. REFLECTIONMAP_SKYBOX: boolean;
  54991. REFLECTIONMAP_EXPLICIT: boolean;
  54992. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54993. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54994. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54995. INVERTCUBICMAP: boolean;
  54996. USESPHERICALFROMREFLECTIONMAP: boolean;
  54997. USEIRRADIANCEMAP: boolean;
  54998. SPHERICAL_HARMONICS: boolean;
  54999. USESPHERICALINVERTEX: boolean;
  55000. REFLECTIONMAP_OPPOSITEZ: boolean;
  55001. LODINREFLECTIONALPHA: boolean;
  55002. GAMMAREFLECTION: boolean;
  55003. RGBDREFLECTION: boolean;
  55004. LINEARSPECULARREFLECTION: boolean;
  55005. RADIANCEOCCLUSION: boolean;
  55006. HORIZONOCCLUSION: boolean;
  55007. INSTANCES: boolean;
  55008. THIN_INSTANCES: boolean;
  55009. NUM_BONE_INFLUENCERS: number;
  55010. BonesPerMesh: number;
  55011. BONETEXTURE: boolean;
  55012. NONUNIFORMSCALING: boolean;
  55013. MORPHTARGETS: boolean;
  55014. MORPHTARGETS_NORMAL: boolean;
  55015. MORPHTARGETS_TANGENT: boolean;
  55016. MORPHTARGETS_UV: boolean;
  55017. NUM_MORPH_INFLUENCERS: number;
  55018. IMAGEPROCESSING: boolean;
  55019. VIGNETTE: boolean;
  55020. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55021. VIGNETTEBLENDMODEOPAQUE: boolean;
  55022. TONEMAPPING: boolean;
  55023. TONEMAPPING_ACES: boolean;
  55024. CONTRAST: boolean;
  55025. COLORCURVES: boolean;
  55026. COLORGRADING: boolean;
  55027. COLORGRADING3D: boolean;
  55028. SAMPLER3DGREENDEPTH: boolean;
  55029. SAMPLER3DBGRMAP: boolean;
  55030. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55031. EXPOSURE: boolean;
  55032. MULTIVIEW: boolean;
  55033. USEPHYSICALLIGHTFALLOFF: boolean;
  55034. USEGLTFLIGHTFALLOFF: boolean;
  55035. TWOSIDEDLIGHTING: boolean;
  55036. SHADOWFLOAT: boolean;
  55037. CLIPPLANE: boolean;
  55038. CLIPPLANE2: boolean;
  55039. CLIPPLANE3: boolean;
  55040. CLIPPLANE4: boolean;
  55041. CLIPPLANE5: boolean;
  55042. CLIPPLANE6: boolean;
  55043. POINTSIZE: boolean;
  55044. FOG: boolean;
  55045. LOGARITHMICDEPTH: boolean;
  55046. FORCENORMALFORWARD: boolean;
  55047. SPECULARAA: boolean;
  55048. CLEARCOAT: boolean;
  55049. CLEARCOAT_DEFAULTIOR: boolean;
  55050. CLEARCOAT_TEXTURE: boolean;
  55051. CLEARCOAT_TEXTUREDIRECTUV: number;
  55052. CLEARCOAT_BUMP: boolean;
  55053. CLEARCOAT_BUMPDIRECTUV: number;
  55054. CLEARCOAT_TINT: boolean;
  55055. CLEARCOAT_TINT_TEXTURE: boolean;
  55056. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55057. ANISOTROPIC: boolean;
  55058. ANISOTROPIC_TEXTURE: boolean;
  55059. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55060. BRDF_V_HEIGHT_CORRELATED: boolean;
  55061. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55062. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55063. SHEEN: boolean;
  55064. SHEEN_TEXTURE: boolean;
  55065. SHEEN_TEXTUREDIRECTUV: number;
  55066. SHEEN_LINKWITHALBEDO: boolean;
  55067. SHEEN_ROUGHNESS: boolean;
  55068. SHEEN_ALBEDOSCALING: boolean;
  55069. SUBSURFACE: boolean;
  55070. SS_REFRACTION: boolean;
  55071. SS_TRANSLUCENCY: boolean;
  55072. SS_SCATTERING: boolean;
  55073. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55074. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55075. SS_REFRACTIONMAP_3D: boolean;
  55076. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55077. SS_LODINREFRACTIONALPHA: boolean;
  55078. SS_GAMMAREFRACTION: boolean;
  55079. SS_RGBDREFRACTION: boolean;
  55080. SS_LINEARSPECULARREFRACTION: boolean;
  55081. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55082. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55083. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55084. UNLIT: boolean;
  55085. DEBUGMODE: number;
  55086. /**
  55087. * Initializes the PBR Material defines.
  55088. */
  55089. constructor();
  55090. /**
  55091. * Resets the PBR Material defines.
  55092. */
  55093. reset(): void;
  55094. }
  55095. /**
  55096. * The Physically based material base class of BJS.
  55097. *
  55098. * This offers the main features of a standard PBR material.
  55099. * For more information, please refer to the documentation :
  55100. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55101. */
  55102. export abstract class PBRBaseMaterial extends PushMaterial {
  55103. /**
  55104. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55105. */
  55106. static readonly PBRMATERIAL_OPAQUE: number;
  55107. /**
  55108. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55109. */
  55110. static readonly PBRMATERIAL_ALPHATEST: number;
  55111. /**
  55112. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55113. */
  55114. static readonly PBRMATERIAL_ALPHABLEND: number;
  55115. /**
  55116. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55117. * They are also discarded below the alpha cutoff threshold to improve performances.
  55118. */
  55119. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55120. /**
  55121. * Defines the default value of how much AO map is occluding the analytical lights
  55122. * (point spot...).
  55123. */
  55124. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55125. /**
  55126. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55127. */
  55128. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55129. /**
  55130. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55131. * to enhance interoperability with other engines.
  55132. */
  55133. static readonly LIGHTFALLOFF_GLTF: number;
  55134. /**
  55135. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55136. * to enhance interoperability with other materials.
  55137. */
  55138. static readonly LIGHTFALLOFF_STANDARD: number;
  55139. /**
  55140. * Intensity of the direct lights e.g. the four lights available in your scene.
  55141. * This impacts both the direct diffuse and specular highlights.
  55142. */
  55143. protected _directIntensity: number;
  55144. /**
  55145. * Intensity of the emissive part of the material.
  55146. * This helps controlling the emissive effect without modifying the emissive color.
  55147. */
  55148. protected _emissiveIntensity: number;
  55149. /**
  55150. * Intensity of the environment e.g. how much the environment will light the object
  55151. * either through harmonics for rough material or through the refelction for shiny ones.
  55152. */
  55153. protected _environmentIntensity: number;
  55154. /**
  55155. * This is a special control allowing the reduction of the specular highlights coming from the
  55156. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55157. */
  55158. protected _specularIntensity: number;
  55159. /**
  55160. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55161. */
  55162. private _lightingInfos;
  55163. /**
  55164. * Debug Control allowing disabling the bump map on this material.
  55165. */
  55166. protected _disableBumpMap: boolean;
  55167. /**
  55168. * AKA Diffuse Texture in standard nomenclature.
  55169. */
  55170. protected _albedoTexture: Nullable<BaseTexture>;
  55171. /**
  55172. * AKA Occlusion Texture in other nomenclature.
  55173. */
  55174. protected _ambientTexture: Nullable<BaseTexture>;
  55175. /**
  55176. * AKA Occlusion Texture Intensity in other nomenclature.
  55177. */
  55178. protected _ambientTextureStrength: number;
  55179. /**
  55180. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55181. * 1 means it completely occludes it
  55182. * 0 mean it has no impact
  55183. */
  55184. protected _ambientTextureImpactOnAnalyticalLights: number;
  55185. /**
  55186. * Stores the alpha values in a texture.
  55187. */
  55188. protected _opacityTexture: Nullable<BaseTexture>;
  55189. /**
  55190. * Stores the reflection values in a texture.
  55191. */
  55192. protected _reflectionTexture: Nullable<BaseTexture>;
  55193. /**
  55194. * Stores the emissive values in a texture.
  55195. */
  55196. protected _emissiveTexture: Nullable<BaseTexture>;
  55197. /**
  55198. * AKA Specular texture in other nomenclature.
  55199. */
  55200. protected _reflectivityTexture: Nullable<BaseTexture>;
  55201. /**
  55202. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55203. */
  55204. protected _metallicTexture: Nullable<BaseTexture>;
  55205. /**
  55206. * Specifies the metallic scalar of the metallic/roughness workflow.
  55207. * Can also be used to scale the metalness values of the metallic texture.
  55208. */
  55209. protected _metallic: Nullable<number>;
  55210. /**
  55211. * Specifies the roughness scalar of the metallic/roughness workflow.
  55212. * Can also be used to scale the roughness values of the metallic texture.
  55213. */
  55214. protected _roughness: Nullable<number>;
  55215. /**
  55216. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55217. * By default the indexOfrefraction is used to compute F0;
  55218. *
  55219. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55220. *
  55221. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55222. * F90 = metallicReflectanceColor;
  55223. */
  55224. protected _metallicF0Factor: number;
  55225. /**
  55226. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55227. * By default the F90 is always 1;
  55228. *
  55229. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55230. *
  55231. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55232. * F90 = metallicReflectanceColor;
  55233. */
  55234. protected _metallicReflectanceColor: Color3;
  55235. /**
  55236. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55237. * This is multiply against the scalar values defined in the material.
  55238. */
  55239. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55240. /**
  55241. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55242. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55243. */
  55244. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55245. /**
  55246. * Stores surface normal data used to displace a mesh in a texture.
  55247. */
  55248. protected _bumpTexture: Nullable<BaseTexture>;
  55249. /**
  55250. * Stores the pre-calculated light information of a mesh in a texture.
  55251. */
  55252. protected _lightmapTexture: Nullable<BaseTexture>;
  55253. /**
  55254. * The color of a material in ambient lighting.
  55255. */
  55256. protected _ambientColor: Color3;
  55257. /**
  55258. * AKA Diffuse Color in other nomenclature.
  55259. */
  55260. protected _albedoColor: Color3;
  55261. /**
  55262. * AKA Specular Color in other nomenclature.
  55263. */
  55264. protected _reflectivityColor: Color3;
  55265. /**
  55266. * The color applied when light is reflected from a material.
  55267. */
  55268. protected _reflectionColor: Color3;
  55269. /**
  55270. * The color applied when light is emitted from a material.
  55271. */
  55272. protected _emissiveColor: Color3;
  55273. /**
  55274. * AKA Glossiness in other nomenclature.
  55275. */
  55276. protected _microSurface: number;
  55277. /**
  55278. * Specifies that the material will use the light map as a show map.
  55279. */
  55280. protected _useLightmapAsShadowmap: boolean;
  55281. /**
  55282. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55283. * makes the reflect vector face the model (under horizon).
  55284. */
  55285. protected _useHorizonOcclusion: boolean;
  55286. /**
  55287. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55288. * too much the area relying on ambient texture to define their ambient occlusion.
  55289. */
  55290. protected _useRadianceOcclusion: boolean;
  55291. /**
  55292. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55293. */
  55294. protected _useAlphaFromAlbedoTexture: boolean;
  55295. /**
  55296. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55297. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55298. */
  55299. protected _useSpecularOverAlpha: boolean;
  55300. /**
  55301. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55302. */
  55303. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55304. /**
  55305. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55306. */
  55307. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55308. /**
  55309. * Specifies if the metallic texture contains the roughness information in its green channel.
  55310. */
  55311. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55312. /**
  55313. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55314. */
  55315. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55316. /**
  55317. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55318. */
  55319. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55320. /**
  55321. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55322. */
  55323. protected _useAmbientInGrayScale: boolean;
  55324. /**
  55325. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55326. * The material will try to infer what glossiness each pixel should be.
  55327. */
  55328. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55329. /**
  55330. * Defines the falloff type used in this material.
  55331. * It by default is Physical.
  55332. */
  55333. protected _lightFalloff: number;
  55334. /**
  55335. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55336. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55337. */
  55338. protected _useRadianceOverAlpha: boolean;
  55339. /**
  55340. * Allows using an object space normal map (instead of tangent space).
  55341. */
  55342. protected _useObjectSpaceNormalMap: boolean;
  55343. /**
  55344. * Allows using the bump map in parallax mode.
  55345. */
  55346. protected _useParallax: boolean;
  55347. /**
  55348. * Allows using the bump map in parallax occlusion mode.
  55349. */
  55350. protected _useParallaxOcclusion: boolean;
  55351. /**
  55352. * Controls the scale bias of the parallax mode.
  55353. */
  55354. protected _parallaxScaleBias: number;
  55355. /**
  55356. * If sets to true, disables all the lights affecting the material.
  55357. */
  55358. protected _disableLighting: boolean;
  55359. /**
  55360. * Number of Simultaneous lights allowed on the material.
  55361. */
  55362. protected _maxSimultaneousLights: number;
  55363. /**
  55364. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55365. */
  55366. protected _invertNormalMapX: boolean;
  55367. /**
  55368. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55369. */
  55370. protected _invertNormalMapY: boolean;
  55371. /**
  55372. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55373. */
  55374. protected _twoSidedLighting: boolean;
  55375. /**
  55376. * Defines the alpha limits in alpha test mode.
  55377. */
  55378. protected _alphaCutOff: number;
  55379. /**
  55380. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55381. */
  55382. protected _forceAlphaTest: boolean;
  55383. /**
  55384. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55385. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55386. */
  55387. protected _useAlphaFresnel: boolean;
  55388. /**
  55389. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55390. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55391. */
  55392. protected _useLinearAlphaFresnel: boolean;
  55393. /**
  55394. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55395. * from cos thetav and roughness:
  55396. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55397. */
  55398. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55399. /**
  55400. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55401. */
  55402. protected _forceIrradianceInFragment: boolean;
  55403. private _realTimeFiltering;
  55404. /**
  55405. * Enables realtime filtering on the texture.
  55406. */
  55407. get realTimeFiltering(): boolean;
  55408. set realTimeFiltering(b: boolean);
  55409. private _realTimeFilteringQuality;
  55410. /**
  55411. * Quality switch for realtime filtering
  55412. */
  55413. get realTimeFilteringQuality(): number;
  55414. set realTimeFilteringQuality(n: number);
  55415. /**
  55416. * Force normal to face away from face.
  55417. */
  55418. protected _forceNormalForward: boolean;
  55419. /**
  55420. * Enables specular anti aliasing in the PBR shader.
  55421. * It will both interacts on the Geometry for analytical and IBL lighting.
  55422. * It also prefilter the roughness map based on the bump values.
  55423. */
  55424. protected _enableSpecularAntiAliasing: boolean;
  55425. /**
  55426. * Default configuration related to image processing available in the PBR Material.
  55427. */
  55428. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55429. /**
  55430. * Keep track of the image processing observer to allow dispose and replace.
  55431. */
  55432. private _imageProcessingObserver;
  55433. /**
  55434. * Attaches a new image processing configuration to the PBR Material.
  55435. * @param configuration
  55436. */
  55437. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55438. /**
  55439. * Stores the available render targets.
  55440. */
  55441. private _renderTargets;
  55442. /**
  55443. * Sets the global ambient color for the material used in lighting calculations.
  55444. */
  55445. private _globalAmbientColor;
  55446. /**
  55447. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55448. */
  55449. private _useLogarithmicDepth;
  55450. /**
  55451. * If set to true, no lighting calculations will be applied.
  55452. */
  55453. private _unlit;
  55454. private _debugMode;
  55455. /**
  55456. * @hidden
  55457. * This is reserved for the inspector.
  55458. * Defines the material debug mode.
  55459. * It helps seeing only some components of the material while troubleshooting.
  55460. */
  55461. debugMode: number;
  55462. /**
  55463. * @hidden
  55464. * This is reserved for the inspector.
  55465. * Specify from where on screen the debug mode should start.
  55466. * The value goes from -1 (full screen) to 1 (not visible)
  55467. * It helps with side by side comparison against the final render
  55468. * This defaults to -1
  55469. */
  55470. private debugLimit;
  55471. /**
  55472. * @hidden
  55473. * This is reserved for the inspector.
  55474. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55475. * You can use the factor to better multiply the final value.
  55476. */
  55477. private debugFactor;
  55478. /**
  55479. * Defines the clear coat layer parameters for the material.
  55480. */
  55481. readonly clearCoat: PBRClearCoatConfiguration;
  55482. /**
  55483. * Defines the anisotropic parameters for the material.
  55484. */
  55485. readonly anisotropy: PBRAnisotropicConfiguration;
  55486. /**
  55487. * Defines the BRDF parameters for the material.
  55488. */
  55489. readonly brdf: PBRBRDFConfiguration;
  55490. /**
  55491. * Defines the Sheen parameters for the material.
  55492. */
  55493. readonly sheen: PBRSheenConfiguration;
  55494. /**
  55495. * Defines the SubSurface parameters for the material.
  55496. */
  55497. readonly subSurface: PBRSubSurfaceConfiguration;
  55498. /**
  55499. * Defines the detail map parameters for the material.
  55500. */
  55501. readonly detailMap: DetailMapConfiguration;
  55502. protected _rebuildInParallel: boolean;
  55503. /**
  55504. * Instantiates a new PBRMaterial instance.
  55505. *
  55506. * @param name The material name
  55507. * @param scene The scene the material will be use in.
  55508. */
  55509. constructor(name: string, scene: Scene);
  55510. /**
  55511. * Gets a boolean indicating that current material needs to register RTT
  55512. */
  55513. get hasRenderTargetTextures(): boolean;
  55514. /**
  55515. * Gets the name of the material class.
  55516. */
  55517. getClassName(): string;
  55518. /**
  55519. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55520. */
  55521. get useLogarithmicDepth(): boolean;
  55522. /**
  55523. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55524. */
  55525. set useLogarithmicDepth(value: boolean);
  55526. /**
  55527. * Returns true if alpha blending should be disabled.
  55528. */
  55529. protected get _disableAlphaBlending(): boolean;
  55530. /**
  55531. * Specifies whether or not this material should be rendered in alpha blend mode.
  55532. */
  55533. needAlphaBlending(): boolean;
  55534. /**
  55535. * Specifies whether or not this material should be rendered in alpha test mode.
  55536. */
  55537. needAlphaTesting(): boolean;
  55538. /**
  55539. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55540. */
  55541. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55542. /**
  55543. * Gets the texture used for the alpha test.
  55544. */
  55545. getAlphaTestTexture(): Nullable<BaseTexture>;
  55546. /**
  55547. * Specifies that the submesh is ready to be used.
  55548. * @param mesh - BJS mesh.
  55549. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55550. * @param useInstances - Specifies that instances should be used.
  55551. * @returns - boolean indicating that the submesh is ready or not.
  55552. */
  55553. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55554. /**
  55555. * Specifies if the material uses metallic roughness workflow.
  55556. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55557. */
  55558. isMetallicWorkflow(): boolean;
  55559. private _prepareEffect;
  55560. private _prepareDefines;
  55561. /**
  55562. * Force shader compilation
  55563. */
  55564. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55565. /**
  55566. * Initializes the uniform buffer layout for the shader.
  55567. */
  55568. buildUniformLayout(): void;
  55569. /**
  55570. * Unbinds the material from the mesh
  55571. */
  55572. unbind(): void;
  55573. /**
  55574. * Binds the submesh data.
  55575. * @param world - The world matrix.
  55576. * @param mesh - The BJS mesh.
  55577. * @param subMesh - A submesh of the BJS mesh.
  55578. */
  55579. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55580. /**
  55581. * Returns the animatable textures.
  55582. * @returns - Array of animatable textures.
  55583. */
  55584. getAnimatables(): IAnimatable[];
  55585. /**
  55586. * Returns the texture used for reflections.
  55587. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55588. */
  55589. private _getReflectionTexture;
  55590. /**
  55591. * Returns an array of the actively used textures.
  55592. * @returns - Array of BaseTextures
  55593. */
  55594. getActiveTextures(): BaseTexture[];
  55595. /**
  55596. * Checks to see if a texture is used in the material.
  55597. * @param texture - Base texture to use.
  55598. * @returns - Boolean specifying if a texture is used in the material.
  55599. */
  55600. hasTexture(texture: BaseTexture): boolean;
  55601. /**
  55602. * Disposes the resources of the material.
  55603. * @param forceDisposeEffect - Forces the disposal of effects.
  55604. * @param forceDisposeTextures - Forces the disposal of all textures.
  55605. */
  55606. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55607. }
  55608. }
  55609. declare module BABYLON {
  55610. /**
  55611. * The Physically based material of BJS.
  55612. *
  55613. * This offers the main features of a standard PBR material.
  55614. * For more information, please refer to the documentation :
  55615. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55616. */
  55617. export class PBRMaterial extends PBRBaseMaterial {
  55618. /**
  55619. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55620. */
  55621. static readonly PBRMATERIAL_OPAQUE: number;
  55622. /**
  55623. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55624. */
  55625. static readonly PBRMATERIAL_ALPHATEST: number;
  55626. /**
  55627. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55628. */
  55629. static readonly PBRMATERIAL_ALPHABLEND: number;
  55630. /**
  55631. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55632. * They are also discarded below the alpha cutoff threshold to improve performances.
  55633. */
  55634. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55635. /**
  55636. * Defines the default value of how much AO map is occluding the analytical lights
  55637. * (point spot...).
  55638. */
  55639. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55640. /**
  55641. * Intensity of the direct lights e.g. the four lights available in your scene.
  55642. * This impacts both the direct diffuse and specular highlights.
  55643. */
  55644. directIntensity: number;
  55645. /**
  55646. * Intensity of the emissive part of the material.
  55647. * This helps controlling the emissive effect without modifying the emissive color.
  55648. */
  55649. emissiveIntensity: number;
  55650. /**
  55651. * Intensity of the environment e.g. how much the environment will light the object
  55652. * either through harmonics for rough material or through the refelction for shiny ones.
  55653. */
  55654. environmentIntensity: number;
  55655. /**
  55656. * This is a special control allowing the reduction of the specular highlights coming from the
  55657. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55658. */
  55659. specularIntensity: number;
  55660. /**
  55661. * Debug Control allowing disabling the bump map on this material.
  55662. */
  55663. disableBumpMap: boolean;
  55664. /**
  55665. * AKA Diffuse Texture in standard nomenclature.
  55666. */
  55667. albedoTexture: BaseTexture;
  55668. /**
  55669. * AKA Occlusion Texture in other nomenclature.
  55670. */
  55671. ambientTexture: BaseTexture;
  55672. /**
  55673. * AKA Occlusion Texture Intensity in other nomenclature.
  55674. */
  55675. ambientTextureStrength: number;
  55676. /**
  55677. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55678. * 1 means it completely occludes it
  55679. * 0 mean it has no impact
  55680. */
  55681. ambientTextureImpactOnAnalyticalLights: number;
  55682. /**
  55683. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55684. */
  55685. opacityTexture: BaseTexture;
  55686. /**
  55687. * Stores the reflection values in a texture.
  55688. */
  55689. reflectionTexture: Nullable<BaseTexture>;
  55690. /**
  55691. * Stores the emissive values in a texture.
  55692. */
  55693. emissiveTexture: BaseTexture;
  55694. /**
  55695. * AKA Specular texture in other nomenclature.
  55696. */
  55697. reflectivityTexture: BaseTexture;
  55698. /**
  55699. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55700. */
  55701. metallicTexture: BaseTexture;
  55702. /**
  55703. * Specifies the metallic scalar of the metallic/roughness workflow.
  55704. * Can also be used to scale the metalness values of the metallic texture.
  55705. */
  55706. metallic: Nullable<number>;
  55707. /**
  55708. * Specifies the roughness scalar of the metallic/roughness workflow.
  55709. * Can also be used to scale the roughness values of the metallic texture.
  55710. */
  55711. roughness: Nullable<number>;
  55712. /**
  55713. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55714. * By default the indexOfrefraction is used to compute F0;
  55715. *
  55716. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55717. *
  55718. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55719. * F90 = metallicReflectanceColor;
  55720. */
  55721. metallicF0Factor: number;
  55722. /**
  55723. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55724. * By default the F90 is always 1;
  55725. *
  55726. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55727. *
  55728. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55729. * F90 = metallicReflectanceColor;
  55730. */
  55731. metallicReflectanceColor: Color3;
  55732. /**
  55733. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55734. * This is multiply against the scalar values defined in the material.
  55735. */
  55736. metallicReflectanceTexture: Nullable<BaseTexture>;
  55737. /**
  55738. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55739. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55740. */
  55741. microSurfaceTexture: BaseTexture;
  55742. /**
  55743. * Stores surface normal data used to displace a mesh in a texture.
  55744. */
  55745. bumpTexture: BaseTexture;
  55746. /**
  55747. * Stores the pre-calculated light information of a mesh in a texture.
  55748. */
  55749. lightmapTexture: BaseTexture;
  55750. /**
  55751. * Stores the refracted light information in a texture.
  55752. */
  55753. get refractionTexture(): Nullable<BaseTexture>;
  55754. set refractionTexture(value: Nullable<BaseTexture>);
  55755. /**
  55756. * The color of a material in ambient lighting.
  55757. */
  55758. ambientColor: Color3;
  55759. /**
  55760. * AKA Diffuse Color in other nomenclature.
  55761. */
  55762. albedoColor: Color3;
  55763. /**
  55764. * AKA Specular Color in other nomenclature.
  55765. */
  55766. reflectivityColor: Color3;
  55767. /**
  55768. * The color reflected from the material.
  55769. */
  55770. reflectionColor: Color3;
  55771. /**
  55772. * The color emitted from the material.
  55773. */
  55774. emissiveColor: Color3;
  55775. /**
  55776. * AKA Glossiness in other nomenclature.
  55777. */
  55778. microSurface: number;
  55779. /**
  55780. * Index of refraction of the material base layer.
  55781. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55782. *
  55783. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55784. *
  55785. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55786. */
  55787. get indexOfRefraction(): number;
  55788. set indexOfRefraction(value: number);
  55789. /**
  55790. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55791. */
  55792. get invertRefractionY(): boolean;
  55793. set invertRefractionY(value: boolean);
  55794. /**
  55795. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55796. * Materials half opaque for instance using refraction could benefit from this control.
  55797. */
  55798. get linkRefractionWithTransparency(): boolean;
  55799. set linkRefractionWithTransparency(value: boolean);
  55800. /**
  55801. * If true, the light map contains occlusion information instead of lighting info.
  55802. */
  55803. useLightmapAsShadowmap: boolean;
  55804. /**
  55805. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55806. */
  55807. useAlphaFromAlbedoTexture: boolean;
  55808. /**
  55809. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55810. */
  55811. forceAlphaTest: boolean;
  55812. /**
  55813. * Defines the alpha limits in alpha test mode.
  55814. */
  55815. alphaCutOff: number;
  55816. /**
  55817. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55818. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55819. */
  55820. useSpecularOverAlpha: boolean;
  55821. /**
  55822. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55823. */
  55824. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55825. /**
  55826. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55827. */
  55828. useRoughnessFromMetallicTextureAlpha: boolean;
  55829. /**
  55830. * Specifies if the metallic texture contains the roughness information in its green channel.
  55831. */
  55832. useRoughnessFromMetallicTextureGreen: boolean;
  55833. /**
  55834. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55835. */
  55836. useMetallnessFromMetallicTextureBlue: boolean;
  55837. /**
  55838. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55839. */
  55840. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55841. /**
  55842. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55843. */
  55844. useAmbientInGrayScale: boolean;
  55845. /**
  55846. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55847. * The material will try to infer what glossiness each pixel should be.
  55848. */
  55849. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55850. /**
  55851. * BJS is using an harcoded light falloff based on a manually sets up range.
  55852. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55853. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55854. */
  55855. get usePhysicalLightFalloff(): boolean;
  55856. /**
  55857. * BJS is using an harcoded light falloff based on a manually sets up range.
  55858. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55859. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55860. */
  55861. set usePhysicalLightFalloff(value: boolean);
  55862. /**
  55863. * In order to support the falloff compatibility with gltf, a special mode has been added
  55864. * to reproduce the gltf light falloff.
  55865. */
  55866. get useGLTFLightFalloff(): boolean;
  55867. /**
  55868. * In order to support the falloff compatibility with gltf, a special mode has been added
  55869. * to reproduce the gltf light falloff.
  55870. */
  55871. set useGLTFLightFalloff(value: boolean);
  55872. /**
  55873. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55874. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55875. */
  55876. useRadianceOverAlpha: boolean;
  55877. /**
  55878. * Allows using an object space normal map (instead of tangent space).
  55879. */
  55880. useObjectSpaceNormalMap: boolean;
  55881. /**
  55882. * Allows using the bump map in parallax mode.
  55883. */
  55884. useParallax: boolean;
  55885. /**
  55886. * Allows using the bump map in parallax occlusion mode.
  55887. */
  55888. useParallaxOcclusion: boolean;
  55889. /**
  55890. * Controls the scale bias of the parallax mode.
  55891. */
  55892. parallaxScaleBias: number;
  55893. /**
  55894. * If sets to true, disables all the lights affecting the material.
  55895. */
  55896. disableLighting: boolean;
  55897. /**
  55898. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55899. */
  55900. forceIrradianceInFragment: boolean;
  55901. /**
  55902. * Number of Simultaneous lights allowed on the material.
  55903. */
  55904. maxSimultaneousLights: number;
  55905. /**
  55906. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55907. */
  55908. invertNormalMapX: boolean;
  55909. /**
  55910. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55911. */
  55912. invertNormalMapY: boolean;
  55913. /**
  55914. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55915. */
  55916. twoSidedLighting: boolean;
  55917. /**
  55918. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55919. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55920. */
  55921. useAlphaFresnel: boolean;
  55922. /**
  55923. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55924. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55925. */
  55926. useLinearAlphaFresnel: boolean;
  55927. /**
  55928. * Let user defines the brdf lookup texture used for IBL.
  55929. * A default 8bit version is embedded but you could point at :
  55930. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55931. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55932. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55933. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55934. */
  55935. environmentBRDFTexture: Nullable<BaseTexture>;
  55936. /**
  55937. * Force normal to face away from face.
  55938. */
  55939. forceNormalForward: boolean;
  55940. /**
  55941. * Enables specular anti aliasing in the PBR shader.
  55942. * It will both interacts on the Geometry for analytical and IBL lighting.
  55943. * It also prefilter the roughness map based on the bump values.
  55944. */
  55945. enableSpecularAntiAliasing: boolean;
  55946. /**
  55947. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55948. * makes the reflect vector face the model (under horizon).
  55949. */
  55950. useHorizonOcclusion: boolean;
  55951. /**
  55952. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55953. * too much the area relying on ambient texture to define their ambient occlusion.
  55954. */
  55955. useRadianceOcclusion: boolean;
  55956. /**
  55957. * If set to true, no lighting calculations will be applied.
  55958. */
  55959. unlit: boolean;
  55960. /**
  55961. * Gets the image processing configuration used either in this material.
  55962. */
  55963. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55964. /**
  55965. * Sets the Default image processing configuration used either in the this material.
  55966. *
  55967. * If sets to null, the scene one is in use.
  55968. */
  55969. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55970. /**
  55971. * Gets wether the color curves effect is enabled.
  55972. */
  55973. get cameraColorCurvesEnabled(): boolean;
  55974. /**
  55975. * Sets wether the color curves effect is enabled.
  55976. */
  55977. set cameraColorCurvesEnabled(value: boolean);
  55978. /**
  55979. * Gets wether the color grading effect is enabled.
  55980. */
  55981. get cameraColorGradingEnabled(): boolean;
  55982. /**
  55983. * Gets wether the color grading effect is enabled.
  55984. */
  55985. set cameraColorGradingEnabled(value: boolean);
  55986. /**
  55987. * Gets wether tonemapping is enabled or not.
  55988. */
  55989. get cameraToneMappingEnabled(): boolean;
  55990. /**
  55991. * Sets wether tonemapping is enabled or not
  55992. */
  55993. set cameraToneMappingEnabled(value: boolean);
  55994. /**
  55995. * The camera exposure used on this material.
  55996. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55997. * This corresponds to a photographic exposure.
  55998. */
  55999. get cameraExposure(): number;
  56000. /**
  56001. * The camera exposure used on this material.
  56002. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56003. * This corresponds to a photographic exposure.
  56004. */
  56005. set cameraExposure(value: number);
  56006. /**
  56007. * Gets The camera contrast used on this material.
  56008. */
  56009. get cameraContrast(): number;
  56010. /**
  56011. * Sets The camera contrast used on this material.
  56012. */
  56013. set cameraContrast(value: number);
  56014. /**
  56015. * Gets the Color Grading 2D Lookup Texture.
  56016. */
  56017. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56018. /**
  56019. * Sets the Color Grading 2D Lookup Texture.
  56020. */
  56021. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56022. /**
  56023. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56024. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56025. * 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;
  56026. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56027. */
  56028. get cameraColorCurves(): Nullable<ColorCurves>;
  56029. /**
  56030. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56031. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56032. * 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;
  56033. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56034. */
  56035. set cameraColorCurves(value: Nullable<ColorCurves>);
  56036. /**
  56037. * Instantiates a new PBRMaterial instance.
  56038. *
  56039. * @param name The material name
  56040. * @param scene The scene the material will be use in.
  56041. */
  56042. constructor(name: string, scene: Scene);
  56043. /**
  56044. * Returns the name of this material class.
  56045. */
  56046. getClassName(): string;
  56047. /**
  56048. * Makes a duplicate of the current material.
  56049. * @param name - name to use for the new material.
  56050. */
  56051. clone(name: string): PBRMaterial;
  56052. /**
  56053. * Serializes this PBR Material.
  56054. * @returns - An object with the serialized material.
  56055. */
  56056. serialize(): any;
  56057. /**
  56058. * Parses a PBR Material from a serialized object.
  56059. * @param source - Serialized object.
  56060. * @param scene - BJS scene instance.
  56061. * @param rootUrl - url for the scene object
  56062. * @returns - PBRMaterial
  56063. */
  56064. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56065. }
  56066. }
  56067. declare module BABYLON {
  56068. /**
  56069. * Direct draw surface info
  56070. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56071. */
  56072. export interface DDSInfo {
  56073. /**
  56074. * Width of the texture
  56075. */
  56076. width: number;
  56077. /**
  56078. * Width of the texture
  56079. */
  56080. height: number;
  56081. /**
  56082. * Number of Mipmaps for the texture
  56083. * @see https://en.wikipedia.org/wiki/Mipmap
  56084. */
  56085. mipmapCount: number;
  56086. /**
  56087. * If the textures format is a known fourCC format
  56088. * @see https://www.fourcc.org/
  56089. */
  56090. isFourCC: boolean;
  56091. /**
  56092. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56093. */
  56094. isRGB: boolean;
  56095. /**
  56096. * If the texture is a lumincance format
  56097. */
  56098. isLuminance: boolean;
  56099. /**
  56100. * If this is a cube texture
  56101. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56102. */
  56103. isCube: boolean;
  56104. /**
  56105. * If the texture is a compressed format eg. FOURCC_DXT1
  56106. */
  56107. isCompressed: boolean;
  56108. /**
  56109. * The dxgiFormat of the texture
  56110. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56111. */
  56112. dxgiFormat: number;
  56113. /**
  56114. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56115. */
  56116. textureType: number;
  56117. /**
  56118. * Sphericle polynomial created for the dds texture
  56119. */
  56120. sphericalPolynomial?: SphericalPolynomial;
  56121. }
  56122. /**
  56123. * Class used to provide DDS decompression tools
  56124. */
  56125. export class DDSTools {
  56126. /**
  56127. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56128. */
  56129. static StoreLODInAlphaChannel: boolean;
  56130. /**
  56131. * Gets DDS information from an array buffer
  56132. * @param data defines the array buffer view to read data from
  56133. * @returns the DDS information
  56134. */
  56135. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56136. private static _FloatView;
  56137. private static _Int32View;
  56138. private static _ToHalfFloat;
  56139. private static _FromHalfFloat;
  56140. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56141. private static _GetHalfFloatRGBAArrayBuffer;
  56142. private static _GetFloatRGBAArrayBuffer;
  56143. private static _GetFloatAsUIntRGBAArrayBuffer;
  56144. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56145. private static _GetRGBAArrayBuffer;
  56146. private static _ExtractLongWordOrder;
  56147. private static _GetRGBArrayBuffer;
  56148. private static _GetLuminanceArrayBuffer;
  56149. /**
  56150. * Uploads DDS Levels to a Babylon Texture
  56151. * @hidden
  56152. */
  56153. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56154. }
  56155. interface ThinEngine {
  56156. /**
  56157. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56158. * @param rootUrl defines the url where the file to load is located
  56159. * @param scene defines the current scene
  56160. * @param lodScale defines scale to apply to the mip map selection
  56161. * @param lodOffset defines offset to apply to the mip map selection
  56162. * @param onLoad defines an optional callback raised when the texture is loaded
  56163. * @param onError defines an optional callback raised if there is an issue to load the texture
  56164. * @param format defines the format of the data
  56165. * @param forcedExtension defines the extension to use to pick the right loader
  56166. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56167. * @returns the cube texture as an InternalTexture
  56168. */
  56169. 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;
  56170. }
  56171. }
  56172. declare module BABYLON {
  56173. /**
  56174. * Implementation of the DDS Texture Loader.
  56175. * @hidden
  56176. */
  56177. export class _DDSTextureLoader implements IInternalTextureLoader {
  56178. /**
  56179. * Defines wether the loader supports cascade loading the different faces.
  56180. */
  56181. readonly supportCascades: boolean;
  56182. /**
  56183. * This returns if the loader support the current file information.
  56184. * @param extension defines the file extension of the file being loaded
  56185. * @returns true if the loader can load the specified file
  56186. */
  56187. canLoad(extension: string): boolean;
  56188. /**
  56189. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56190. * @param data contains the texture data
  56191. * @param texture defines the BabylonJS internal texture
  56192. * @param createPolynomials will be true if polynomials have been requested
  56193. * @param onLoad defines the callback to trigger once the texture is ready
  56194. * @param onError defines the callback to trigger in case of error
  56195. */
  56196. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56197. /**
  56198. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56199. * @param data contains the texture data
  56200. * @param texture defines the BabylonJS internal texture
  56201. * @param callback defines the method to call once ready to upload
  56202. */
  56203. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56204. }
  56205. }
  56206. declare module BABYLON {
  56207. /**
  56208. * Implementation of the ENV Texture Loader.
  56209. * @hidden
  56210. */
  56211. export class _ENVTextureLoader implements IInternalTextureLoader {
  56212. /**
  56213. * Defines wether the loader supports cascade loading the different faces.
  56214. */
  56215. readonly supportCascades: boolean;
  56216. /**
  56217. * This returns if the loader support the current file information.
  56218. * @param extension defines the file extension of the file being loaded
  56219. * @returns true if the loader can load the specified file
  56220. */
  56221. canLoad(extension: string): boolean;
  56222. /**
  56223. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56224. * @param data contains the texture data
  56225. * @param texture defines the BabylonJS internal texture
  56226. * @param createPolynomials will be true if polynomials have been requested
  56227. * @param onLoad defines the callback to trigger once the texture is ready
  56228. * @param onError defines the callback to trigger in case of error
  56229. */
  56230. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56231. /**
  56232. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56233. * @param data contains the texture data
  56234. * @param texture defines the BabylonJS internal texture
  56235. * @param callback defines the method to call once ready to upload
  56236. */
  56237. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56238. }
  56239. }
  56240. declare module BABYLON {
  56241. /**
  56242. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56243. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56244. */
  56245. export class KhronosTextureContainer {
  56246. /** contents of the KTX container file */
  56247. data: ArrayBufferView;
  56248. private static HEADER_LEN;
  56249. private static COMPRESSED_2D;
  56250. private static COMPRESSED_3D;
  56251. private static TEX_2D;
  56252. private static TEX_3D;
  56253. /**
  56254. * Gets the openGL type
  56255. */
  56256. glType: number;
  56257. /**
  56258. * Gets the openGL type size
  56259. */
  56260. glTypeSize: number;
  56261. /**
  56262. * Gets the openGL format
  56263. */
  56264. glFormat: number;
  56265. /**
  56266. * Gets the openGL internal format
  56267. */
  56268. glInternalFormat: number;
  56269. /**
  56270. * Gets the base internal format
  56271. */
  56272. glBaseInternalFormat: number;
  56273. /**
  56274. * Gets image width in pixel
  56275. */
  56276. pixelWidth: number;
  56277. /**
  56278. * Gets image height in pixel
  56279. */
  56280. pixelHeight: number;
  56281. /**
  56282. * Gets image depth in pixels
  56283. */
  56284. pixelDepth: number;
  56285. /**
  56286. * Gets the number of array elements
  56287. */
  56288. numberOfArrayElements: number;
  56289. /**
  56290. * Gets the number of faces
  56291. */
  56292. numberOfFaces: number;
  56293. /**
  56294. * Gets the number of mipmap levels
  56295. */
  56296. numberOfMipmapLevels: number;
  56297. /**
  56298. * Gets the bytes of key value data
  56299. */
  56300. bytesOfKeyValueData: number;
  56301. /**
  56302. * Gets the load type
  56303. */
  56304. loadType: number;
  56305. /**
  56306. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56307. */
  56308. isInvalid: boolean;
  56309. /**
  56310. * Creates a new KhronosTextureContainer
  56311. * @param data contents of the KTX container file
  56312. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56313. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56314. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56315. */
  56316. constructor(
  56317. /** contents of the KTX container file */
  56318. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56319. /**
  56320. * Uploads KTX content to a Babylon Texture.
  56321. * It is assumed that the texture has already been created & is currently bound
  56322. * @hidden
  56323. */
  56324. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56325. private _upload2DCompressedLevels;
  56326. /**
  56327. * Checks if the given data starts with a KTX file identifier.
  56328. * @param data the data to check
  56329. * @returns true if the data is a KTX file or false otherwise
  56330. */
  56331. static IsValid(data: ArrayBufferView): boolean;
  56332. }
  56333. }
  56334. declare module BABYLON {
  56335. /**
  56336. * Class for loading KTX2 files
  56337. * !!! Experimental Extension Subject to Changes !!!
  56338. * @hidden
  56339. */
  56340. export class KhronosTextureContainer2 {
  56341. private static _ModulePromise;
  56342. private static _TranscodeFormat;
  56343. constructor(engine: ThinEngine);
  56344. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56345. private _determineTranscodeFormat;
  56346. /**
  56347. * Checks if the given data starts with a KTX2 file identifier.
  56348. * @param data the data to check
  56349. * @returns true if the data is a KTX2 file or false otherwise
  56350. */
  56351. static IsValid(data: ArrayBufferView): boolean;
  56352. }
  56353. }
  56354. declare module BABYLON {
  56355. /**
  56356. * Implementation of the KTX Texture Loader.
  56357. * @hidden
  56358. */
  56359. export class _KTXTextureLoader implements IInternalTextureLoader {
  56360. /**
  56361. * Defines wether the loader supports cascade loading the different faces.
  56362. */
  56363. readonly supportCascades: boolean;
  56364. /**
  56365. * This returns if the loader support the current file information.
  56366. * @param extension defines the file extension of the file being loaded
  56367. * @returns true if the loader can load the specified file
  56368. */
  56369. canLoad(extension: string): boolean;
  56370. /**
  56371. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56372. * @param data contains the texture data
  56373. * @param texture defines the BabylonJS internal texture
  56374. * @param createPolynomials will be true if polynomials have been requested
  56375. * @param onLoad defines the callback to trigger once the texture is ready
  56376. * @param onError defines the callback to trigger in case of error
  56377. */
  56378. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56379. /**
  56380. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56381. * @param data contains the texture data
  56382. * @param texture defines the BabylonJS internal texture
  56383. * @param callback defines the method to call once ready to upload
  56384. */
  56385. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56386. }
  56387. }
  56388. declare module BABYLON {
  56389. /** @hidden */
  56390. export var _forceSceneHelpersToBundle: boolean;
  56391. interface Scene {
  56392. /**
  56393. * Creates a default light for the scene.
  56394. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56395. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56396. */
  56397. createDefaultLight(replace?: boolean): void;
  56398. /**
  56399. * Creates a default camera for the scene.
  56400. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56401. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56402. * @param replace has default false, when true replaces the active camera in the scene
  56403. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56404. */
  56405. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56406. /**
  56407. * Creates a default camera and a default light.
  56408. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56409. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56410. * @param replace has the default false, when true replaces the active camera/light in the scene
  56411. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56412. */
  56413. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56414. /**
  56415. * Creates a new sky box
  56416. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56417. * @param environmentTexture defines the texture to use as environment texture
  56418. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56419. * @param scale defines the overall scale of the skybox
  56420. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56421. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56422. * @returns a new mesh holding the sky box
  56423. */
  56424. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56425. /**
  56426. * Creates a new environment
  56427. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56428. * @param options defines the options you can use to configure the environment
  56429. * @returns the new EnvironmentHelper
  56430. */
  56431. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56432. /**
  56433. * Creates a new VREXperienceHelper
  56434. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56435. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56436. * @returns a new VREXperienceHelper
  56437. */
  56438. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56439. /**
  56440. * Creates a new WebXRDefaultExperience
  56441. * @see http://doc.babylonjs.com/how_to/webxr
  56442. * @param options experience options
  56443. * @returns a promise for a new WebXRDefaultExperience
  56444. */
  56445. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56446. }
  56447. }
  56448. declare module BABYLON {
  56449. /**
  56450. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56451. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56452. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56453. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56454. */
  56455. export class VideoDome extends TransformNode {
  56456. /**
  56457. * Define the video source as a Monoscopic panoramic 360 video.
  56458. */
  56459. static readonly MODE_MONOSCOPIC: number;
  56460. /**
  56461. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56462. */
  56463. static readonly MODE_TOPBOTTOM: number;
  56464. /**
  56465. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56466. */
  56467. static readonly MODE_SIDEBYSIDE: number;
  56468. private _halfDome;
  56469. private _useDirectMapping;
  56470. /**
  56471. * The video texture being displayed on the sphere
  56472. */
  56473. protected _videoTexture: VideoTexture;
  56474. /**
  56475. * Gets the video texture being displayed on the sphere
  56476. */
  56477. get videoTexture(): VideoTexture;
  56478. /**
  56479. * The skybox material
  56480. */
  56481. protected _material: BackgroundMaterial;
  56482. /**
  56483. * The surface used for the skybox
  56484. */
  56485. protected _mesh: Mesh;
  56486. /**
  56487. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56488. */
  56489. private _halfDomeMask;
  56490. /**
  56491. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56492. * Also see the options.resolution property.
  56493. */
  56494. get fovMultiplier(): number;
  56495. set fovMultiplier(value: number);
  56496. private _videoMode;
  56497. /**
  56498. * Gets or set the current video mode for the video. It can be:
  56499. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56500. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56501. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56502. */
  56503. get videoMode(): number;
  56504. set videoMode(value: number);
  56505. /**
  56506. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56507. *
  56508. */
  56509. get halfDome(): boolean;
  56510. /**
  56511. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56512. */
  56513. set halfDome(enabled: boolean);
  56514. /**
  56515. * Oberserver used in Stereoscopic VR Mode.
  56516. */
  56517. private _onBeforeCameraRenderObserver;
  56518. /**
  56519. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56520. * @param name Element's name, child elements will append suffixes for their own names.
  56521. * @param urlsOrVideo defines the url(s) or the video element to use
  56522. * @param options An object containing optional or exposed sub element properties
  56523. */
  56524. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56525. resolution?: number;
  56526. clickToPlay?: boolean;
  56527. autoPlay?: boolean;
  56528. loop?: boolean;
  56529. size?: number;
  56530. poster?: string;
  56531. faceForward?: boolean;
  56532. useDirectMapping?: boolean;
  56533. halfDomeMode?: boolean;
  56534. }, scene: Scene);
  56535. private _changeVideoMode;
  56536. /**
  56537. * Releases resources associated with this node.
  56538. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56539. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56540. */
  56541. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56542. }
  56543. }
  56544. declare module BABYLON {
  56545. /**
  56546. * This class can be used to get instrumentation data from a Babylon engine
  56547. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56548. */
  56549. export class EngineInstrumentation implements IDisposable {
  56550. /**
  56551. * Define the instrumented engine.
  56552. */
  56553. engine: Engine;
  56554. private _captureGPUFrameTime;
  56555. private _gpuFrameTimeToken;
  56556. private _gpuFrameTime;
  56557. private _captureShaderCompilationTime;
  56558. private _shaderCompilationTime;
  56559. private _onBeginFrameObserver;
  56560. private _onEndFrameObserver;
  56561. private _onBeforeShaderCompilationObserver;
  56562. private _onAfterShaderCompilationObserver;
  56563. /**
  56564. * Gets the perf counter used for GPU frame time
  56565. */
  56566. get gpuFrameTimeCounter(): PerfCounter;
  56567. /**
  56568. * Gets the GPU frame time capture status
  56569. */
  56570. get captureGPUFrameTime(): boolean;
  56571. /**
  56572. * Enable or disable the GPU frame time capture
  56573. */
  56574. set captureGPUFrameTime(value: boolean);
  56575. /**
  56576. * Gets the perf counter used for shader compilation time
  56577. */
  56578. get shaderCompilationTimeCounter(): PerfCounter;
  56579. /**
  56580. * Gets the shader compilation time capture status
  56581. */
  56582. get captureShaderCompilationTime(): boolean;
  56583. /**
  56584. * Enable or disable the shader compilation time capture
  56585. */
  56586. set captureShaderCompilationTime(value: boolean);
  56587. /**
  56588. * Instantiates a new engine instrumentation.
  56589. * This class can be used to get instrumentation data from a Babylon engine
  56590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56591. * @param engine Defines the engine to instrument
  56592. */
  56593. constructor(
  56594. /**
  56595. * Define the instrumented engine.
  56596. */
  56597. engine: Engine);
  56598. /**
  56599. * Dispose and release associated resources.
  56600. */
  56601. dispose(): void;
  56602. }
  56603. }
  56604. declare module BABYLON {
  56605. /**
  56606. * This class can be used to get instrumentation data from a Babylon engine
  56607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56608. */
  56609. export class SceneInstrumentation implements IDisposable {
  56610. /**
  56611. * Defines the scene to instrument
  56612. */
  56613. scene: Scene;
  56614. private _captureActiveMeshesEvaluationTime;
  56615. private _activeMeshesEvaluationTime;
  56616. private _captureRenderTargetsRenderTime;
  56617. private _renderTargetsRenderTime;
  56618. private _captureFrameTime;
  56619. private _frameTime;
  56620. private _captureRenderTime;
  56621. private _renderTime;
  56622. private _captureInterFrameTime;
  56623. private _interFrameTime;
  56624. private _captureParticlesRenderTime;
  56625. private _particlesRenderTime;
  56626. private _captureSpritesRenderTime;
  56627. private _spritesRenderTime;
  56628. private _capturePhysicsTime;
  56629. private _physicsTime;
  56630. private _captureAnimationsTime;
  56631. private _animationsTime;
  56632. private _captureCameraRenderTime;
  56633. private _cameraRenderTime;
  56634. private _onBeforeActiveMeshesEvaluationObserver;
  56635. private _onAfterActiveMeshesEvaluationObserver;
  56636. private _onBeforeRenderTargetsRenderObserver;
  56637. private _onAfterRenderTargetsRenderObserver;
  56638. private _onAfterRenderObserver;
  56639. private _onBeforeDrawPhaseObserver;
  56640. private _onAfterDrawPhaseObserver;
  56641. private _onBeforeAnimationsObserver;
  56642. private _onBeforeParticlesRenderingObserver;
  56643. private _onAfterParticlesRenderingObserver;
  56644. private _onBeforeSpritesRenderingObserver;
  56645. private _onAfterSpritesRenderingObserver;
  56646. private _onBeforePhysicsObserver;
  56647. private _onAfterPhysicsObserver;
  56648. private _onAfterAnimationsObserver;
  56649. private _onBeforeCameraRenderObserver;
  56650. private _onAfterCameraRenderObserver;
  56651. /**
  56652. * Gets the perf counter used for active meshes evaluation time
  56653. */
  56654. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56655. /**
  56656. * Gets the active meshes evaluation time capture status
  56657. */
  56658. get captureActiveMeshesEvaluationTime(): boolean;
  56659. /**
  56660. * Enable or disable the active meshes evaluation time capture
  56661. */
  56662. set captureActiveMeshesEvaluationTime(value: boolean);
  56663. /**
  56664. * Gets the perf counter used for render targets render time
  56665. */
  56666. get renderTargetsRenderTimeCounter(): PerfCounter;
  56667. /**
  56668. * Gets the render targets render time capture status
  56669. */
  56670. get captureRenderTargetsRenderTime(): boolean;
  56671. /**
  56672. * Enable or disable the render targets render time capture
  56673. */
  56674. set captureRenderTargetsRenderTime(value: boolean);
  56675. /**
  56676. * Gets the perf counter used for particles render time
  56677. */
  56678. get particlesRenderTimeCounter(): PerfCounter;
  56679. /**
  56680. * Gets the particles render time capture status
  56681. */
  56682. get captureParticlesRenderTime(): boolean;
  56683. /**
  56684. * Enable or disable the particles render time capture
  56685. */
  56686. set captureParticlesRenderTime(value: boolean);
  56687. /**
  56688. * Gets the perf counter used for sprites render time
  56689. */
  56690. get spritesRenderTimeCounter(): PerfCounter;
  56691. /**
  56692. * Gets the sprites render time capture status
  56693. */
  56694. get captureSpritesRenderTime(): boolean;
  56695. /**
  56696. * Enable or disable the sprites render time capture
  56697. */
  56698. set captureSpritesRenderTime(value: boolean);
  56699. /**
  56700. * Gets the perf counter used for physics time
  56701. */
  56702. get physicsTimeCounter(): PerfCounter;
  56703. /**
  56704. * Gets the physics time capture status
  56705. */
  56706. get capturePhysicsTime(): boolean;
  56707. /**
  56708. * Enable or disable the physics time capture
  56709. */
  56710. set capturePhysicsTime(value: boolean);
  56711. /**
  56712. * Gets the perf counter used for animations time
  56713. */
  56714. get animationsTimeCounter(): PerfCounter;
  56715. /**
  56716. * Gets the animations time capture status
  56717. */
  56718. get captureAnimationsTime(): boolean;
  56719. /**
  56720. * Enable or disable the animations time capture
  56721. */
  56722. set captureAnimationsTime(value: boolean);
  56723. /**
  56724. * Gets the perf counter used for frame time capture
  56725. */
  56726. get frameTimeCounter(): PerfCounter;
  56727. /**
  56728. * Gets the frame time capture status
  56729. */
  56730. get captureFrameTime(): boolean;
  56731. /**
  56732. * Enable or disable the frame time capture
  56733. */
  56734. set captureFrameTime(value: boolean);
  56735. /**
  56736. * Gets the perf counter used for inter-frames time capture
  56737. */
  56738. get interFrameTimeCounter(): PerfCounter;
  56739. /**
  56740. * Gets the inter-frames time capture status
  56741. */
  56742. get captureInterFrameTime(): boolean;
  56743. /**
  56744. * Enable or disable the inter-frames time capture
  56745. */
  56746. set captureInterFrameTime(value: boolean);
  56747. /**
  56748. * Gets the perf counter used for render time capture
  56749. */
  56750. get renderTimeCounter(): PerfCounter;
  56751. /**
  56752. * Gets the render time capture status
  56753. */
  56754. get captureRenderTime(): boolean;
  56755. /**
  56756. * Enable or disable the render time capture
  56757. */
  56758. set captureRenderTime(value: boolean);
  56759. /**
  56760. * Gets the perf counter used for camera render time capture
  56761. */
  56762. get cameraRenderTimeCounter(): PerfCounter;
  56763. /**
  56764. * Gets the camera render time capture status
  56765. */
  56766. get captureCameraRenderTime(): boolean;
  56767. /**
  56768. * Enable or disable the camera render time capture
  56769. */
  56770. set captureCameraRenderTime(value: boolean);
  56771. /**
  56772. * Gets the perf counter used for draw calls
  56773. */
  56774. get drawCallsCounter(): PerfCounter;
  56775. /**
  56776. * Instantiates a new scene instrumentation.
  56777. * This class can be used to get instrumentation data from a Babylon engine
  56778. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56779. * @param scene Defines the scene to instrument
  56780. */
  56781. constructor(
  56782. /**
  56783. * Defines the scene to instrument
  56784. */
  56785. scene: Scene);
  56786. /**
  56787. * Dispose and release associated resources.
  56788. */
  56789. dispose(): void;
  56790. }
  56791. }
  56792. declare module BABYLON {
  56793. /** @hidden */
  56794. export var glowMapGenerationPixelShader: {
  56795. name: string;
  56796. shader: string;
  56797. };
  56798. }
  56799. declare module BABYLON {
  56800. /** @hidden */
  56801. export var glowMapGenerationVertexShader: {
  56802. name: string;
  56803. shader: string;
  56804. };
  56805. }
  56806. declare module BABYLON {
  56807. /**
  56808. * Effect layer options. This helps customizing the behaviour
  56809. * of the effect layer.
  56810. */
  56811. export interface IEffectLayerOptions {
  56812. /**
  56813. * Multiplication factor apply to the canvas size to compute the render target size
  56814. * used to generated the objects (the smaller the faster).
  56815. */
  56816. mainTextureRatio: number;
  56817. /**
  56818. * Enforces a fixed size texture to ensure effect stability across devices.
  56819. */
  56820. mainTextureFixedSize?: number;
  56821. /**
  56822. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56823. */
  56824. alphaBlendingMode: number;
  56825. /**
  56826. * The camera attached to the layer.
  56827. */
  56828. camera: Nullable<Camera>;
  56829. /**
  56830. * The rendering group to draw the layer in.
  56831. */
  56832. renderingGroupId: number;
  56833. }
  56834. /**
  56835. * The effect layer Helps adding post process effect blended with the main pass.
  56836. *
  56837. * This can be for instance use to generate glow or higlight effects on the scene.
  56838. *
  56839. * The effect layer class can not be used directly and is intented to inherited from to be
  56840. * customized per effects.
  56841. */
  56842. export abstract class EffectLayer {
  56843. private _vertexBuffers;
  56844. private _indexBuffer;
  56845. private _cachedDefines;
  56846. private _effectLayerMapGenerationEffect;
  56847. private _effectLayerOptions;
  56848. private _mergeEffect;
  56849. protected _scene: Scene;
  56850. protected _engine: Engine;
  56851. protected _maxSize: number;
  56852. protected _mainTextureDesiredSize: ISize;
  56853. protected _mainTexture: RenderTargetTexture;
  56854. protected _shouldRender: boolean;
  56855. protected _postProcesses: PostProcess[];
  56856. protected _textures: BaseTexture[];
  56857. protected _emissiveTextureAndColor: {
  56858. texture: Nullable<BaseTexture>;
  56859. color: Color4;
  56860. };
  56861. /**
  56862. * The name of the layer
  56863. */
  56864. name: string;
  56865. /**
  56866. * The clear color of the texture used to generate the glow map.
  56867. */
  56868. neutralColor: Color4;
  56869. /**
  56870. * Specifies whether the highlight layer is enabled or not.
  56871. */
  56872. isEnabled: boolean;
  56873. /**
  56874. * Gets the camera attached to the layer.
  56875. */
  56876. get camera(): Nullable<Camera>;
  56877. /**
  56878. * Gets the rendering group id the layer should render in.
  56879. */
  56880. get renderingGroupId(): number;
  56881. set renderingGroupId(renderingGroupId: number);
  56882. /**
  56883. * An event triggered when the effect layer has been disposed.
  56884. */
  56885. onDisposeObservable: Observable<EffectLayer>;
  56886. /**
  56887. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56888. */
  56889. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56890. /**
  56891. * An event triggered when the generated texture is being merged in the scene.
  56892. */
  56893. onBeforeComposeObservable: Observable<EffectLayer>;
  56894. /**
  56895. * An event triggered when the mesh is rendered into the effect render target.
  56896. */
  56897. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56898. /**
  56899. * An event triggered after the mesh has been rendered into the effect render target.
  56900. */
  56901. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56902. /**
  56903. * An event triggered when the generated texture has been merged in the scene.
  56904. */
  56905. onAfterComposeObservable: Observable<EffectLayer>;
  56906. /**
  56907. * An event triggered when the efffect layer changes its size.
  56908. */
  56909. onSizeChangedObservable: Observable<EffectLayer>;
  56910. /** @hidden */
  56911. static _SceneComponentInitialization: (scene: Scene) => void;
  56912. /**
  56913. * Instantiates a new effect Layer and references it in the scene.
  56914. * @param name The name of the layer
  56915. * @param scene The scene to use the layer in
  56916. */
  56917. constructor(
  56918. /** The Friendly of the effect in the scene */
  56919. name: string, scene: Scene);
  56920. /**
  56921. * Get the effect name of the layer.
  56922. * @return The effect name
  56923. */
  56924. abstract getEffectName(): string;
  56925. /**
  56926. * Checks for the readiness of the element composing the layer.
  56927. * @param subMesh the mesh to check for
  56928. * @param useInstances specify whether or not to use instances to render the mesh
  56929. * @return true if ready otherwise, false
  56930. */
  56931. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56932. /**
  56933. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56934. * @returns true if the effect requires stencil during the main canvas render pass.
  56935. */
  56936. abstract needStencil(): boolean;
  56937. /**
  56938. * Create the merge effect. This is the shader use to blit the information back
  56939. * to the main canvas at the end of the scene rendering.
  56940. * @returns The effect containing the shader used to merge the effect on the main canvas
  56941. */
  56942. protected abstract _createMergeEffect(): Effect;
  56943. /**
  56944. * Creates the render target textures and post processes used in the effect layer.
  56945. */
  56946. protected abstract _createTextureAndPostProcesses(): void;
  56947. /**
  56948. * Implementation specific of rendering the generating effect on the main canvas.
  56949. * @param effect The effect used to render through
  56950. */
  56951. protected abstract _internalRender(effect: Effect): void;
  56952. /**
  56953. * Sets the required values for both the emissive texture and and the main color.
  56954. */
  56955. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56956. /**
  56957. * Free any resources and references associated to a mesh.
  56958. * Internal use
  56959. * @param mesh The mesh to free.
  56960. */
  56961. abstract _disposeMesh(mesh: Mesh): void;
  56962. /**
  56963. * Serializes this layer (Glow or Highlight for example)
  56964. * @returns a serialized layer object
  56965. */
  56966. abstract serialize?(): any;
  56967. /**
  56968. * Initializes the effect layer with the required options.
  56969. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56970. */
  56971. protected _init(options: Partial<IEffectLayerOptions>): void;
  56972. /**
  56973. * Generates the index buffer of the full screen quad blending to the main canvas.
  56974. */
  56975. private _generateIndexBuffer;
  56976. /**
  56977. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56978. */
  56979. private _generateVertexBuffer;
  56980. /**
  56981. * Sets the main texture desired size which is the closest power of two
  56982. * of the engine canvas size.
  56983. */
  56984. private _setMainTextureSize;
  56985. /**
  56986. * Creates the main texture for the effect layer.
  56987. */
  56988. protected _createMainTexture(): void;
  56989. /**
  56990. * Adds specific effects defines.
  56991. * @param defines The defines to add specifics to.
  56992. */
  56993. protected _addCustomEffectDefines(defines: string[]): void;
  56994. /**
  56995. * Checks for the readiness of the element composing the layer.
  56996. * @param subMesh the mesh to check for
  56997. * @param useInstances specify whether or not to use instances to render the mesh
  56998. * @param emissiveTexture the associated emissive texture used to generate the glow
  56999. * @return true if ready otherwise, false
  57000. */
  57001. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57002. /**
  57003. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57004. */
  57005. render(): void;
  57006. /**
  57007. * Determine if a given mesh will be used in the current effect.
  57008. * @param mesh mesh to test
  57009. * @returns true if the mesh will be used
  57010. */
  57011. hasMesh(mesh: AbstractMesh): boolean;
  57012. /**
  57013. * Returns true if the layer contains information to display, otherwise false.
  57014. * @returns true if the glow layer should be rendered
  57015. */
  57016. shouldRender(): boolean;
  57017. /**
  57018. * Returns true if the mesh should render, otherwise false.
  57019. * @param mesh The mesh to render
  57020. * @returns true if it should render otherwise false
  57021. */
  57022. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57023. /**
  57024. * Returns true if the mesh can be rendered, otherwise false.
  57025. * @param mesh The mesh to render
  57026. * @param material The material used on the mesh
  57027. * @returns true if it can be rendered otherwise false
  57028. */
  57029. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57030. /**
  57031. * Returns true if the mesh should render, otherwise false.
  57032. * @param mesh The mesh to render
  57033. * @returns true if it should render otherwise false
  57034. */
  57035. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57036. /**
  57037. * Renders the submesh passed in parameter to the generation map.
  57038. */
  57039. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57040. /**
  57041. * Defines whether the current material of the mesh should be use to render the effect.
  57042. * @param mesh defines the current mesh to render
  57043. */
  57044. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57045. /**
  57046. * Rebuild the required buffers.
  57047. * @hidden Internal use only.
  57048. */
  57049. _rebuild(): void;
  57050. /**
  57051. * Dispose only the render target textures and post process.
  57052. */
  57053. private _disposeTextureAndPostProcesses;
  57054. /**
  57055. * Dispose the highlight layer and free resources.
  57056. */
  57057. dispose(): void;
  57058. /**
  57059. * Gets the class name of the effect layer
  57060. * @returns the string with the class name of the effect layer
  57061. */
  57062. getClassName(): string;
  57063. /**
  57064. * Creates an effect layer from parsed effect layer data
  57065. * @param parsedEffectLayer defines effect layer data
  57066. * @param scene defines the current scene
  57067. * @param rootUrl defines the root URL containing the effect layer information
  57068. * @returns a parsed effect Layer
  57069. */
  57070. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57071. }
  57072. }
  57073. declare module BABYLON {
  57074. interface AbstractScene {
  57075. /**
  57076. * The list of effect layers (highlights/glow) added to the scene
  57077. * @see http://doc.babylonjs.com/how_to/highlight_layer
  57078. * @see http://doc.babylonjs.com/how_to/glow_layer
  57079. */
  57080. effectLayers: Array<EffectLayer>;
  57081. /**
  57082. * Removes the given effect layer from this scene.
  57083. * @param toRemove defines the effect layer to remove
  57084. * @returns the index of the removed effect layer
  57085. */
  57086. removeEffectLayer(toRemove: EffectLayer): number;
  57087. /**
  57088. * Adds the given effect layer to this scene
  57089. * @param newEffectLayer defines the effect layer to add
  57090. */
  57091. addEffectLayer(newEffectLayer: EffectLayer): void;
  57092. }
  57093. /**
  57094. * Defines the layer scene component responsible to manage any effect layers
  57095. * in a given scene.
  57096. */
  57097. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57098. /**
  57099. * The component name helpfull to identify the component in the list of scene components.
  57100. */
  57101. readonly name: string;
  57102. /**
  57103. * The scene the component belongs to.
  57104. */
  57105. scene: Scene;
  57106. private _engine;
  57107. private _renderEffects;
  57108. private _needStencil;
  57109. private _previousStencilState;
  57110. /**
  57111. * Creates a new instance of the component for the given scene
  57112. * @param scene Defines the scene to register the component in
  57113. */
  57114. constructor(scene: Scene);
  57115. /**
  57116. * Registers the component in a given scene
  57117. */
  57118. register(): void;
  57119. /**
  57120. * Rebuilds the elements related to this component in case of
  57121. * context lost for instance.
  57122. */
  57123. rebuild(): void;
  57124. /**
  57125. * Serializes the component data to the specified json object
  57126. * @param serializationObject The object to serialize to
  57127. */
  57128. serialize(serializationObject: any): void;
  57129. /**
  57130. * Adds all the elements from the container to the scene
  57131. * @param container the container holding the elements
  57132. */
  57133. addFromContainer(container: AbstractScene): void;
  57134. /**
  57135. * Removes all the elements in the container from the scene
  57136. * @param container contains the elements to remove
  57137. * @param dispose if the removed element should be disposed (default: false)
  57138. */
  57139. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57140. /**
  57141. * Disposes the component and the associated ressources.
  57142. */
  57143. dispose(): void;
  57144. private _isReadyForMesh;
  57145. private _renderMainTexture;
  57146. private _setStencil;
  57147. private _setStencilBack;
  57148. private _draw;
  57149. private _drawCamera;
  57150. private _drawRenderingGroup;
  57151. }
  57152. }
  57153. declare module BABYLON {
  57154. /** @hidden */
  57155. export var glowMapMergePixelShader: {
  57156. name: string;
  57157. shader: string;
  57158. };
  57159. }
  57160. declare module BABYLON {
  57161. /** @hidden */
  57162. export var glowMapMergeVertexShader: {
  57163. name: string;
  57164. shader: string;
  57165. };
  57166. }
  57167. declare module BABYLON {
  57168. interface AbstractScene {
  57169. /**
  57170. * Return a the first highlight layer of the scene with a given name.
  57171. * @param name The name of the highlight layer to look for.
  57172. * @return The highlight layer if found otherwise null.
  57173. */
  57174. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57175. }
  57176. /**
  57177. * Glow layer options. This helps customizing the behaviour
  57178. * of the glow layer.
  57179. */
  57180. export interface IGlowLayerOptions {
  57181. /**
  57182. * Multiplication factor apply to the canvas size to compute the render target size
  57183. * used to generated the glowing objects (the smaller the faster).
  57184. */
  57185. mainTextureRatio: number;
  57186. /**
  57187. * Enforces a fixed size texture to ensure resize independant blur.
  57188. */
  57189. mainTextureFixedSize?: number;
  57190. /**
  57191. * How big is the kernel of the blur texture.
  57192. */
  57193. blurKernelSize: number;
  57194. /**
  57195. * The camera attached to the layer.
  57196. */
  57197. camera: Nullable<Camera>;
  57198. /**
  57199. * Enable MSAA by chosing the number of samples.
  57200. */
  57201. mainTextureSamples?: number;
  57202. /**
  57203. * The rendering group to draw the layer in.
  57204. */
  57205. renderingGroupId: number;
  57206. }
  57207. /**
  57208. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57209. *
  57210. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57211. *
  57212. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57213. */
  57214. export class GlowLayer extends EffectLayer {
  57215. /**
  57216. * Effect Name of the layer.
  57217. */
  57218. static readonly EffectName: string;
  57219. /**
  57220. * The default blur kernel size used for the glow.
  57221. */
  57222. static DefaultBlurKernelSize: number;
  57223. /**
  57224. * The default texture size ratio used for the glow.
  57225. */
  57226. static DefaultTextureRatio: number;
  57227. /**
  57228. * Sets the kernel size of the blur.
  57229. */
  57230. set blurKernelSize(value: number);
  57231. /**
  57232. * Gets the kernel size of the blur.
  57233. */
  57234. get blurKernelSize(): number;
  57235. /**
  57236. * Sets the glow intensity.
  57237. */
  57238. set intensity(value: number);
  57239. /**
  57240. * Gets the glow intensity.
  57241. */
  57242. get intensity(): number;
  57243. private _options;
  57244. private _intensity;
  57245. private _horizontalBlurPostprocess1;
  57246. private _verticalBlurPostprocess1;
  57247. private _horizontalBlurPostprocess2;
  57248. private _verticalBlurPostprocess2;
  57249. private _blurTexture1;
  57250. private _blurTexture2;
  57251. private _postProcesses1;
  57252. private _postProcesses2;
  57253. private _includedOnlyMeshes;
  57254. private _excludedMeshes;
  57255. private _meshesUsingTheirOwnMaterials;
  57256. /**
  57257. * Callback used to let the user override the color selection on a per mesh basis
  57258. */
  57259. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57260. /**
  57261. * Callback used to let the user override the texture selection on a per mesh basis
  57262. */
  57263. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57264. /**
  57265. * Instantiates a new glow Layer and references it to the scene.
  57266. * @param name The name of the layer
  57267. * @param scene The scene to use the layer in
  57268. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57269. */
  57270. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57271. /**
  57272. * Get the effect name of the layer.
  57273. * @return The effect name
  57274. */
  57275. getEffectName(): string;
  57276. /**
  57277. * Create the merge effect. This is the shader use to blit the information back
  57278. * to the main canvas at the end of the scene rendering.
  57279. */
  57280. protected _createMergeEffect(): Effect;
  57281. /**
  57282. * Creates the render target textures and post processes used in the glow layer.
  57283. */
  57284. protected _createTextureAndPostProcesses(): void;
  57285. /**
  57286. * Checks for the readiness of the element composing the layer.
  57287. * @param subMesh the mesh to check for
  57288. * @param useInstances specify wether or not to use instances to render the mesh
  57289. * @param emissiveTexture the associated emissive texture used to generate the glow
  57290. * @return true if ready otherwise, false
  57291. */
  57292. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57293. /**
  57294. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57295. */
  57296. needStencil(): boolean;
  57297. /**
  57298. * Returns true if the mesh can be rendered, otherwise false.
  57299. * @param mesh The mesh to render
  57300. * @param material The material used on the mesh
  57301. * @returns true if it can be rendered otherwise false
  57302. */
  57303. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57304. /**
  57305. * Implementation specific of rendering the generating effect on the main canvas.
  57306. * @param effect The effect used to render through
  57307. */
  57308. protected _internalRender(effect: Effect): void;
  57309. /**
  57310. * Sets the required values for both the emissive texture and and the main color.
  57311. */
  57312. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57313. /**
  57314. * Returns true if the mesh should render, otherwise false.
  57315. * @param mesh The mesh to render
  57316. * @returns true if it should render otherwise false
  57317. */
  57318. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57319. /**
  57320. * Adds specific effects defines.
  57321. * @param defines The defines to add specifics to.
  57322. */
  57323. protected _addCustomEffectDefines(defines: string[]): void;
  57324. /**
  57325. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57326. * @param mesh The mesh to exclude from the glow layer
  57327. */
  57328. addExcludedMesh(mesh: Mesh): void;
  57329. /**
  57330. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57331. * @param mesh The mesh to remove
  57332. */
  57333. removeExcludedMesh(mesh: Mesh): void;
  57334. /**
  57335. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57336. * @param mesh The mesh to include in the glow layer
  57337. */
  57338. addIncludedOnlyMesh(mesh: Mesh): void;
  57339. /**
  57340. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57341. * @param mesh The mesh to remove
  57342. */
  57343. removeIncludedOnlyMesh(mesh: Mesh): void;
  57344. /**
  57345. * Determine if a given mesh will be used in the glow layer
  57346. * @param mesh The mesh to test
  57347. * @returns true if the mesh will be highlighted by the current glow layer
  57348. */
  57349. hasMesh(mesh: AbstractMesh): boolean;
  57350. /**
  57351. * Defines whether the current material of the mesh should be use to render the effect.
  57352. * @param mesh defines the current mesh to render
  57353. */
  57354. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57355. /**
  57356. * Add a mesh to be rendered through its own material and not with emissive only.
  57357. * @param mesh The mesh for which we need to use its material
  57358. */
  57359. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57360. /**
  57361. * Remove a mesh from being rendered through its own material and not with emissive only.
  57362. * @param mesh The mesh for which we need to not use its material
  57363. */
  57364. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57365. /**
  57366. * Free any resources and references associated to a mesh.
  57367. * Internal use
  57368. * @param mesh The mesh to free.
  57369. * @hidden
  57370. */
  57371. _disposeMesh(mesh: Mesh): void;
  57372. /**
  57373. * Gets the class name of the effect layer
  57374. * @returns the string with the class name of the effect layer
  57375. */
  57376. getClassName(): string;
  57377. /**
  57378. * Serializes this glow layer
  57379. * @returns a serialized glow layer object
  57380. */
  57381. serialize(): any;
  57382. /**
  57383. * Creates a Glow Layer from parsed glow layer data
  57384. * @param parsedGlowLayer defines glow layer data
  57385. * @param scene defines the current scene
  57386. * @param rootUrl defines the root URL containing the glow layer information
  57387. * @returns a parsed Glow Layer
  57388. */
  57389. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57390. }
  57391. }
  57392. declare module BABYLON {
  57393. /** @hidden */
  57394. export var glowBlurPostProcessPixelShader: {
  57395. name: string;
  57396. shader: string;
  57397. };
  57398. }
  57399. declare module BABYLON {
  57400. interface AbstractScene {
  57401. /**
  57402. * Return a the first highlight layer of the scene with a given name.
  57403. * @param name The name of the highlight layer to look for.
  57404. * @return The highlight layer if found otherwise null.
  57405. */
  57406. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57407. }
  57408. /**
  57409. * Highlight layer options. This helps customizing the behaviour
  57410. * of the highlight layer.
  57411. */
  57412. export interface IHighlightLayerOptions {
  57413. /**
  57414. * Multiplication factor apply to the canvas size to compute the render target size
  57415. * used to generated the glowing objects (the smaller the faster).
  57416. */
  57417. mainTextureRatio: number;
  57418. /**
  57419. * Enforces a fixed size texture to ensure resize independant blur.
  57420. */
  57421. mainTextureFixedSize?: number;
  57422. /**
  57423. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57424. * of the picture to blur (the smaller the faster).
  57425. */
  57426. blurTextureSizeRatio: number;
  57427. /**
  57428. * How big in texel of the blur texture is the vertical blur.
  57429. */
  57430. blurVerticalSize: number;
  57431. /**
  57432. * How big in texel of the blur texture is the horizontal blur.
  57433. */
  57434. blurHorizontalSize: number;
  57435. /**
  57436. * Alpha blending mode used to apply the blur. Default is combine.
  57437. */
  57438. alphaBlendingMode: number;
  57439. /**
  57440. * The camera attached to the layer.
  57441. */
  57442. camera: Nullable<Camera>;
  57443. /**
  57444. * Should we display highlight as a solid stroke?
  57445. */
  57446. isStroke?: boolean;
  57447. /**
  57448. * The rendering group to draw the layer in.
  57449. */
  57450. renderingGroupId: number;
  57451. }
  57452. /**
  57453. * The highlight layer Helps adding a glow effect around a mesh.
  57454. *
  57455. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57456. * glowy meshes to your scene.
  57457. *
  57458. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57459. */
  57460. export class HighlightLayer extends EffectLayer {
  57461. name: string;
  57462. /**
  57463. * Effect Name of the highlight layer.
  57464. */
  57465. static readonly EffectName: string;
  57466. /**
  57467. * The neutral color used during the preparation of the glow effect.
  57468. * This is black by default as the blend operation is a blend operation.
  57469. */
  57470. static NeutralColor: Color4;
  57471. /**
  57472. * Stencil value used for glowing meshes.
  57473. */
  57474. static GlowingMeshStencilReference: number;
  57475. /**
  57476. * Stencil value used for the other meshes in the scene.
  57477. */
  57478. static NormalMeshStencilReference: number;
  57479. /**
  57480. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57481. */
  57482. innerGlow: boolean;
  57483. /**
  57484. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57485. */
  57486. outerGlow: boolean;
  57487. /**
  57488. * Specifies the horizontal size of the blur.
  57489. */
  57490. set blurHorizontalSize(value: number);
  57491. /**
  57492. * Specifies the vertical size of the blur.
  57493. */
  57494. set blurVerticalSize(value: number);
  57495. /**
  57496. * Gets the horizontal size of the blur.
  57497. */
  57498. get blurHorizontalSize(): number;
  57499. /**
  57500. * Gets the vertical size of the blur.
  57501. */
  57502. get blurVerticalSize(): number;
  57503. /**
  57504. * An event triggered when the highlight layer is being blurred.
  57505. */
  57506. onBeforeBlurObservable: Observable<HighlightLayer>;
  57507. /**
  57508. * An event triggered when the highlight layer has been blurred.
  57509. */
  57510. onAfterBlurObservable: Observable<HighlightLayer>;
  57511. private _instanceGlowingMeshStencilReference;
  57512. private _options;
  57513. private _downSamplePostprocess;
  57514. private _horizontalBlurPostprocess;
  57515. private _verticalBlurPostprocess;
  57516. private _blurTexture;
  57517. private _meshes;
  57518. private _excludedMeshes;
  57519. /**
  57520. * Instantiates a new highlight Layer and references it to the scene..
  57521. * @param name The name of the layer
  57522. * @param scene The scene to use the layer in
  57523. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57524. */
  57525. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57526. /**
  57527. * Get the effect name of the layer.
  57528. * @return The effect name
  57529. */
  57530. getEffectName(): string;
  57531. /**
  57532. * Create the merge effect. This is the shader use to blit the information back
  57533. * to the main canvas at the end of the scene rendering.
  57534. */
  57535. protected _createMergeEffect(): Effect;
  57536. /**
  57537. * Creates the render target textures and post processes used in the highlight layer.
  57538. */
  57539. protected _createTextureAndPostProcesses(): void;
  57540. /**
  57541. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57542. */
  57543. needStencil(): boolean;
  57544. /**
  57545. * Checks for the readiness of the element composing the layer.
  57546. * @param subMesh the mesh to check for
  57547. * @param useInstances specify wether or not to use instances to render the mesh
  57548. * @param emissiveTexture the associated emissive texture used to generate the glow
  57549. * @return true if ready otherwise, false
  57550. */
  57551. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57552. /**
  57553. * Implementation specific of rendering the generating effect on the main canvas.
  57554. * @param effect The effect used to render through
  57555. */
  57556. protected _internalRender(effect: Effect): void;
  57557. /**
  57558. * Returns true if the layer contains information to display, otherwise false.
  57559. */
  57560. shouldRender(): boolean;
  57561. /**
  57562. * Returns true if the mesh should render, otherwise false.
  57563. * @param mesh The mesh to render
  57564. * @returns true if it should render otherwise false
  57565. */
  57566. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57567. /**
  57568. * Adds specific effects defines.
  57569. * @param defines The defines to add specifics to.
  57570. */
  57571. protected _addCustomEffectDefines(defines: string[]): void;
  57572. /**
  57573. * Sets the required values for both the emissive texture and and the main color.
  57574. */
  57575. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57576. /**
  57577. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57578. * @param mesh The mesh to exclude from the highlight layer
  57579. */
  57580. addExcludedMesh(mesh: Mesh): void;
  57581. /**
  57582. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57583. * @param mesh The mesh to highlight
  57584. */
  57585. removeExcludedMesh(mesh: Mesh): void;
  57586. /**
  57587. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57588. * @param mesh mesh to test
  57589. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57590. */
  57591. hasMesh(mesh: AbstractMesh): boolean;
  57592. /**
  57593. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57594. * @param mesh The mesh to highlight
  57595. * @param color The color of the highlight
  57596. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57597. */
  57598. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57599. /**
  57600. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57601. * @param mesh The mesh to highlight
  57602. */
  57603. removeMesh(mesh: Mesh): void;
  57604. /**
  57605. * Remove all the meshes currently referenced in the highlight layer
  57606. */
  57607. removeAllMeshes(): void;
  57608. /**
  57609. * Force the stencil to the normal expected value for none glowing parts
  57610. */
  57611. private _defaultStencilReference;
  57612. /**
  57613. * Free any resources and references associated to a mesh.
  57614. * Internal use
  57615. * @param mesh The mesh to free.
  57616. * @hidden
  57617. */
  57618. _disposeMesh(mesh: Mesh): void;
  57619. /**
  57620. * Dispose the highlight layer and free resources.
  57621. */
  57622. dispose(): void;
  57623. /**
  57624. * Gets the class name of the effect layer
  57625. * @returns the string with the class name of the effect layer
  57626. */
  57627. getClassName(): string;
  57628. /**
  57629. * Serializes this Highlight layer
  57630. * @returns a serialized Highlight layer object
  57631. */
  57632. serialize(): any;
  57633. /**
  57634. * Creates a Highlight layer from parsed Highlight layer data
  57635. * @param parsedHightlightLayer defines the Highlight layer data
  57636. * @param scene defines the current scene
  57637. * @param rootUrl defines the root URL containing the Highlight layer information
  57638. * @returns a parsed Highlight layer
  57639. */
  57640. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57641. }
  57642. }
  57643. declare module BABYLON {
  57644. interface AbstractScene {
  57645. /**
  57646. * The list of layers (background and foreground) of the scene
  57647. */
  57648. layers: Array<Layer>;
  57649. }
  57650. /**
  57651. * Defines the layer scene component responsible to manage any layers
  57652. * in a given scene.
  57653. */
  57654. export class LayerSceneComponent implements ISceneComponent {
  57655. /**
  57656. * The component name helpfull to identify the component in the list of scene components.
  57657. */
  57658. readonly name: string;
  57659. /**
  57660. * The scene the component belongs to.
  57661. */
  57662. scene: Scene;
  57663. private _engine;
  57664. /**
  57665. * Creates a new instance of the component for the given scene
  57666. * @param scene Defines the scene to register the component in
  57667. */
  57668. constructor(scene: Scene);
  57669. /**
  57670. * Registers the component in a given scene
  57671. */
  57672. register(): void;
  57673. /**
  57674. * Rebuilds the elements related to this component in case of
  57675. * context lost for instance.
  57676. */
  57677. rebuild(): void;
  57678. /**
  57679. * Disposes the component and the associated ressources.
  57680. */
  57681. dispose(): void;
  57682. private _draw;
  57683. private _drawCameraPredicate;
  57684. private _drawCameraBackground;
  57685. private _drawCameraForeground;
  57686. private _drawRenderTargetPredicate;
  57687. private _drawRenderTargetBackground;
  57688. private _drawRenderTargetForeground;
  57689. /**
  57690. * Adds all the elements from the container to the scene
  57691. * @param container the container holding the elements
  57692. */
  57693. addFromContainer(container: AbstractScene): void;
  57694. /**
  57695. * Removes all the elements in the container from the scene
  57696. * @param container contains the elements to remove
  57697. * @param dispose if the removed element should be disposed (default: false)
  57698. */
  57699. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57700. }
  57701. }
  57702. declare module BABYLON {
  57703. /** @hidden */
  57704. export var layerPixelShader: {
  57705. name: string;
  57706. shader: string;
  57707. };
  57708. }
  57709. declare module BABYLON {
  57710. /** @hidden */
  57711. export var layerVertexShader: {
  57712. name: string;
  57713. shader: string;
  57714. };
  57715. }
  57716. declare module BABYLON {
  57717. /**
  57718. * This represents a full screen 2d layer.
  57719. * This can be useful to display a picture in the background of your scene for instance.
  57720. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57721. */
  57722. export class Layer {
  57723. /**
  57724. * Define the name of the layer.
  57725. */
  57726. name: string;
  57727. /**
  57728. * Define the texture the layer should display.
  57729. */
  57730. texture: Nullable<Texture>;
  57731. /**
  57732. * Is the layer in background or foreground.
  57733. */
  57734. isBackground: boolean;
  57735. /**
  57736. * Define the color of the layer (instead of texture).
  57737. */
  57738. color: Color4;
  57739. /**
  57740. * Define the scale of the layer in order to zoom in out of the texture.
  57741. */
  57742. scale: Vector2;
  57743. /**
  57744. * Define an offset for the layer in order to shift the texture.
  57745. */
  57746. offset: Vector2;
  57747. /**
  57748. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57749. */
  57750. alphaBlendingMode: number;
  57751. /**
  57752. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57753. * Alpha test will not mix with the background color in case of transparency.
  57754. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57755. */
  57756. alphaTest: boolean;
  57757. /**
  57758. * Define a mask to restrict the layer to only some of the scene cameras.
  57759. */
  57760. layerMask: number;
  57761. /**
  57762. * Define the list of render target the layer is visible into.
  57763. */
  57764. renderTargetTextures: RenderTargetTexture[];
  57765. /**
  57766. * Define if the layer is only used in renderTarget or if it also
  57767. * renders in the main frame buffer of the canvas.
  57768. */
  57769. renderOnlyInRenderTargetTextures: boolean;
  57770. private _scene;
  57771. private _vertexBuffers;
  57772. private _indexBuffer;
  57773. private _effect;
  57774. private _previousDefines;
  57775. /**
  57776. * An event triggered when the layer is disposed.
  57777. */
  57778. onDisposeObservable: Observable<Layer>;
  57779. private _onDisposeObserver;
  57780. /**
  57781. * Back compatibility with callback before the onDisposeObservable existed.
  57782. * The set callback will be triggered when the layer has been disposed.
  57783. */
  57784. set onDispose(callback: () => void);
  57785. /**
  57786. * An event triggered before rendering the scene
  57787. */
  57788. onBeforeRenderObservable: Observable<Layer>;
  57789. private _onBeforeRenderObserver;
  57790. /**
  57791. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57792. * The set callback will be triggered just before rendering the layer.
  57793. */
  57794. set onBeforeRender(callback: () => void);
  57795. /**
  57796. * An event triggered after rendering the scene
  57797. */
  57798. onAfterRenderObservable: Observable<Layer>;
  57799. private _onAfterRenderObserver;
  57800. /**
  57801. * Back compatibility with callback before the onAfterRenderObservable existed.
  57802. * The set callback will be triggered just after rendering the layer.
  57803. */
  57804. set onAfterRender(callback: () => void);
  57805. /**
  57806. * Instantiates a new layer.
  57807. * This represents a full screen 2d layer.
  57808. * This can be useful to display a picture in the background of your scene for instance.
  57809. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57810. * @param name Define the name of the layer in the scene
  57811. * @param imgUrl Define the url of the texture to display in the layer
  57812. * @param scene Define the scene the layer belongs to
  57813. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57814. * @param color Defines a color for the layer
  57815. */
  57816. constructor(
  57817. /**
  57818. * Define the name of the layer.
  57819. */
  57820. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57821. private _createIndexBuffer;
  57822. /** @hidden */
  57823. _rebuild(): void;
  57824. /**
  57825. * Renders the layer in the scene.
  57826. */
  57827. render(): void;
  57828. /**
  57829. * Disposes and releases the associated ressources.
  57830. */
  57831. dispose(): void;
  57832. }
  57833. }
  57834. declare module BABYLON {
  57835. /** @hidden */
  57836. export var lensFlarePixelShader: {
  57837. name: string;
  57838. shader: string;
  57839. };
  57840. }
  57841. declare module BABYLON {
  57842. /** @hidden */
  57843. export var lensFlareVertexShader: {
  57844. name: string;
  57845. shader: string;
  57846. };
  57847. }
  57848. declare module BABYLON {
  57849. /**
  57850. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57851. * It is usually composed of several `lensFlare`.
  57852. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57853. */
  57854. export class LensFlareSystem {
  57855. /**
  57856. * Define the name of the lens flare system
  57857. */
  57858. name: string;
  57859. /**
  57860. * List of lens flares used in this system.
  57861. */
  57862. lensFlares: LensFlare[];
  57863. /**
  57864. * Define a limit from the border the lens flare can be visible.
  57865. */
  57866. borderLimit: number;
  57867. /**
  57868. * Define a viewport border we do not want to see the lens flare in.
  57869. */
  57870. viewportBorder: number;
  57871. /**
  57872. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57873. */
  57874. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57875. /**
  57876. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57877. */
  57878. layerMask: number;
  57879. /**
  57880. * Define the id of the lens flare system in the scene.
  57881. * (equal to name by default)
  57882. */
  57883. id: string;
  57884. private _scene;
  57885. private _emitter;
  57886. private _vertexBuffers;
  57887. private _indexBuffer;
  57888. private _effect;
  57889. private _positionX;
  57890. private _positionY;
  57891. private _isEnabled;
  57892. /** @hidden */
  57893. static _SceneComponentInitialization: (scene: Scene) => void;
  57894. /**
  57895. * Instantiates a lens flare system.
  57896. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57897. * It is usually composed of several `lensFlare`.
  57898. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57899. * @param name Define the name of the lens flare system in the scene
  57900. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57901. * @param scene Define the scene the lens flare system belongs to
  57902. */
  57903. constructor(
  57904. /**
  57905. * Define the name of the lens flare system
  57906. */
  57907. name: string, emitter: any, scene: Scene);
  57908. /**
  57909. * Define if the lens flare system is enabled.
  57910. */
  57911. get isEnabled(): boolean;
  57912. set isEnabled(value: boolean);
  57913. /**
  57914. * Get the scene the effects belongs to.
  57915. * @returns the scene holding the lens flare system
  57916. */
  57917. getScene(): Scene;
  57918. /**
  57919. * Get the emitter of the lens flare system.
  57920. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57921. * @returns the emitter of the lens flare system
  57922. */
  57923. getEmitter(): any;
  57924. /**
  57925. * Set the emitter of the lens flare system.
  57926. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57927. * @param newEmitter Define the new emitter of the system
  57928. */
  57929. setEmitter(newEmitter: any): void;
  57930. /**
  57931. * Get the lens flare system emitter position.
  57932. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57933. * @returns the position
  57934. */
  57935. getEmitterPosition(): Vector3;
  57936. /**
  57937. * @hidden
  57938. */
  57939. computeEffectivePosition(globalViewport: Viewport): boolean;
  57940. /** @hidden */
  57941. _isVisible(): boolean;
  57942. /**
  57943. * @hidden
  57944. */
  57945. render(): boolean;
  57946. /**
  57947. * Dispose and release the lens flare with its associated resources.
  57948. */
  57949. dispose(): void;
  57950. /**
  57951. * Parse a lens flare system from a JSON repressentation
  57952. * @param parsedLensFlareSystem Define the JSON to parse
  57953. * @param scene Define the scene the parsed system should be instantiated in
  57954. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57955. * @returns the parsed system
  57956. */
  57957. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57958. /**
  57959. * Serialize the current Lens Flare System into a JSON representation.
  57960. * @returns the serialized JSON
  57961. */
  57962. serialize(): any;
  57963. }
  57964. }
  57965. declare module BABYLON {
  57966. /**
  57967. * This represents one of the lens effect in a `lensFlareSystem`.
  57968. * It controls one of the indiviual texture used in the effect.
  57969. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57970. */
  57971. export class LensFlare {
  57972. /**
  57973. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57974. */
  57975. size: number;
  57976. /**
  57977. * 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.
  57978. */
  57979. position: number;
  57980. /**
  57981. * Define the lens color.
  57982. */
  57983. color: Color3;
  57984. /**
  57985. * Define the lens texture.
  57986. */
  57987. texture: Nullable<Texture>;
  57988. /**
  57989. * Define the alpha mode to render this particular lens.
  57990. */
  57991. alphaMode: number;
  57992. private _system;
  57993. /**
  57994. * Creates a new Lens Flare.
  57995. * This represents one of the lens effect in a `lensFlareSystem`.
  57996. * It controls one of the indiviual texture used in the effect.
  57997. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57998. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57999. * @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.
  58000. * @param color Define the lens color
  58001. * @param imgUrl Define the lens texture url
  58002. * @param system Define the `lensFlareSystem` this flare is part of
  58003. * @returns The newly created Lens Flare
  58004. */
  58005. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58006. /**
  58007. * Instantiates a new Lens Flare.
  58008. * This represents one of the lens effect in a `lensFlareSystem`.
  58009. * It controls one of the indiviual texture used in the effect.
  58010. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58011. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58012. * @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.
  58013. * @param color Define the lens color
  58014. * @param imgUrl Define the lens texture url
  58015. * @param system Define the `lensFlareSystem` this flare is part of
  58016. */
  58017. constructor(
  58018. /**
  58019. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58020. */
  58021. size: number,
  58022. /**
  58023. * 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.
  58024. */
  58025. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58026. /**
  58027. * Dispose and release the lens flare with its associated resources.
  58028. */
  58029. dispose(): void;
  58030. }
  58031. }
  58032. declare module BABYLON {
  58033. interface AbstractScene {
  58034. /**
  58035. * The list of lens flare system added to the scene
  58036. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58037. */
  58038. lensFlareSystems: Array<LensFlareSystem>;
  58039. /**
  58040. * Removes the given lens flare system from this scene.
  58041. * @param toRemove The lens flare system to remove
  58042. * @returns The index of the removed lens flare system
  58043. */
  58044. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58045. /**
  58046. * Adds the given lens flare system to this scene
  58047. * @param newLensFlareSystem The lens flare system to add
  58048. */
  58049. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58050. /**
  58051. * Gets a lens flare system using its name
  58052. * @param name defines the name to look for
  58053. * @returns the lens flare system or null if not found
  58054. */
  58055. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58056. /**
  58057. * Gets a lens flare system using its id
  58058. * @param id defines the id to look for
  58059. * @returns the lens flare system or null if not found
  58060. */
  58061. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58062. }
  58063. /**
  58064. * Defines the lens flare scene component responsible to manage any lens flares
  58065. * in a given scene.
  58066. */
  58067. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58068. /**
  58069. * The component name helpfull to identify the component in the list of scene components.
  58070. */
  58071. readonly name: string;
  58072. /**
  58073. * The scene the component belongs to.
  58074. */
  58075. scene: Scene;
  58076. /**
  58077. * Creates a new instance of the component for the given scene
  58078. * @param scene Defines the scene to register the component in
  58079. */
  58080. constructor(scene: Scene);
  58081. /**
  58082. * Registers the component in a given scene
  58083. */
  58084. register(): void;
  58085. /**
  58086. * Rebuilds the elements related to this component in case of
  58087. * context lost for instance.
  58088. */
  58089. rebuild(): void;
  58090. /**
  58091. * Adds all the elements from the container to the scene
  58092. * @param container the container holding the elements
  58093. */
  58094. addFromContainer(container: AbstractScene): void;
  58095. /**
  58096. * Removes all the elements in the container from the scene
  58097. * @param container contains the elements to remove
  58098. * @param dispose if the removed element should be disposed (default: false)
  58099. */
  58100. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58101. /**
  58102. * Serializes the component data to the specified json object
  58103. * @param serializationObject The object to serialize to
  58104. */
  58105. serialize(serializationObject: any): void;
  58106. /**
  58107. * Disposes the component and the associated ressources.
  58108. */
  58109. dispose(): void;
  58110. private _draw;
  58111. }
  58112. }
  58113. declare module BABYLON {
  58114. /** @hidden */
  58115. export var depthPixelShader: {
  58116. name: string;
  58117. shader: string;
  58118. };
  58119. }
  58120. declare module BABYLON {
  58121. /** @hidden */
  58122. export var depthVertexShader: {
  58123. name: string;
  58124. shader: string;
  58125. };
  58126. }
  58127. declare module BABYLON {
  58128. /**
  58129. * This represents a depth renderer in Babylon.
  58130. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58131. */
  58132. export class DepthRenderer {
  58133. private _scene;
  58134. private _depthMap;
  58135. private _effect;
  58136. private readonly _storeNonLinearDepth;
  58137. private readonly _clearColor;
  58138. /** Get if the depth renderer is using packed depth or not */
  58139. readonly isPacked: boolean;
  58140. private _cachedDefines;
  58141. private _camera;
  58142. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58143. enabled: boolean;
  58144. /**
  58145. * Specifiess that the depth renderer will only be used within
  58146. * the camera it is created for.
  58147. * This can help forcing its rendering during the camera processing.
  58148. */
  58149. useOnlyInActiveCamera: boolean;
  58150. /** @hidden */
  58151. static _SceneComponentInitialization: (scene: Scene) => void;
  58152. /**
  58153. * Instantiates a depth renderer
  58154. * @param scene The scene the renderer belongs to
  58155. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58156. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58157. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58158. */
  58159. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58160. /**
  58161. * Creates the depth rendering effect and checks if the effect is ready.
  58162. * @param subMesh The submesh to be used to render the depth map of
  58163. * @param useInstances If multiple world instances should be used
  58164. * @returns if the depth renderer is ready to render the depth map
  58165. */
  58166. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58167. /**
  58168. * Gets the texture which the depth map will be written to.
  58169. * @returns The depth map texture
  58170. */
  58171. getDepthMap(): RenderTargetTexture;
  58172. /**
  58173. * Disposes of the depth renderer.
  58174. */
  58175. dispose(): void;
  58176. }
  58177. }
  58178. declare module BABYLON {
  58179. /** @hidden */
  58180. export var minmaxReduxPixelShader: {
  58181. name: string;
  58182. shader: string;
  58183. };
  58184. }
  58185. declare module BABYLON {
  58186. /**
  58187. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58188. * and maximum values from all values of the texture.
  58189. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58190. * The source values are read from the red channel of the texture.
  58191. */
  58192. export class MinMaxReducer {
  58193. /**
  58194. * Observable triggered when the computation has been performed
  58195. */
  58196. onAfterReductionPerformed: Observable<{
  58197. min: number;
  58198. max: number;
  58199. }>;
  58200. protected _camera: Camera;
  58201. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58202. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58203. protected _postProcessManager: PostProcessManager;
  58204. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58205. protected _forceFullscreenViewport: boolean;
  58206. /**
  58207. * Creates a min/max reducer
  58208. * @param camera The camera to use for the post processes
  58209. */
  58210. constructor(camera: Camera);
  58211. /**
  58212. * Gets the texture used to read the values from.
  58213. */
  58214. get sourceTexture(): Nullable<RenderTargetTexture>;
  58215. /**
  58216. * Sets the source texture to read the values from.
  58217. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58218. * because in such textures '1' value must not be taken into account to compute the maximum
  58219. * as this value is used to clear the texture.
  58220. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58221. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58222. * @param depthRedux Indicates if the texture is a depth texture or not
  58223. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58224. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58225. */
  58226. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58227. /**
  58228. * Defines the refresh rate of the computation.
  58229. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58230. */
  58231. get refreshRate(): number;
  58232. set refreshRate(value: number);
  58233. protected _activated: boolean;
  58234. /**
  58235. * Gets the activation status of the reducer
  58236. */
  58237. get activated(): boolean;
  58238. /**
  58239. * Activates the reduction computation.
  58240. * When activated, the observers registered in onAfterReductionPerformed are
  58241. * called after the compuation is performed
  58242. */
  58243. activate(): void;
  58244. /**
  58245. * Deactivates the reduction computation.
  58246. */
  58247. deactivate(): void;
  58248. /**
  58249. * Disposes the min/max reducer
  58250. * @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.
  58251. */
  58252. dispose(disposeAll?: boolean): void;
  58253. }
  58254. }
  58255. declare module BABYLON {
  58256. /**
  58257. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58258. */
  58259. export class DepthReducer extends MinMaxReducer {
  58260. private _depthRenderer;
  58261. private _depthRendererId;
  58262. /**
  58263. * Gets the depth renderer used for the computation.
  58264. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58265. */
  58266. get depthRenderer(): Nullable<DepthRenderer>;
  58267. /**
  58268. * Creates a depth reducer
  58269. * @param camera The camera used to render the depth texture
  58270. */
  58271. constructor(camera: Camera);
  58272. /**
  58273. * Sets the depth renderer to use to generate the depth map
  58274. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58275. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58276. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58277. */
  58278. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58279. /** @hidden */
  58280. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58281. /**
  58282. * Activates the reduction computation.
  58283. * When activated, the observers registered in onAfterReductionPerformed are
  58284. * called after the compuation is performed
  58285. */
  58286. activate(): void;
  58287. /**
  58288. * Deactivates the reduction computation.
  58289. */
  58290. deactivate(): void;
  58291. /**
  58292. * Disposes the depth reducer
  58293. * @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.
  58294. */
  58295. dispose(disposeAll?: boolean): void;
  58296. }
  58297. }
  58298. declare module BABYLON {
  58299. /**
  58300. * A CSM implementation allowing casting shadows on large scenes.
  58301. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58302. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58303. */
  58304. export class CascadedShadowGenerator extends ShadowGenerator {
  58305. private static readonly frustumCornersNDCSpace;
  58306. /**
  58307. * Name of the CSM class
  58308. */
  58309. static CLASSNAME: string;
  58310. /**
  58311. * Defines the default number of cascades used by the CSM.
  58312. */
  58313. static readonly DEFAULT_CASCADES_COUNT: number;
  58314. /**
  58315. * Defines the minimum number of cascades used by the CSM.
  58316. */
  58317. static readonly MIN_CASCADES_COUNT: number;
  58318. /**
  58319. * Defines the maximum number of cascades used by the CSM.
  58320. */
  58321. static readonly MAX_CASCADES_COUNT: number;
  58322. protected _validateFilter(filter: number): number;
  58323. /**
  58324. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58325. */
  58326. penumbraDarkness: number;
  58327. private _numCascades;
  58328. /**
  58329. * Gets or set the number of cascades used by the CSM.
  58330. */
  58331. get numCascades(): number;
  58332. set numCascades(value: number);
  58333. /**
  58334. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58335. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58336. */
  58337. stabilizeCascades: boolean;
  58338. private _freezeShadowCastersBoundingInfo;
  58339. private _freezeShadowCastersBoundingInfoObservable;
  58340. /**
  58341. * Enables or disables the shadow casters bounding info computation.
  58342. * If your shadow casters don't move, you can disable this feature.
  58343. * If it is enabled, the bounding box computation is done every frame.
  58344. */
  58345. get freezeShadowCastersBoundingInfo(): boolean;
  58346. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58347. private _scbiMin;
  58348. private _scbiMax;
  58349. protected _computeShadowCastersBoundingInfo(): void;
  58350. protected _shadowCastersBoundingInfo: BoundingInfo;
  58351. /**
  58352. * Gets or sets the shadow casters bounding info.
  58353. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58354. * so that the system won't overwrite the bounds you provide
  58355. */
  58356. get shadowCastersBoundingInfo(): BoundingInfo;
  58357. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58358. protected _breaksAreDirty: boolean;
  58359. protected _minDistance: number;
  58360. protected _maxDistance: number;
  58361. /**
  58362. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58363. *
  58364. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58365. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58366. * @param min minimal distance for the breaks (default to 0.)
  58367. * @param max maximal distance for the breaks (default to 1.)
  58368. */
  58369. setMinMaxDistance(min: number, max: number): void;
  58370. /** Gets the minimal distance used in the cascade break computation */
  58371. get minDistance(): number;
  58372. /** Gets the maximal distance used in the cascade break computation */
  58373. get maxDistance(): number;
  58374. /**
  58375. * Gets the class name of that object
  58376. * @returns "CascadedShadowGenerator"
  58377. */
  58378. getClassName(): string;
  58379. private _cascadeMinExtents;
  58380. private _cascadeMaxExtents;
  58381. /**
  58382. * Gets a cascade minimum extents
  58383. * @param cascadeIndex index of the cascade
  58384. * @returns the minimum cascade extents
  58385. */
  58386. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58387. /**
  58388. * Gets a cascade maximum extents
  58389. * @param cascadeIndex index of the cascade
  58390. * @returns the maximum cascade extents
  58391. */
  58392. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58393. private _cascades;
  58394. private _currentLayer;
  58395. private _viewSpaceFrustumsZ;
  58396. private _viewMatrices;
  58397. private _projectionMatrices;
  58398. private _transformMatrices;
  58399. private _transformMatricesAsArray;
  58400. private _frustumLengths;
  58401. private _lightSizeUVCorrection;
  58402. private _depthCorrection;
  58403. private _frustumCornersWorldSpace;
  58404. private _frustumCenter;
  58405. private _shadowCameraPos;
  58406. private _shadowMaxZ;
  58407. /**
  58408. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58409. * It defaults to camera.maxZ
  58410. */
  58411. get shadowMaxZ(): number;
  58412. /**
  58413. * Sets the shadow max z distance.
  58414. */
  58415. set shadowMaxZ(value: number);
  58416. protected _debug: boolean;
  58417. /**
  58418. * Gets or sets the debug flag.
  58419. * When enabled, the cascades are materialized by different colors on the screen.
  58420. */
  58421. get debug(): boolean;
  58422. set debug(dbg: boolean);
  58423. private _depthClamp;
  58424. /**
  58425. * Gets or sets the depth clamping value.
  58426. *
  58427. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58428. * to account for the shadow casters far away.
  58429. *
  58430. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58431. */
  58432. get depthClamp(): boolean;
  58433. set depthClamp(value: boolean);
  58434. private _cascadeBlendPercentage;
  58435. /**
  58436. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58437. * It defaults to 0.1 (10% blending).
  58438. */
  58439. get cascadeBlendPercentage(): number;
  58440. set cascadeBlendPercentage(value: number);
  58441. private _lambda;
  58442. /**
  58443. * Gets or set the lambda parameter.
  58444. * This parameter is used to split the camera frustum and create the cascades.
  58445. * 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.
  58446. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58447. */
  58448. get lambda(): number;
  58449. set lambda(value: number);
  58450. /**
  58451. * Gets the view matrix corresponding to a given cascade
  58452. * @param cascadeNum cascade to retrieve the view matrix from
  58453. * @returns the cascade view matrix
  58454. */
  58455. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58456. /**
  58457. * Gets the projection matrix corresponding to a given cascade
  58458. * @param cascadeNum cascade to retrieve the projection matrix from
  58459. * @returns the cascade projection matrix
  58460. */
  58461. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58462. /**
  58463. * Gets the transformation matrix corresponding to a given cascade
  58464. * @param cascadeNum cascade to retrieve the transformation matrix from
  58465. * @returns the cascade transformation matrix
  58466. */
  58467. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58468. private _depthRenderer;
  58469. /**
  58470. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58471. *
  58472. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58473. *
  58474. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58475. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58476. * @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
  58477. */
  58478. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58479. private _depthReducer;
  58480. private _autoCalcDepthBounds;
  58481. /**
  58482. * Gets or sets the autoCalcDepthBounds property.
  58483. *
  58484. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58485. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58486. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58487. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58488. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58489. */
  58490. get autoCalcDepthBounds(): boolean;
  58491. set autoCalcDepthBounds(value: boolean);
  58492. /**
  58493. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58494. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58495. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58496. * for setting the refresh rate on the renderer yourself!
  58497. */
  58498. get autoCalcDepthBoundsRefreshRate(): number;
  58499. set autoCalcDepthBoundsRefreshRate(value: number);
  58500. /**
  58501. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58502. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58503. * you change the camera near/far planes!
  58504. */
  58505. splitFrustum(): void;
  58506. private _splitFrustum;
  58507. private _computeMatrices;
  58508. private _computeFrustumInWorldSpace;
  58509. private _computeCascadeFrustum;
  58510. /**
  58511. * Support test.
  58512. */
  58513. static get IsSupported(): boolean;
  58514. /** @hidden */
  58515. static _SceneComponentInitialization: (scene: Scene) => void;
  58516. /**
  58517. * Creates a Cascaded Shadow Generator object.
  58518. * A ShadowGenerator is the required tool to use the shadows.
  58519. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58520. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58521. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58522. * @param light The directional light object generating the shadows.
  58523. * @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.
  58524. */
  58525. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58526. protected _initializeGenerator(): void;
  58527. protected _createTargetRenderTexture(): void;
  58528. protected _initializeShadowMap(): void;
  58529. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58530. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58531. /**
  58532. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58533. * @param defines Defines of the material we want to update
  58534. * @param lightIndex Index of the light in the enabled light list of the material
  58535. */
  58536. prepareDefines(defines: any, lightIndex: number): void;
  58537. /**
  58538. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58539. * defined in the generator but impacting the effect).
  58540. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58541. * @param effect The effect we are binfing the information for
  58542. */
  58543. bindShadowLight(lightIndex: string, effect: Effect): void;
  58544. /**
  58545. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58546. * (eq to view projection * shadow projection matrices)
  58547. * @returns The transform matrix used to create the shadow map
  58548. */
  58549. getTransformMatrix(): Matrix;
  58550. /**
  58551. * Disposes the ShadowGenerator.
  58552. * Returns nothing.
  58553. */
  58554. dispose(): void;
  58555. /**
  58556. * Serializes the shadow generator setup to a json object.
  58557. * @returns The serialized JSON object
  58558. */
  58559. serialize(): any;
  58560. /**
  58561. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58562. * @param parsedShadowGenerator The JSON object to parse
  58563. * @param scene The scene to create the shadow map for
  58564. * @returns The parsed shadow generator
  58565. */
  58566. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58567. }
  58568. }
  58569. declare module BABYLON {
  58570. /**
  58571. * Defines the shadow generator component responsible to manage any shadow generators
  58572. * in a given scene.
  58573. */
  58574. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58575. /**
  58576. * The component name helpfull to identify the component in the list of scene components.
  58577. */
  58578. readonly name: string;
  58579. /**
  58580. * The scene the component belongs to.
  58581. */
  58582. scene: Scene;
  58583. /**
  58584. * Creates a new instance of the component for the given scene
  58585. * @param scene Defines the scene to register the component in
  58586. */
  58587. constructor(scene: Scene);
  58588. /**
  58589. * Registers the component in a given scene
  58590. */
  58591. register(): void;
  58592. /**
  58593. * Rebuilds the elements related to this component in case of
  58594. * context lost for instance.
  58595. */
  58596. rebuild(): void;
  58597. /**
  58598. * Serializes the component data to the specified json object
  58599. * @param serializationObject The object to serialize to
  58600. */
  58601. serialize(serializationObject: any): void;
  58602. /**
  58603. * Adds all the elements from the container to the scene
  58604. * @param container the container holding the elements
  58605. */
  58606. addFromContainer(container: AbstractScene): void;
  58607. /**
  58608. * Removes all the elements in the container from the scene
  58609. * @param container contains the elements to remove
  58610. * @param dispose if the removed element should be disposed (default: false)
  58611. */
  58612. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58613. /**
  58614. * Rebuilds the elements related to this component in case of
  58615. * context lost for instance.
  58616. */
  58617. dispose(): void;
  58618. private _gatherRenderTargets;
  58619. }
  58620. }
  58621. declare module BABYLON {
  58622. /**
  58623. * A point light is a light defined by an unique point in world space.
  58624. * The light is emitted in every direction from this point.
  58625. * A good example of a point light is a standard light bulb.
  58626. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58627. */
  58628. export class PointLight extends ShadowLight {
  58629. private _shadowAngle;
  58630. /**
  58631. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58632. * This specifies what angle the shadow will use to be created.
  58633. *
  58634. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58635. */
  58636. get shadowAngle(): number;
  58637. /**
  58638. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58639. * This specifies what angle the shadow will use to be created.
  58640. *
  58641. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58642. */
  58643. set shadowAngle(value: number);
  58644. /**
  58645. * Gets the direction if it has been set.
  58646. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58647. */
  58648. get direction(): Vector3;
  58649. /**
  58650. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58651. */
  58652. set direction(value: Vector3);
  58653. /**
  58654. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58655. * A PointLight emits the light in every direction.
  58656. * It can cast shadows.
  58657. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58658. * ```javascript
  58659. * var pointLight = new PointLight("pl", camera.position, scene);
  58660. * ```
  58661. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58662. * @param name The light friendly name
  58663. * @param position The position of the point light in the scene
  58664. * @param scene The scene the lights belongs to
  58665. */
  58666. constructor(name: string, position: Vector3, scene: Scene);
  58667. /**
  58668. * Returns the string "PointLight"
  58669. * @returns the class name
  58670. */
  58671. getClassName(): string;
  58672. /**
  58673. * Returns the integer 0.
  58674. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58675. */
  58676. getTypeID(): number;
  58677. /**
  58678. * Specifies wether or not the shadowmap should be a cube texture.
  58679. * @returns true if the shadowmap needs to be a cube texture.
  58680. */
  58681. needCube(): boolean;
  58682. /**
  58683. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58684. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58685. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58686. */
  58687. getShadowDirection(faceIndex?: number): Vector3;
  58688. /**
  58689. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58690. * - fov = PI / 2
  58691. * - aspect ratio : 1.0
  58692. * - z-near and far equal to the active camera minZ and maxZ.
  58693. * Returns the PointLight.
  58694. */
  58695. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58696. protected _buildUniformLayout(): void;
  58697. /**
  58698. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58699. * @param effect The effect to update
  58700. * @param lightIndex The index of the light in the effect to update
  58701. * @returns The point light
  58702. */
  58703. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58704. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58705. /**
  58706. * Prepares the list of defines specific to the light type.
  58707. * @param defines the list of defines
  58708. * @param lightIndex defines the index of the light for the effect
  58709. */
  58710. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58711. }
  58712. }
  58713. declare module BABYLON {
  58714. /**
  58715. * Header information of HDR texture files.
  58716. */
  58717. export interface HDRInfo {
  58718. /**
  58719. * The height of the texture in pixels.
  58720. */
  58721. height: number;
  58722. /**
  58723. * The width of the texture in pixels.
  58724. */
  58725. width: number;
  58726. /**
  58727. * The index of the beginning of the data in the binary file.
  58728. */
  58729. dataPosition: number;
  58730. }
  58731. /**
  58732. * This groups tools to convert HDR texture to native colors array.
  58733. */
  58734. export class HDRTools {
  58735. private static Ldexp;
  58736. private static Rgbe2float;
  58737. private static readStringLine;
  58738. /**
  58739. * Reads header information from an RGBE texture stored in a native array.
  58740. * More information on this format are available here:
  58741. * https://en.wikipedia.org/wiki/RGBE_image_format
  58742. *
  58743. * @param uint8array The binary file stored in native array.
  58744. * @return The header information.
  58745. */
  58746. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58747. /**
  58748. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58749. * This RGBE texture needs to store the information as a panorama.
  58750. *
  58751. * More information on this format are available here:
  58752. * https://en.wikipedia.org/wiki/RGBE_image_format
  58753. *
  58754. * @param buffer The binary file stored in an array buffer.
  58755. * @param size The expected size of the extracted cubemap.
  58756. * @return The Cube Map information.
  58757. */
  58758. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58759. /**
  58760. * Returns the pixels data extracted from an RGBE texture.
  58761. * This pixels will be stored left to right up to down in the R G B order in one array.
  58762. *
  58763. * More information on this format are available here:
  58764. * https://en.wikipedia.org/wiki/RGBE_image_format
  58765. *
  58766. * @param uint8array The binary file stored in an array buffer.
  58767. * @param hdrInfo The header information of the file.
  58768. * @return The pixels data in RGB right to left up to down order.
  58769. */
  58770. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58771. private static RGBE_ReadPixels_RLE;
  58772. }
  58773. }
  58774. declare module BABYLON {
  58775. /**
  58776. * Effect Render Options
  58777. */
  58778. export interface IEffectRendererOptions {
  58779. /**
  58780. * Defines the vertices positions.
  58781. */
  58782. positions?: number[];
  58783. /**
  58784. * Defines the indices.
  58785. */
  58786. indices?: number[];
  58787. }
  58788. /**
  58789. * Helper class to render one or more effects.
  58790. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58791. */
  58792. export class EffectRenderer {
  58793. private engine;
  58794. private static _DefaultOptions;
  58795. private _vertexBuffers;
  58796. private _indexBuffer;
  58797. private _fullscreenViewport;
  58798. /**
  58799. * Creates an effect renderer
  58800. * @param engine the engine to use for rendering
  58801. * @param options defines the options of the effect renderer
  58802. */
  58803. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58804. /**
  58805. * Sets the current viewport in normalized coordinates 0-1
  58806. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58807. */
  58808. setViewport(viewport?: Viewport): void;
  58809. /**
  58810. * Binds the embedded attributes buffer to the effect.
  58811. * @param effect Defines the effect to bind the attributes for
  58812. */
  58813. bindBuffers(effect: Effect): void;
  58814. /**
  58815. * Sets the current effect wrapper to use during draw.
  58816. * The effect needs to be ready before calling this api.
  58817. * This also sets the default full screen position attribute.
  58818. * @param effectWrapper Defines the effect to draw with
  58819. */
  58820. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58821. /**
  58822. * Restores engine states
  58823. */
  58824. restoreStates(): void;
  58825. /**
  58826. * Draws a full screen quad.
  58827. */
  58828. draw(): void;
  58829. private isRenderTargetTexture;
  58830. /**
  58831. * renders one or more effects to a specified texture
  58832. * @param effectWrapper the effect to renderer
  58833. * @param outputTexture texture to draw to, if null it will render to the screen.
  58834. */
  58835. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58836. /**
  58837. * Disposes of the effect renderer
  58838. */
  58839. dispose(): void;
  58840. }
  58841. /**
  58842. * Options to create an EffectWrapper
  58843. */
  58844. interface EffectWrapperCreationOptions {
  58845. /**
  58846. * Engine to use to create the effect
  58847. */
  58848. engine: ThinEngine;
  58849. /**
  58850. * Fragment shader for the effect
  58851. */
  58852. fragmentShader: string;
  58853. /**
  58854. * Use the shader store instead of direct source code
  58855. */
  58856. useShaderStore?: boolean;
  58857. /**
  58858. * Vertex shader for the effect
  58859. */
  58860. vertexShader?: string;
  58861. /**
  58862. * Attributes to use in the shader
  58863. */
  58864. attributeNames?: Array<string>;
  58865. /**
  58866. * Uniforms to use in the shader
  58867. */
  58868. uniformNames?: Array<string>;
  58869. /**
  58870. * Texture sampler names to use in the shader
  58871. */
  58872. samplerNames?: Array<string>;
  58873. /**
  58874. * Defines to use in the shader
  58875. */
  58876. defines?: Array<string>;
  58877. /**
  58878. * Callback when effect is compiled
  58879. */
  58880. onCompiled?: Nullable<(effect: Effect) => void>;
  58881. /**
  58882. * The friendly name of the effect displayed in Spector.
  58883. */
  58884. name?: string;
  58885. }
  58886. /**
  58887. * Wraps an effect to be used for rendering
  58888. */
  58889. export class EffectWrapper {
  58890. /**
  58891. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58892. */
  58893. onApplyObservable: Observable<{}>;
  58894. /**
  58895. * The underlying effect
  58896. */
  58897. effect: Effect;
  58898. /**
  58899. * Creates an effect to be renderer
  58900. * @param creationOptions options to create the effect
  58901. */
  58902. constructor(creationOptions: EffectWrapperCreationOptions);
  58903. /**
  58904. * Disposes of the effect wrapper
  58905. */
  58906. dispose(): void;
  58907. }
  58908. }
  58909. declare module BABYLON {
  58910. /** @hidden */
  58911. export var hdrFilteringVertexShader: {
  58912. name: string;
  58913. shader: string;
  58914. };
  58915. }
  58916. declare module BABYLON {
  58917. /** @hidden */
  58918. export var hdrFilteringPixelShader: {
  58919. name: string;
  58920. shader: string;
  58921. };
  58922. }
  58923. declare module BABYLON {
  58924. /**
  58925. * Options for texture filtering
  58926. */
  58927. interface IHDRFilteringOptions {
  58928. /**
  58929. * Scales pixel intensity for the input HDR map.
  58930. */
  58931. hdrScale?: number;
  58932. /**
  58933. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58934. */
  58935. quality?: number;
  58936. }
  58937. /**
  58938. * Filters HDR maps to get correct renderings of PBR reflections
  58939. */
  58940. export class HDRFiltering {
  58941. private _engine;
  58942. private _effectRenderer;
  58943. private _effectWrapper;
  58944. private _lodGenerationOffset;
  58945. private _lodGenerationScale;
  58946. /**
  58947. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58948. * you care about baking speed.
  58949. */
  58950. quality: number;
  58951. /**
  58952. * Scales pixel intensity for the input HDR map.
  58953. */
  58954. hdrScale: number;
  58955. /**
  58956. * Instantiates HDR filter for reflection maps
  58957. *
  58958. * @param engine Thin engine
  58959. * @param options Options
  58960. */
  58961. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58962. private _createRenderTarget;
  58963. private _prefilterInternal;
  58964. private _createEffect;
  58965. /**
  58966. * Get a value indicating if the filter is ready to be used
  58967. * @param texture Texture to filter
  58968. * @returns true if the filter is ready
  58969. */
  58970. isReady(texture: BaseTexture): boolean;
  58971. /**
  58972. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58973. * Prefiltering will be invoked at the end of next rendering pass.
  58974. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58975. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58976. * @param texture Texture to filter
  58977. * @param onFinished Callback when filtering is done
  58978. * @return Promise called when prefiltering is done
  58979. */
  58980. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58981. }
  58982. }
  58983. declare module BABYLON {
  58984. /**
  58985. * This represents a texture coming from an HDR input.
  58986. *
  58987. * The only supported format is currently panorama picture stored in RGBE format.
  58988. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58989. */
  58990. export class HDRCubeTexture extends BaseTexture {
  58991. private static _facesMapping;
  58992. private _generateHarmonics;
  58993. private _noMipmap;
  58994. private _prefilterOnLoad;
  58995. private _textureMatrix;
  58996. private _size;
  58997. private _onLoad;
  58998. private _onError;
  58999. /**
  59000. * The texture URL.
  59001. */
  59002. url: string;
  59003. /**
  59004. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59005. */
  59006. coordinatesMode: number;
  59007. protected _isBlocking: boolean;
  59008. /**
  59009. * Sets wether or not the texture is blocking during loading.
  59010. */
  59011. set isBlocking(value: boolean);
  59012. /**
  59013. * Gets wether or not the texture is blocking during loading.
  59014. */
  59015. get isBlocking(): boolean;
  59016. protected _rotationY: number;
  59017. /**
  59018. * Sets texture matrix rotation angle around Y axis in radians.
  59019. */
  59020. set rotationY(value: number);
  59021. /**
  59022. * Gets texture matrix rotation angle around Y axis radians.
  59023. */
  59024. get rotationY(): number;
  59025. /**
  59026. * Gets or sets the center of the bounding box associated with the cube texture
  59027. * It must define where the camera used to render the texture was set
  59028. */
  59029. boundingBoxPosition: Vector3;
  59030. private _boundingBoxSize;
  59031. /**
  59032. * Gets or sets the size of the bounding box associated with the cube texture
  59033. * When defined, the cubemap will switch to local mode
  59034. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59035. * @example https://www.babylonjs-playground.com/#RNASML
  59036. */
  59037. set boundingBoxSize(value: Vector3);
  59038. get boundingBoxSize(): Vector3;
  59039. /**
  59040. * Instantiates an HDRTexture from the following parameters.
  59041. *
  59042. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59043. * @param sceneOrEngine The scene or engine the texture will be used in
  59044. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59045. * @param noMipmap Forces to not generate the mipmap if true
  59046. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59047. * @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)
  59048. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59049. */
  59050. 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>);
  59051. /**
  59052. * Get the current class name of the texture useful for serialization or dynamic coding.
  59053. * @returns "HDRCubeTexture"
  59054. */
  59055. getClassName(): string;
  59056. /**
  59057. * Occurs when the file is raw .hdr file.
  59058. */
  59059. private loadTexture;
  59060. clone(): HDRCubeTexture;
  59061. delayLoad(): void;
  59062. /**
  59063. * Get the texture reflection matrix used to rotate/transform the reflection.
  59064. * @returns the reflection matrix
  59065. */
  59066. getReflectionTextureMatrix(): Matrix;
  59067. /**
  59068. * Set the texture reflection matrix used to rotate/transform the reflection.
  59069. * @param value Define the reflection matrix to set
  59070. */
  59071. setReflectionTextureMatrix(value: Matrix): void;
  59072. /**
  59073. * Parses a JSON representation of an HDR Texture in order to create the texture
  59074. * @param parsedTexture Define the JSON representation
  59075. * @param scene Define the scene the texture should be created in
  59076. * @param rootUrl Define the root url in case we need to load relative dependencies
  59077. * @returns the newly created texture after parsing
  59078. */
  59079. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59080. serialize(): any;
  59081. }
  59082. }
  59083. declare module BABYLON {
  59084. /**
  59085. * Class used to control physics engine
  59086. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59087. */
  59088. export class PhysicsEngine implements IPhysicsEngine {
  59089. private _physicsPlugin;
  59090. /**
  59091. * Global value used to control the smallest number supported by the simulation
  59092. */
  59093. static Epsilon: number;
  59094. private _impostors;
  59095. private _joints;
  59096. private _subTimeStep;
  59097. /**
  59098. * Gets the gravity vector used by the simulation
  59099. */
  59100. gravity: Vector3;
  59101. /**
  59102. * Factory used to create the default physics plugin.
  59103. * @returns The default physics plugin
  59104. */
  59105. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59106. /**
  59107. * Creates a new Physics Engine
  59108. * @param gravity defines the gravity vector used by the simulation
  59109. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59110. */
  59111. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59112. /**
  59113. * Sets the gravity vector used by the simulation
  59114. * @param gravity defines the gravity vector to use
  59115. */
  59116. setGravity(gravity: Vector3): void;
  59117. /**
  59118. * Set the time step of the physics engine.
  59119. * Default is 1/60.
  59120. * To slow it down, enter 1/600 for example.
  59121. * To speed it up, 1/30
  59122. * @param newTimeStep defines the new timestep to apply to this world.
  59123. */
  59124. setTimeStep(newTimeStep?: number): void;
  59125. /**
  59126. * Get the time step of the physics engine.
  59127. * @returns the current time step
  59128. */
  59129. getTimeStep(): number;
  59130. /**
  59131. * Set the sub time step of the physics engine.
  59132. * Default is 0 meaning there is no sub steps
  59133. * To increase physics resolution precision, set a small value (like 1 ms)
  59134. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59135. */
  59136. setSubTimeStep(subTimeStep?: number): void;
  59137. /**
  59138. * Get the sub time step of the physics engine.
  59139. * @returns the current sub time step
  59140. */
  59141. getSubTimeStep(): number;
  59142. /**
  59143. * Release all resources
  59144. */
  59145. dispose(): void;
  59146. /**
  59147. * Gets the name of the current physics plugin
  59148. * @returns the name of the plugin
  59149. */
  59150. getPhysicsPluginName(): string;
  59151. /**
  59152. * Adding a new impostor for the impostor tracking.
  59153. * This will be done by the impostor itself.
  59154. * @param impostor the impostor to add
  59155. */
  59156. addImpostor(impostor: PhysicsImpostor): void;
  59157. /**
  59158. * Remove an impostor from the engine.
  59159. * This impostor and its mesh will not longer be updated by the physics engine.
  59160. * @param impostor the impostor to remove
  59161. */
  59162. removeImpostor(impostor: PhysicsImpostor): void;
  59163. /**
  59164. * Add a joint to the physics engine
  59165. * @param mainImpostor defines the main impostor to which the joint is added.
  59166. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59167. * @param joint defines the joint that will connect both impostors.
  59168. */
  59169. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59170. /**
  59171. * Removes a joint from the simulation
  59172. * @param mainImpostor defines the impostor used with the joint
  59173. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59174. * @param joint defines the joint to remove
  59175. */
  59176. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59177. /**
  59178. * Called by the scene. No need to call it.
  59179. * @param delta defines the timespam between frames
  59180. */
  59181. _step(delta: number): void;
  59182. /**
  59183. * Gets the current plugin used to run the simulation
  59184. * @returns current plugin
  59185. */
  59186. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59187. /**
  59188. * Gets the list of physic impostors
  59189. * @returns an array of PhysicsImpostor
  59190. */
  59191. getImpostors(): Array<PhysicsImpostor>;
  59192. /**
  59193. * Gets the impostor for a physics enabled object
  59194. * @param object defines the object impersonated by the impostor
  59195. * @returns the PhysicsImpostor or null if not found
  59196. */
  59197. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59198. /**
  59199. * Gets the impostor for a physics body object
  59200. * @param body defines physics body used by the impostor
  59201. * @returns the PhysicsImpostor or null if not found
  59202. */
  59203. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59204. /**
  59205. * Does a raycast in the physics world
  59206. * @param from when should the ray start?
  59207. * @param to when should the ray end?
  59208. * @returns PhysicsRaycastResult
  59209. */
  59210. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59211. }
  59212. }
  59213. declare module BABYLON {
  59214. /** @hidden */
  59215. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59216. private _useDeltaForWorldStep;
  59217. world: any;
  59218. name: string;
  59219. private _physicsMaterials;
  59220. private _fixedTimeStep;
  59221. private _cannonRaycastResult;
  59222. private _raycastResult;
  59223. private _physicsBodysToRemoveAfterStep;
  59224. private _firstFrame;
  59225. BJSCANNON: any;
  59226. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59227. setGravity(gravity: Vector3): void;
  59228. setTimeStep(timeStep: number): void;
  59229. getTimeStep(): number;
  59230. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59231. private _removeMarkedPhysicsBodiesFromWorld;
  59232. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59233. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59234. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59235. private _processChildMeshes;
  59236. removePhysicsBody(impostor: PhysicsImpostor): void;
  59237. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59238. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59239. private _addMaterial;
  59240. private _checkWithEpsilon;
  59241. private _createShape;
  59242. private _createHeightmap;
  59243. private _minus90X;
  59244. private _plus90X;
  59245. private _tmpPosition;
  59246. private _tmpDeltaPosition;
  59247. private _tmpUnityRotation;
  59248. private _updatePhysicsBodyTransformation;
  59249. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59250. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59251. isSupported(): boolean;
  59252. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59253. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59254. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59255. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59256. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59257. getBodyMass(impostor: PhysicsImpostor): number;
  59258. getBodyFriction(impostor: PhysicsImpostor): number;
  59259. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59260. getBodyRestitution(impostor: PhysicsImpostor): number;
  59261. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59262. sleepBody(impostor: PhysicsImpostor): void;
  59263. wakeUpBody(impostor: PhysicsImpostor): void;
  59264. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59265. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59266. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59267. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59268. getRadius(impostor: PhysicsImpostor): number;
  59269. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59270. dispose(): void;
  59271. private _extendNamespace;
  59272. /**
  59273. * Does a raycast in the physics world
  59274. * @param from when should the ray start?
  59275. * @param to when should the ray end?
  59276. * @returns PhysicsRaycastResult
  59277. */
  59278. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59279. }
  59280. }
  59281. declare module BABYLON {
  59282. /** @hidden */
  59283. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59284. private _useDeltaForWorldStep;
  59285. world: any;
  59286. name: string;
  59287. BJSOIMO: any;
  59288. private _raycastResult;
  59289. private _fixedTimeStep;
  59290. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59291. setGravity(gravity: Vector3): void;
  59292. setTimeStep(timeStep: number): void;
  59293. getTimeStep(): number;
  59294. private _tmpImpostorsArray;
  59295. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59296. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59297. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59298. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59299. private _tmpPositionVector;
  59300. removePhysicsBody(impostor: PhysicsImpostor): void;
  59301. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59302. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59303. isSupported(): boolean;
  59304. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59305. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59306. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59307. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59308. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59309. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59310. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59311. getBodyMass(impostor: PhysicsImpostor): number;
  59312. getBodyFriction(impostor: PhysicsImpostor): number;
  59313. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59314. getBodyRestitution(impostor: PhysicsImpostor): number;
  59315. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59316. sleepBody(impostor: PhysicsImpostor): void;
  59317. wakeUpBody(impostor: PhysicsImpostor): void;
  59318. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59319. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59320. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59321. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59322. getRadius(impostor: PhysicsImpostor): number;
  59323. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59324. dispose(): void;
  59325. /**
  59326. * Does a raycast in the physics world
  59327. * @param from when should the ray start?
  59328. * @param to when should the ray end?
  59329. * @returns PhysicsRaycastResult
  59330. */
  59331. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59332. }
  59333. }
  59334. declare module BABYLON {
  59335. /**
  59336. * Class containing static functions to help procedurally build meshes
  59337. */
  59338. export class RibbonBuilder {
  59339. /**
  59340. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59341. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59342. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59343. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59344. * * 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
  59345. * * 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
  59346. * * 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
  59347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59348. * * 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
  59349. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59350. * * 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
  59351. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59352. * * 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
  59353. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59355. * @param name defines the name of the mesh
  59356. * @param options defines the options used to create the mesh
  59357. * @param scene defines the hosting scene
  59358. * @returns the ribbon mesh
  59359. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59360. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59361. */
  59362. static CreateRibbon(name: string, options: {
  59363. pathArray: Vector3[][];
  59364. closeArray?: boolean;
  59365. closePath?: boolean;
  59366. offset?: number;
  59367. updatable?: boolean;
  59368. sideOrientation?: number;
  59369. frontUVs?: Vector4;
  59370. backUVs?: Vector4;
  59371. instance?: Mesh;
  59372. invertUV?: boolean;
  59373. uvs?: Vector2[];
  59374. colors?: Color4[];
  59375. }, scene?: Nullable<Scene>): Mesh;
  59376. }
  59377. }
  59378. declare module BABYLON {
  59379. /**
  59380. * Class containing static functions to help procedurally build meshes
  59381. */
  59382. export class ShapeBuilder {
  59383. /**
  59384. * 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.
  59385. * * 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.
  59386. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59387. * * 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.
  59388. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59389. * * 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
  59390. * * 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
  59391. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59393. * * 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
  59394. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59396. * @param name defines the name of the mesh
  59397. * @param options defines the options used to create the mesh
  59398. * @param scene defines the hosting scene
  59399. * @returns the extruded shape mesh
  59400. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59402. */
  59403. static ExtrudeShape(name: string, options: {
  59404. shape: Vector3[];
  59405. path: Vector3[];
  59406. scale?: number;
  59407. rotation?: number;
  59408. cap?: number;
  59409. updatable?: boolean;
  59410. sideOrientation?: number;
  59411. frontUVs?: Vector4;
  59412. backUVs?: Vector4;
  59413. instance?: Mesh;
  59414. invertUV?: boolean;
  59415. }, scene?: Nullable<Scene>): Mesh;
  59416. /**
  59417. * Creates an custom extruded shape mesh.
  59418. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59419. * * 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.
  59420. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59421. * * 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
  59422. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59423. * * 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
  59424. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59425. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59426. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59427. * * 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
  59428. * * 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
  59429. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59431. * * 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
  59432. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59434. * @param name defines the name of the mesh
  59435. * @param options defines the options used to create the mesh
  59436. * @param scene defines the hosting scene
  59437. * @returns the custom extruded shape mesh
  59438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59439. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59441. */
  59442. static ExtrudeShapeCustom(name: string, options: {
  59443. shape: Vector3[];
  59444. path: Vector3[];
  59445. scaleFunction?: any;
  59446. rotationFunction?: any;
  59447. ribbonCloseArray?: boolean;
  59448. ribbonClosePath?: boolean;
  59449. cap?: number;
  59450. updatable?: boolean;
  59451. sideOrientation?: number;
  59452. frontUVs?: Vector4;
  59453. backUVs?: Vector4;
  59454. instance?: Mesh;
  59455. invertUV?: boolean;
  59456. }, scene?: Nullable<Scene>): Mesh;
  59457. private static _ExtrudeShapeGeneric;
  59458. }
  59459. }
  59460. declare module BABYLON {
  59461. /**
  59462. * AmmoJS Physics plugin
  59463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59464. * @see https://github.com/kripken/ammo.js/
  59465. */
  59466. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59467. private _useDeltaForWorldStep;
  59468. /**
  59469. * Reference to the Ammo library
  59470. */
  59471. bjsAMMO: any;
  59472. /**
  59473. * Created ammoJS world which physics bodies are added to
  59474. */
  59475. world: any;
  59476. /**
  59477. * Name of the plugin
  59478. */
  59479. name: string;
  59480. private _timeStep;
  59481. private _fixedTimeStep;
  59482. private _maxSteps;
  59483. private _tmpQuaternion;
  59484. private _tmpAmmoTransform;
  59485. private _tmpAmmoQuaternion;
  59486. private _tmpAmmoConcreteContactResultCallback;
  59487. private _collisionConfiguration;
  59488. private _dispatcher;
  59489. private _overlappingPairCache;
  59490. private _solver;
  59491. private _softBodySolver;
  59492. private _tmpAmmoVectorA;
  59493. private _tmpAmmoVectorB;
  59494. private _tmpAmmoVectorC;
  59495. private _tmpAmmoVectorD;
  59496. private _tmpContactCallbackResult;
  59497. private _tmpAmmoVectorRCA;
  59498. private _tmpAmmoVectorRCB;
  59499. private _raycastResult;
  59500. private static readonly DISABLE_COLLISION_FLAG;
  59501. private static readonly KINEMATIC_FLAG;
  59502. private static readonly DISABLE_DEACTIVATION_FLAG;
  59503. /**
  59504. * Initializes the ammoJS plugin
  59505. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59506. * @param ammoInjection can be used to inject your own ammo reference
  59507. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59508. */
  59509. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59510. /**
  59511. * Sets the gravity of the physics world (m/(s^2))
  59512. * @param gravity Gravity to set
  59513. */
  59514. setGravity(gravity: Vector3): void;
  59515. /**
  59516. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59517. * @param timeStep timestep to use in seconds
  59518. */
  59519. setTimeStep(timeStep: number): void;
  59520. /**
  59521. * 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)
  59522. * @param fixedTimeStep fixedTimeStep to use in seconds
  59523. */
  59524. setFixedTimeStep(fixedTimeStep: number): void;
  59525. /**
  59526. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59527. * @param maxSteps the maximum number of steps by the physics engine per frame
  59528. */
  59529. setMaxSteps(maxSteps: number): void;
  59530. /**
  59531. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59532. * @returns the current timestep in seconds
  59533. */
  59534. getTimeStep(): number;
  59535. /**
  59536. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59537. */
  59538. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59539. private _isImpostorInContact;
  59540. private _isImpostorPairInContact;
  59541. private _stepSimulation;
  59542. /**
  59543. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59544. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59545. * After the step the babylon meshes are set to the position of the physics imposters
  59546. * @param delta amount of time to step forward
  59547. * @param impostors array of imposters to update before/after the step
  59548. */
  59549. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59550. /**
  59551. * Update babylon mesh to match physics world object
  59552. * @param impostor imposter to match
  59553. */
  59554. private _afterSoftStep;
  59555. /**
  59556. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59557. * @param impostor imposter to match
  59558. */
  59559. private _ropeStep;
  59560. /**
  59561. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59562. * @param impostor imposter to match
  59563. */
  59564. private _softbodyOrClothStep;
  59565. private _tmpMatrix;
  59566. /**
  59567. * Applies an impulse on the imposter
  59568. * @param impostor imposter to apply impulse to
  59569. * @param force amount of force to be applied to the imposter
  59570. * @param contactPoint the location to apply the impulse on the imposter
  59571. */
  59572. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59573. /**
  59574. * Applies a force on the imposter
  59575. * @param impostor imposter to apply force
  59576. * @param force amount of force to be applied to the imposter
  59577. * @param contactPoint the location to apply the force on the imposter
  59578. */
  59579. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59580. /**
  59581. * Creates a physics body using the plugin
  59582. * @param impostor the imposter to create the physics body on
  59583. */
  59584. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59585. /**
  59586. * Removes the physics body from the imposter and disposes of the body's memory
  59587. * @param impostor imposter to remove the physics body from
  59588. */
  59589. removePhysicsBody(impostor: PhysicsImpostor): void;
  59590. /**
  59591. * Generates a joint
  59592. * @param impostorJoint the imposter joint to create the joint with
  59593. */
  59594. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59595. /**
  59596. * Removes a joint
  59597. * @param impostorJoint the imposter joint to remove the joint from
  59598. */
  59599. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59600. private _addMeshVerts;
  59601. /**
  59602. * Initialise the soft body vertices to match its object's (mesh) vertices
  59603. * Softbody vertices (nodes) are in world space and to match this
  59604. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59605. * @param impostor to create the softbody for
  59606. */
  59607. private _softVertexData;
  59608. /**
  59609. * Create an impostor's soft body
  59610. * @param impostor to create the softbody for
  59611. */
  59612. private _createSoftbody;
  59613. /**
  59614. * Create cloth for an impostor
  59615. * @param impostor to create the softbody for
  59616. */
  59617. private _createCloth;
  59618. /**
  59619. * Create rope for an impostor
  59620. * @param impostor to create the softbody for
  59621. */
  59622. private _createRope;
  59623. /**
  59624. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59625. * @param impostor to create the custom physics shape for
  59626. */
  59627. private _createCustom;
  59628. private _addHullVerts;
  59629. private _createShape;
  59630. /**
  59631. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59632. * @param impostor imposter containing the physics body and babylon object
  59633. */
  59634. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59635. /**
  59636. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59637. * @param impostor imposter containing the physics body and babylon object
  59638. * @param newPosition new position
  59639. * @param newRotation new rotation
  59640. */
  59641. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59642. /**
  59643. * If this plugin is supported
  59644. * @returns true if its supported
  59645. */
  59646. isSupported(): boolean;
  59647. /**
  59648. * Sets the linear velocity of the physics body
  59649. * @param impostor imposter to set the velocity on
  59650. * @param velocity velocity to set
  59651. */
  59652. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59653. /**
  59654. * Sets the angular velocity of the physics body
  59655. * @param impostor imposter to set the velocity on
  59656. * @param velocity velocity to set
  59657. */
  59658. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59659. /**
  59660. * gets the linear velocity
  59661. * @param impostor imposter to get linear velocity from
  59662. * @returns linear velocity
  59663. */
  59664. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59665. /**
  59666. * gets the angular velocity
  59667. * @param impostor imposter to get angular velocity from
  59668. * @returns angular velocity
  59669. */
  59670. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59671. /**
  59672. * Sets the mass of physics body
  59673. * @param impostor imposter to set the mass on
  59674. * @param mass mass to set
  59675. */
  59676. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59677. /**
  59678. * Gets the mass of the physics body
  59679. * @param impostor imposter to get the mass from
  59680. * @returns mass
  59681. */
  59682. getBodyMass(impostor: PhysicsImpostor): number;
  59683. /**
  59684. * Gets friction of the impostor
  59685. * @param impostor impostor to get friction from
  59686. * @returns friction value
  59687. */
  59688. getBodyFriction(impostor: PhysicsImpostor): number;
  59689. /**
  59690. * Sets friction of the impostor
  59691. * @param impostor impostor to set friction on
  59692. * @param friction friction value
  59693. */
  59694. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59695. /**
  59696. * Gets restitution of the impostor
  59697. * @param impostor impostor to get restitution from
  59698. * @returns restitution value
  59699. */
  59700. getBodyRestitution(impostor: PhysicsImpostor): number;
  59701. /**
  59702. * Sets resitution of the impostor
  59703. * @param impostor impostor to set resitution on
  59704. * @param restitution resitution value
  59705. */
  59706. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59707. /**
  59708. * Gets pressure inside the impostor
  59709. * @param impostor impostor to get pressure from
  59710. * @returns pressure value
  59711. */
  59712. getBodyPressure(impostor: PhysicsImpostor): number;
  59713. /**
  59714. * Sets pressure inside a soft body impostor
  59715. * Cloth and rope must remain 0 pressure
  59716. * @param impostor impostor to set pressure on
  59717. * @param pressure pressure value
  59718. */
  59719. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59720. /**
  59721. * Gets stiffness of the impostor
  59722. * @param impostor impostor to get stiffness from
  59723. * @returns pressure value
  59724. */
  59725. getBodyStiffness(impostor: PhysicsImpostor): number;
  59726. /**
  59727. * Sets stiffness of the impostor
  59728. * @param impostor impostor to set stiffness on
  59729. * @param stiffness stiffness value from 0 to 1
  59730. */
  59731. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59732. /**
  59733. * Gets velocityIterations of the impostor
  59734. * @param impostor impostor to get velocity iterations from
  59735. * @returns velocityIterations value
  59736. */
  59737. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59738. /**
  59739. * Sets velocityIterations of the impostor
  59740. * @param impostor impostor to set velocity iterations on
  59741. * @param velocityIterations velocityIterations value
  59742. */
  59743. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59744. /**
  59745. * Gets positionIterations of the impostor
  59746. * @param impostor impostor to get position iterations from
  59747. * @returns positionIterations value
  59748. */
  59749. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59750. /**
  59751. * Sets positionIterations of the impostor
  59752. * @param impostor impostor to set position on
  59753. * @param positionIterations positionIterations value
  59754. */
  59755. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59756. /**
  59757. * Append an anchor to a cloth object
  59758. * @param impostor is the cloth impostor to add anchor to
  59759. * @param otherImpostor is the rigid impostor to anchor to
  59760. * @param width ratio across width from 0 to 1
  59761. * @param height ratio up height from 0 to 1
  59762. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59763. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59764. */
  59765. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59766. /**
  59767. * Append an hook to a rope object
  59768. * @param impostor is the rope impostor to add hook to
  59769. * @param otherImpostor is the rigid impostor to hook to
  59770. * @param length ratio along the rope from 0 to 1
  59771. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59772. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59773. */
  59774. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59775. /**
  59776. * Sleeps the physics body and stops it from being active
  59777. * @param impostor impostor to sleep
  59778. */
  59779. sleepBody(impostor: PhysicsImpostor): void;
  59780. /**
  59781. * Activates the physics body
  59782. * @param impostor impostor to activate
  59783. */
  59784. wakeUpBody(impostor: PhysicsImpostor): void;
  59785. /**
  59786. * Updates the distance parameters of the joint
  59787. * @param joint joint to update
  59788. * @param maxDistance maximum distance of the joint
  59789. * @param minDistance minimum distance of the joint
  59790. */
  59791. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59792. /**
  59793. * Sets a motor on the joint
  59794. * @param joint joint to set motor on
  59795. * @param speed speed of the motor
  59796. * @param maxForce maximum force of the motor
  59797. * @param motorIndex index of the motor
  59798. */
  59799. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59800. /**
  59801. * Sets the motors limit
  59802. * @param joint joint to set limit on
  59803. * @param upperLimit upper limit
  59804. * @param lowerLimit lower limit
  59805. */
  59806. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59807. /**
  59808. * Syncs the position and rotation of a mesh with the impostor
  59809. * @param mesh mesh to sync
  59810. * @param impostor impostor to update the mesh with
  59811. */
  59812. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59813. /**
  59814. * Gets the radius of the impostor
  59815. * @param impostor impostor to get radius from
  59816. * @returns the radius
  59817. */
  59818. getRadius(impostor: PhysicsImpostor): number;
  59819. /**
  59820. * Gets the box size of the impostor
  59821. * @param impostor impostor to get box size from
  59822. * @param result the resulting box size
  59823. */
  59824. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59825. /**
  59826. * Disposes of the impostor
  59827. */
  59828. dispose(): void;
  59829. /**
  59830. * Does a raycast in the physics world
  59831. * @param from when should the ray start?
  59832. * @param to when should the ray end?
  59833. * @returns PhysicsRaycastResult
  59834. */
  59835. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59836. }
  59837. }
  59838. declare module BABYLON {
  59839. interface AbstractScene {
  59840. /**
  59841. * The list of reflection probes added to the scene
  59842. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59843. */
  59844. reflectionProbes: Array<ReflectionProbe>;
  59845. /**
  59846. * Removes the given reflection probe from this scene.
  59847. * @param toRemove The reflection probe to remove
  59848. * @returns The index of the removed reflection probe
  59849. */
  59850. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59851. /**
  59852. * Adds the given reflection probe to this scene.
  59853. * @param newReflectionProbe The reflection probe to add
  59854. */
  59855. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59856. }
  59857. /**
  59858. * Class used to generate realtime reflection / refraction cube textures
  59859. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59860. */
  59861. export class ReflectionProbe {
  59862. /** defines the name of the probe */
  59863. name: string;
  59864. private _scene;
  59865. private _renderTargetTexture;
  59866. private _projectionMatrix;
  59867. private _viewMatrix;
  59868. private _target;
  59869. private _add;
  59870. private _attachedMesh;
  59871. private _invertYAxis;
  59872. /** Gets or sets probe position (center of the cube map) */
  59873. position: Vector3;
  59874. /**
  59875. * Creates a new reflection probe
  59876. * @param name defines the name of the probe
  59877. * @param size defines the texture resolution (for each face)
  59878. * @param scene defines the hosting scene
  59879. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59880. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59881. */
  59882. constructor(
  59883. /** defines the name of the probe */
  59884. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59885. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59886. get samples(): number;
  59887. set samples(value: number);
  59888. /** Gets or sets the refresh rate to use (on every frame by default) */
  59889. get refreshRate(): number;
  59890. set refreshRate(value: number);
  59891. /**
  59892. * Gets the hosting scene
  59893. * @returns a Scene
  59894. */
  59895. getScene(): Scene;
  59896. /** Gets the internal CubeTexture used to render to */
  59897. get cubeTexture(): RenderTargetTexture;
  59898. /** Gets the list of meshes to render */
  59899. get renderList(): Nullable<AbstractMesh[]>;
  59900. /**
  59901. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59902. * @param mesh defines the mesh to attach to
  59903. */
  59904. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59905. /**
  59906. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59907. * @param renderingGroupId The rendering group id corresponding to its index
  59908. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59909. */
  59910. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59911. /**
  59912. * Clean all associated resources
  59913. */
  59914. dispose(): void;
  59915. /**
  59916. * Converts the reflection probe information to a readable string for debug purpose.
  59917. * @param fullDetails Supports for multiple levels of logging within scene loading
  59918. * @returns the human readable reflection probe info
  59919. */
  59920. toString(fullDetails?: boolean): string;
  59921. /**
  59922. * Get the class name of the relfection probe.
  59923. * @returns "ReflectionProbe"
  59924. */
  59925. getClassName(): string;
  59926. /**
  59927. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59928. * @returns The JSON representation of the texture
  59929. */
  59930. serialize(): any;
  59931. /**
  59932. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59933. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59934. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59935. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59936. * @returns The parsed reflection probe if successful
  59937. */
  59938. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59939. }
  59940. }
  59941. declare module BABYLON {
  59942. /** @hidden */
  59943. export var _BabylonLoaderRegistered: boolean;
  59944. /**
  59945. * Helps setting up some configuration for the babylon file loader.
  59946. */
  59947. export class BabylonFileLoaderConfiguration {
  59948. /**
  59949. * The loader does not allow injecting custom physix engine into the plugins.
  59950. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59951. * So you could set this variable to your engine import to make it work.
  59952. */
  59953. static LoaderInjectedPhysicsEngine: any;
  59954. }
  59955. }
  59956. declare module BABYLON {
  59957. /**
  59958. * The Physically based simple base material of BJS.
  59959. *
  59960. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59961. * It is used as the base class for both the specGloss and metalRough conventions.
  59962. */
  59963. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59964. /**
  59965. * Number of Simultaneous lights allowed on the material.
  59966. */
  59967. maxSimultaneousLights: number;
  59968. /**
  59969. * If sets to true, disables all the lights affecting the material.
  59970. */
  59971. disableLighting: boolean;
  59972. /**
  59973. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59974. */
  59975. environmentTexture: BaseTexture;
  59976. /**
  59977. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59978. */
  59979. invertNormalMapX: boolean;
  59980. /**
  59981. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59982. */
  59983. invertNormalMapY: boolean;
  59984. /**
  59985. * Normal map used in the model.
  59986. */
  59987. normalTexture: BaseTexture;
  59988. /**
  59989. * Emissivie color used to self-illuminate the model.
  59990. */
  59991. emissiveColor: Color3;
  59992. /**
  59993. * Emissivie texture used to self-illuminate the model.
  59994. */
  59995. emissiveTexture: BaseTexture;
  59996. /**
  59997. * Occlusion Channel Strenght.
  59998. */
  59999. occlusionStrength: number;
  60000. /**
  60001. * Occlusion Texture of the material (adding extra occlusion effects).
  60002. */
  60003. occlusionTexture: BaseTexture;
  60004. /**
  60005. * Defines the alpha limits in alpha test mode.
  60006. */
  60007. alphaCutOff: number;
  60008. /**
  60009. * Gets the current double sided mode.
  60010. */
  60011. get doubleSided(): boolean;
  60012. /**
  60013. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60014. */
  60015. set doubleSided(value: boolean);
  60016. /**
  60017. * Stores the pre-calculated light information of a mesh in a texture.
  60018. */
  60019. lightmapTexture: BaseTexture;
  60020. /**
  60021. * If true, the light map contains occlusion information instead of lighting info.
  60022. */
  60023. useLightmapAsShadowmap: boolean;
  60024. /**
  60025. * Instantiates a new PBRMaterial instance.
  60026. *
  60027. * @param name The material name
  60028. * @param scene The scene the material will be use in.
  60029. */
  60030. constructor(name: string, scene: Scene);
  60031. getClassName(): string;
  60032. }
  60033. }
  60034. declare module BABYLON {
  60035. /**
  60036. * The PBR material of BJS following the metal roughness convention.
  60037. *
  60038. * This fits to the PBR convention in the GLTF definition:
  60039. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60040. */
  60041. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60042. /**
  60043. * The base color has two different interpretations depending on the value of metalness.
  60044. * When the material is a metal, the base color is the specific measured reflectance value
  60045. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60046. * of the material.
  60047. */
  60048. baseColor: Color3;
  60049. /**
  60050. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60051. * well as opacity information in the alpha channel.
  60052. */
  60053. baseTexture: BaseTexture;
  60054. /**
  60055. * Specifies the metallic scalar value of the material.
  60056. * Can also be used to scale the metalness values of the metallic texture.
  60057. */
  60058. metallic: number;
  60059. /**
  60060. * Specifies the roughness scalar value of the material.
  60061. * Can also be used to scale the roughness values of the metallic texture.
  60062. */
  60063. roughness: number;
  60064. /**
  60065. * Texture containing both the metallic value in the B channel and the
  60066. * roughness value in the G channel to keep better precision.
  60067. */
  60068. metallicRoughnessTexture: BaseTexture;
  60069. /**
  60070. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60071. *
  60072. * @param name The material name
  60073. * @param scene The scene the material will be use in.
  60074. */
  60075. constructor(name: string, scene: Scene);
  60076. /**
  60077. * Return the currrent class name of the material.
  60078. */
  60079. getClassName(): string;
  60080. /**
  60081. * Makes a duplicate of the current material.
  60082. * @param name - name to use for the new material.
  60083. */
  60084. clone(name: string): PBRMetallicRoughnessMaterial;
  60085. /**
  60086. * Serialize the material to a parsable JSON object.
  60087. */
  60088. serialize(): any;
  60089. /**
  60090. * Parses a JSON object correponding to the serialize function.
  60091. */
  60092. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60093. }
  60094. }
  60095. declare module BABYLON {
  60096. /**
  60097. * The PBR material of BJS following the specular glossiness convention.
  60098. *
  60099. * This fits to the PBR convention in the GLTF definition:
  60100. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60101. */
  60102. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60103. /**
  60104. * Specifies the diffuse color of the material.
  60105. */
  60106. diffuseColor: Color3;
  60107. /**
  60108. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60109. * channel.
  60110. */
  60111. diffuseTexture: BaseTexture;
  60112. /**
  60113. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60114. */
  60115. specularColor: Color3;
  60116. /**
  60117. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60118. */
  60119. glossiness: number;
  60120. /**
  60121. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60122. */
  60123. specularGlossinessTexture: BaseTexture;
  60124. /**
  60125. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60126. *
  60127. * @param name The material name
  60128. * @param scene The scene the material will be use in.
  60129. */
  60130. constructor(name: string, scene: Scene);
  60131. /**
  60132. * Return the currrent class name of the material.
  60133. */
  60134. getClassName(): string;
  60135. /**
  60136. * Makes a duplicate of the current material.
  60137. * @param name - name to use for the new material.
  60138. */
  60139. clone(name: string): PBRSpecularGlossinessMaterial;
  60140. /**
  60141. * Serialize the material to a parsable JSON object.
  60142. */
  60143. serialize(): any;
  60144. /**
  60145. * Parses a JSON object correponding to the serialize function.
  60146. */
  60147. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60148. }
  60149. }
  60150. declare module BABYLON {
  60151. /**
  60152. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60153. * It can help converting any input color in a desired output one. This can then be used to create effects
  60154. * from sepia, black and white to sixties or futuristic rendering...
  60155. *
  60156. * The only supported format is currently 3dl.
  60157. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60158. */
  60159. export class ColorGradingTexture extends BaseTexture {
  60160. /**
  60161. * The texture URL.
  60162. */
  60163. url: string;
  60164. /**
  60165. * Empty line regex stored for GC.
  60166. */
  60167. private static _noneEmptyLineRegex;
  60168. private _textureMatrix;
  60169. private _onLoad;
  60170. /**
  60171. * Instantiates a ColorGradingTexture from the following parameters.
  60172. *
  60173. * @param url The location of the color gradind data (currently only supporting 3dl)
  60174. * @param sceneOrEngine The scene or engine the texture will be used in
  60175. * @param onLoad defines a callback triggered when the texture has been loaded
  60176. */
  60177. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60178. /**
  60179. * Fires the onload event from the constructor if requested.
  60180. */
  60181. private _triggerOnLoad;
  60182. /**
  60183. * Returns the texture matrix used in most of the material.
  60184. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60185. */
  60186. getTextureMatrix(): Matrix;
  60187. /**
  60188. * Occurs when the file being loaded is a .3dl LUT file.
  60189. */
  60190. private load3dlTexture;
  60191. /**
  60192. * Starts the loading process of the texture.
  60193. */
  60194. private loadTexture;
  60195. /**
  60196. * Clones the color gradind texture.
  60197. */
  60198. clone(): ColorGradingTexture;
  60199. /**
  60200. * Called during delayed load for textures.
  60201. */
  60202. delayLoad(): void;
  60203. /**
  60204. * Parses a color grading texture serialized by Babylon.
  60205. * @param parsedTexture The texture information being parsedTexture
  60206. * @param scene The scene to load the texture in
  60207. * @param rootUrl The root url of the data assets to load
  60208. * @return A color gradind texture
  60209. */
  60210. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60211. /**
  60212. * Serializes the LUT texture to json format.
  60213. */
  60214. serialize(): any;
  60215. }
  60216. }
  60217. declare module BABYLON {
  60218. /**
  60219. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60220. */
  60221. export class EquiRectangularCubeTexture extends BaseTexture {
  60222. /** The six faces of the cube. */
  60223. private static _FacesMapping;
  60224. private _noMipmap;
  60225. private _onLoad;
  60226. private _onError;
  60227. /** The size of the cubemap. */
  60228. private _size;
  60229. /** The buffer of the image. */
  60230. private _buffer;
  60231. /** The width of the input image. */
  60232. private _width;
  60233. /** The height of the input image. */
  60234. private _height;
  60235. /** The URL to the image. */
  60236. url: string;
  60237. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60238. coordinatesMode: number;
  60239. /**
  60240. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60241. * @param url The location of the image
  60242. * @param scene The scene the texture will be used in
  60243. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60244. * @param noMipmap Forces to not generate the mipmap if true
  60245. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60246. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60247. * @param onLoad — defines a callback called when texture is loaded
  60248. * @param onError — defines a callback called if there is an error
  60249. */
  60250. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60251. /**
  60252. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60253. */
  60254. private loadImage;
  60255. /**
  60256. * Convert the image buffer into a cubemap and create a CubeTexture.
  60257. */
  60258. private loadTexture;
  60259. /**
  60260. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60261. * @param buffer The ArrayBuffer that should be converted.
  60262. * @returns The buffer as Float32Array.
  60263. */
  60264. private getFloat32ArrayFromArrayBuffer;
  60265. /**
  60266. * Get the current class name of the texture useful for serialization or dynamic coding.
  60267. * @returns "EquiRectangularCubeTexture"
  60268. */
  60269. getClassName(): string;
  60270. /**
  60271. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60272. * @returns A clone of the current EquiRectangularCubeTexture.
  60273. */
  60274. clone(): EquiRectangularCubeTexture;
  60275. }
  60276. }
  60277. declare module BABYLON {
  60278. /**
  60279. * Defines the options related to the creation of an HtmlElementTexture
  60280. */
  60281. export interface IHtmlElementTextureOptions {
  60282. /**
  60283. * Defines wether mip maps should be created or not.
  60284. */
  60285. generateMipMaps?: boolean;
  60286. /**
  60287. * Defines the sampling mode of the texture.
  60288. */
  60289. samplingMode?: number;
  60290. /**
  60291. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60292. */
  60293. engine: Nullable<ThinEngine>;
  60294. /**
  60295. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60296. */
  60297. scene: Nullable<Scene>;
  60298. }
  60299. /**
  60300. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60301. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60302. * is automatically managed.
  60303. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60304. * in your application.
  60305. *
  60306. * As the update is not automatic, you need to call them manually.
  60307. */
  60308. export class HtmlElementTexture extends BaseTexture {
  60309. /**
  60310. * The texture URL.
  60311. */
  60312. element: HTMLVideoElement | HTMLCanvasElement;
  60313. private static readonly DefaultOptions;
  60314. private _textureMatrix;
  60315. private _isVideo;
  60316. private _generateMipMaps;
  60317. private _samplingMode;
  60318. /**
  60319. * Instantiates a HtmlElementTexture from the following parameters.
  60320. *
  60321. * @param name Defines the name of the texture
  60322. * @param element Defines the video or canvas the texture is filled with
  60323. * @param options Defines the other none mandatory texture creation options
  60324. */
  60325. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60326. private _createInternalTexture;
  60327. /**
  60328. * Returns the texture matrix used in most of the material.
  60329. */
  60330. getTextureMatrix(): Matrix;
  60331. /**
  60332. * Updates the content of the texture.
  60333. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60334. */
  60335. update(invertY?: Nullable<boolean>): void;
  60336. }
  60337. }
  60338. declare module BABYLON {
  60339. /**
  60340. * Based on jsTGALoader - Javascript loader for TGA file
  60341. * By Vincent Thibault
  60342. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60343. */
  60344. export class TGATools {
  60345. private static _TYPE_INDEXED;
  60346. private static _TYPE_RGB;
  60347. private static _TYPE_GREY;
  60348. private static _TYPE_RLE_INDEXED;
  60349. private static _TYPE_RLE_RGB;
  60350. private static _TYPE_RLE_GREY;
  60351. private static _ORIGIN_MASK;
  60352. private static _ORIGIN_SHIFT;
  60353. private static _ORIGIN_BL;
  60354. private static _ORIGIN_BR;
  60355. private static _ORIGIN_UL;
  60356. private static _ORIGIN_UR;
  60357. /**
  60358. * Gets the header of a TGA file
  60359. * @param data defines the TGA data
  60360. * @returns the header
  60361. */
  60362. static GetTGAHeader(data: Uint8Array): any;
  60363. /**
  60364. * Uploads TGA content to a Babylon Texture
  60365. * @hidden
  60366. */
  60367. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60368. /** @hidden */
  60369. 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;
  60370. /** @hidden */
  60371. 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;
  60372. /** @hidden */
  60373. 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;
  60374. /** @hidden */
  60375. 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;
  60376. /** @hidden */
  60377. 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;
  60378. /** @hidden */
  60379. 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;
  60380. }
  60381. }
  60382. declare module BABYLON {
  60383. /**
  60384. * Implementation of the TGA Texture Loader.
  60385. * @hidden
  60386. */
  60387. export class _TGATextureLoader implements IInternalTextureLoader {
  60388. /**
  60389. * Defines wether the loader supports cascade loading the different faces.
  60390. */
  60391. readonly supportCascades: boolean;
  60392. /**
  60393. * This returns if the loader support the current file information.
  60394. * @param extension defines the file extension of the file being loaded
  60395. * @returns true if the loader can load the specified file
  60396. */
  60397. canLoad(extension: string): boolean;
  60398. /**
  60399. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60400. * @param data contains the texture data
  60401. * @param texture defines the BabylonJS internal texture
  60402. * @param createPolynomials will be true if polynomials have been requested
  60403. * @param onLoad defines the callback to trigger once the texture is ready
  60404. * @param onError defines the callback to trigger in case of error
  60405. */
  60406. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60407. /**
  60408. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60409. * @param data contains the texture data
  60410. * @param texture defines the BabylonJS internal texture
  60411. * @param callback defines the method to call once ready to upload
  60412. */
  60413. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60414. }
  60415. }
  60416. declare module BABYLON {
  60417. /**
  60418. * Info about the .basis files
  60419. */
  60420. class BasisFileInfo {
  60421. /**
  60422. * If the file has alpha
  60423. */
  60424. hasAlpha: boolean;
  60425. /**
  60426. * Info about each image of the basis file
  60427. */
  60428. images: Array<{
  60429. levels: Array<{
  60430. width: number;
  60431. height: number;
  60432. transcodedPixels: ArrayBufferView;
  60433. }>;
  60434. }>;
  60435. }
  60436. /**
  60437. * Result of transcoding a basis file
  60438. */
  60439. class TranscodeResult {
  60440. /**
  60441. * Info about the .basis file
  60442. */
  60443. fileInfo: BasisFileInfo;
  60444. /**
  60445. * Format to use when loading the file
  60446. */
  60447. format: number;
  60448. }
  60449. /**
  60450. * Configuration options for the Basis transcoder
  60451. */
  60452. export class BasisTranscodeConfiguration {
  60453. /**
  60454. * Supported compression formats used to determine the supported output format of the transcoder
  60455. */
  60456. supportedCompressionFormats?: {
  60457. /**
  60458. * etc1 compression format
  60459. */
  60460. etc1?: boolean;
  60461. /**
  60462. * s3tc compression format
  60463. */
  60464. s3tc?: boolean;
  60465. /**
  60466. * pvrtc compression format
  60467. */
  60468. pvrtc?: boolean;
  60469. /**
  60470. * etc2 compression format
  60471. */
  60472. etc2?: boolean;
  60473. };
  60474. /**
  60475. * If mipmap levels should be loaded for transcoded images (Default: true)
  60476. */
  60477. loadMipmapLevels?: boolean;
  60478. /**
  60479. * Index of a single image to load (Default: all images)
  60480. */
  60481. loadSingleImage?: number;
  60482. }
  60483. /**
  60484. * Used to load .Basis files
  60485. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60486. */
  60487. export class BasisTools {
  60488. private static _IgnoreSupportedFormats;
  60489. /**
  60490. * URL to use when loading the basis transcoder
  60491. */
  60492. static JSModuleURL: string;
  60493. /**
  60494. * URL to use when loading the wasm module for the transcoder
  60495. */
  60496. static WasmModuleURL: string;
  60497. /**
  60498. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60499. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60500. * @returns internal format corresponding to the Basis format
  60501. */
  60502. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60503. private static _WorkerPromise;
  60504. private static _Worker;
  60505. private static _actionId;
  60506. private static _CreateWorkerAsync;
  60507. /**
  60508. * Transcodes a loaded image file to compressed pixel data
  60509. * @param data image data to transcode
  60510. * @param config configuration options for the transcoding
  60511. * @returns a promise resulting in the transcoded image
  60512. */
  60513. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60514. /**
  60515. * Loads a texture from the transcode result
  60516. * @param texture texture load to
  60517. * @param transcodeResult the result of transcoding the basis file to load from
  60518. */
  60519. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60520. }
  60521. }
  60522. declare module BABYLON {
  60523. /**
  60524. * Loader for .basis file format
  60525. */
  60526. export class _BasisTextureLoader implements IInternalTextureLoader {
  60527. /**
  60528. * Defines whether the loader supports cascade loading the different faces.
  60529. */
  60530. readonly supportCascades: boolean;
  60531. /**
  60532. * This returns if the loader support the current file information.
  60533. * @param extension defines the file extension of the file being loaded
  60534. * @returns true if the loader can load the specified file
  60535. */
  60536. canLoad(extension: string): boolean;
  60537. /**
  60538. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60539. * @param data contains the texture data
  60540. * @param texture defines the BabylonJS internal texture
  60541. * @param createPolynomials will be true if polynomials have been requested
  60542. * @param onLoad defines the callback to trigger once the texture is ready
  60543. * @param onError defines the callback to trigger in case of error
  60544. */
  60545. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60546. /**
  60547. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60548. * @param data contains the texture data
  60549. * @param texture defines the BabylonJS internal texture
  60550. * @param callback defines the method to call once ready to upload
  60551. */
  60552. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60553. }
  60554. }
  60555. declare module BABYLON {
  60556. /**
  60557. * Defines the basic options interface of a TexturePacker Frame
  60558. */
  60559. export interface ITexturePackerFrame {
  60560. /**
  60561. * The frame ID
  60562. */
  60563. id: number;
  60564. /**
  60565. * The frames Scale
  60566. */
  60567. scale: Vector2;
  60568. /**
  60569. * The Frames offset
  60570. */
  60571. offset: Vector2;
  60572. }
  60573. /**
  60574. * This is a support class for frame Data on texture packer sets.
  60575. */
  60576. export class TexturePackerFrame implements ITexturePackerFrame {
  60577. /**
  60578. * The frame ID
  60579. */
  60580. id: number;
  60581. /**
  60582. * The frames Scale
  60583. */
  60584. scale: Vector2;
  60585. /**
  60586. * The Frames offset
  60587. */
  60588. offset: Vector2;
  60589. /**
  60590. * Initializes a texture package frame.
  60591. * @param id The numerical frame identifier
  60592. * @param scale Scalar Vector2 for UV frame
  60593. * @param offset Vector2 for the frame position in UV units.
  60594. * @returns TexturePackerFrame
  60595. */
  60596. constructor(id: number, scale: Vector2, offset: Vector2);
  60597. }
  60598. }
  60599. declare module BABYLON {
  60600. /**
  60601. * Defines the basic options interface of a TexturePacker
  60602. */
  60603. export interface ITexturePackerOptions {
  60604. /**
  60605. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60606. */
  60607. map?: string[];
  60608. /**
  60609. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60610. */
  60611. uvsIn?: string;
  60612. /**
  60613. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60614. */
  60615. uvsOut?: string;
  60616. /**
  60617. * number representing the layout style. Defaults to LAYOUT_STRIP
  60618. */
  60619. layout?: number;
  60620. /**
  60621. * number of columns if using custom column count layout(2). This defaults to 4.
  60622. */
  60623. colnum?: number;
  60624. /**
  60625. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60626. */
  60627. updateInputMeshes?: boolean;
  60628. /**
  60629. * boolean flag to dispose all the source textures. Defaults to true.
  60630. */
  60631. disposeSources?: boolean;
  60632. /**
  60633. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60634. */
  60635. fillBlanks?: boolean;
  60636. /**
  60637. * string value representing the context fill style color. Defaults to 'black'.
  60638. */
  60639. customFillColor?: string;
  60640. /**
  60641. * Width and Height Value of each Frame in the TexturePacker Sets
  60642. */
  60643. frameSize?: number;
  60644. /**
  60645. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60646. */
  60647. paddingRatio?: number;
  60648. /**
  60649. * Number that declares the fill method for the padding gutter.
  60650. */
  60651. paddingMode?: number;
  60652. /**
  60653. * If in SUBUV_COLOR padding mode what color to use.
  60654. */
  60655. paddingColor?: Color3 | Color4;
  60656. }
  60657. /**
  60658. * Defines the basic interface of a TexturePacker JSON File
  60659. */
  60660. export interface ITexturePackerJSON {
  60661. /**
  60662. * The frame ID
  60663. */
  60664. name: string;
  60665. /**
  60666. * The base64 channel data
  60667. */
  60668. sets: any;
  60669. /**
  60670. * The options of the Packer
  60671. */
  60672. options: ITexturePackerOptions;
  60673. /**
  60674. * The frame data of the Packer
  60675. */
  60676. frames: Array<number>;
  60677. }
  60678. /**
  60679. * This is a support class that generates a series of packed texture sets.
  60680. * @see https://doc.babylonjs.com/babylon101/materials
  60681. */
  60682. export class TexturePacker {
  60683. /** Packer Layout Constant 0 */
  60684. static readonly LAYOUT_STRIP: number;
  60685. /** Packer Layout Constant 1 */
  60686. static readonly LAYOUT_POWER2: number;
  60687. /** Packer Layout Constant 2 */
  60688. static readonly LAYOUT_COLNUM: number;
  60689. /** Packer Layout Constant 0 */
  60690. static readonly SUBUV_WRAP: number;
  60691. /** Packer Layout Constant 1 */
  60692. static readonly SUBUV_EXTEND: number;
  60693. /** Packer Layout Constant 2 */
  60694. static readonly SUBUV_COLOR: number;
  60695. /** The Name of the Texture Package */
  60696. name: string;
  60697. /** The scene scope of the TexturePacker */
  60698. scene: Scene;
  60699. /** The Meshes to target */
  60700. meshes: AbstractMesh[];
  60701. /** Arguments passed with the Constructor */
  60702. options: ITexturePackerOptions;
  60703. /** The promise that is started upon initialization */
  60704. promise: Nullable<Promise<TexturePacker | string>>;
  60705. /** The Container object for the channel sets that are generated */
  60706. sets: object;
  60707. /** The Container array for the frames that are generated */
  60708. frames: TexturePackerFrame[];
  60709. /** The expected number of textures the system is parsing. */
  60710. private _expecting;
  60711. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60712. private _paddingValue;
  60713. /**
  60714. * Initializes a texture package series from an array of meshes or a single mesh.
  60715. * @param name The name of the package
  60716. * @param meshes The target meshes to compose the package from
  60717. * @param options The arguments that texture packer should follow while building.
  60718. * @param scene The scene which the textures are scoped to.
  60719. * @returns TexturePacker
  60720. */
  60721. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60722. /**
  60723. * Starts the package process
  60724. * @param resolve The promises resolution function
  60725. * @returns TexturePacker
  60726. */
  60727. private _createFrames;
  60728. /**
  60729. * Calculates the Size of the Channel Sets
  60730. * @returns Vector2
  60731. */
  60732. private _calculateSize;
  60733. /**
  60734. * Calculates the UV data for the frames.
  60735. * @param baseSize the base frameSize
  60736. * @param padding the base frame padding
  60737. * @param dtSize size of the Dynamic Texture for that channel
  60738. * @param dtUnits is 1/dtSize
  60739. * @param update flag to update the input meshes
  60740. */
  60741. private _calculateMeshUVFrames;
  60742. /**
  60743. * Calculates the frames Offset.
  60744. * @param index of the frame
  60745. * @returns Vector2
  60746. */
  60747. private _getFrameOffset;
  60748. /**
  60749. * Updates a Mesh to the frame data
  60750. * @param mesh that is the target
  60751. * @param frameID or the frame index
  60752. */
  60753. private _updateMeshUV;
  60754. /**
  60755. * Updates a Meshes materials to use the texture packer channels
  60756. * @param m is the mesh to target
  60757. * @param force all channels on the packer to be set.
  60758. */
  60759. private _updateTextureReferences;
  60760. /**
  60761. * Public method to set a Mesh to a frame
  60762. * @param m that is the target
  60763. * @param frameID or the frame index
  60764. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60765. */
  60766. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60767. /**
  60768. * Starts the async promise to compile the texture packer.
  60769. * @returns Promise<void>
  60770. */
  60771. processAsync(): Promise<void>;
  60772. /**
  60773. * Disposes all textures associated with this packer
  60774. */
  60775. dispose(): void;
  60776. /**
  60777. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60778. * @param imageType is the image type to use.
  60779. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60780. */
  60781. download(imageType?: string, quality?: number): void;
  60782. /**
  60783. * Public method to load a texturePacker JSON file.
  60784. * @param data of the JSON file in string format.
  60785. */
  60786. updateFromJSON(data: string): void;
  60787. }
  60788. }
  60789. declare module BABYLON {
  60790. /**
  60791. * 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.
  60792. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60793. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60794. */
  60795. export class CustomProceduralTexture extends ProceduralTexture {
  60796. private _animate;
  60797. private _time;
  60798. private _config;
  60799. private _texturePath;
  60800. /**
  60801. * Instantiates a new Custom Procedural Texture.
  60802. * 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.
  60803. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60804. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60805. * @param name Define the name of the texture
  60806. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60807. * @param size Define the size of the texture to create
  60808. * @param scene Define the scene the texture belongs to
  60809. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60810. * @param generateMipMaps Define if the texture should creates mip maps or not
  60811. */
  60812. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60813. private _loadJson;
  60814. /**
  60815. * Is the texture ready to be used ? (rendered at least once)
  60816. * @returns true if ready, otherwise, false.
  60817. */
  60818. isReady(): boolean;
  60819. /**
  60820. * Render the texture to its associated render target.
  60821. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60822. */
  60823. render(useCameraPostProcess?: boolean): void;
  60824. /**
  60825. * Update the list of dependant textures samplers in the shader.
  60826. */
  60827. updateTextures(): void;
  60828. /**
  60829. * Update the uniform values of the procedural texture in the shader.
  60830. */
  60831. updateShaderUniforms(): void;
  60832. /**
  60833. * Define if the texture animates or not.
  60834. */
  60835. get animate(): boolean;
  60836. set animate(value: boolean);
  60837. }
  60838. }
  60839. declare module BABYLON {
  60840. /** @hidden */
  60841. export var noisePixelShader: {
  60842. name: string;
  60843. shader: string;
  60844. };
  60845. }
  60846. declare module BABYLON {
  60847. /**
  60848. * Class used to generate noise procedural textures
  60849. */
  60850. export class NoiseProceduralTexture extends ProceduralTexture {
  60851. private _time;
  60852. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60853. brightness: number;
  60854. /** Defines the number of octaves to process */
  60855. octaves: number;
  60856. /** Defines the level of persistence (0.8 by default) */
  60857. persistence: number;
  60858. /** Gets or sets animation speed factor (default is 1) */
  60859. animationSpeedFactor: number;
  60860. /**
  60861. * Creates a new NoiseProceduralTexture
  60862. * @param name defines the name fo the texture
  60863. * @param size defines the size of the texture (default is 256)
  60864. * @param scene defines the hosting scene
  60865. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60866. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60867. */
  60868. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60869. private _updateShaderUniforms;
  60870. protected _getDefines(): string;
  60871. /** Generate the current state of the procedural texture */
  60872. render(useCameraPostProcess?: boolean): void;
  60873. /**
  60874. * Serializes this noise procedural texture
  60875. * @returns a serialized noise procedural texture object
  60876. */
  60877. serialize(): any;
  60878. /**
  60879. * Clone the texture.
  60880. * @returns the cloned texture
  60881. */
  60882. clone(): NoiseProceduralTexture;
  60883. /**
  60884. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60885. * @param parsedTexture defines parsed texture data
  60886. * @param scene defines the current scene
  60887. * @param rootUrl defines the root URL containing noise procedural texture information
  60888. * @returns a parsed NoiseProceduralTexture
  60889. */
  60890. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60891. }
  60892. }
  60893. declare module BABYLON {
  60894. /**
  60895. * Raw cube texture where the raw buffers are passed in
  60896. */
  60897. export class RawCubeTexture extends CubeTexture {
  60898. /**
  60899. * Creates a cube texture where the raw buffers are passed in.
  60900. * @param scene defines the scene the texture is attached to
  60901. * @param data defines the array of data to use to create each face
  60902. * @param size defines the size of the textures
  60903. * @param format defines the format of the data
  60904. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60905. * @param generateMipMaps defines if the engine should generate the mip levels
  60906. * @param invertY defines if data must be stored with Y axis inverted
  60907. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60908. * @param compression defines the compression used (null by default)
  60909. */
  60910. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60911. /**
  60912. * Updates the raw cube texture.
  60913. * @param data defines the data to store
  60914. * @param format defines the data format
  60915. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60916. * @param invertY defines if data must be stored with Y axis inverted
  60917. * @param compression defines the compression used (null by default)
  60918. * @param level defines which level of the texture to update
  60919. */
  60920. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60921. /**
  60922. * Updates a raw cube texture with RGBD encoded data.
  60923. * @param data defines the array of data [mipmap][face] to use to create each face
  60924. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60925. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60926. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60927. * @returns a promsie that resolves when the operation is complete
  60928. */
  60929. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60930. /**
  60931. * Clones the raw cube texture.
  60932. * @return a new cube texture
  60933. */
  60934. clone(): CubeTexture;
  60935. /** @hidden */
  60936. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60937. }
  60938. }
  60939. declare module BABYLON {
  60940. /**
  60941. * Class used to store 2D array textures containing user data
  60942. */
  60943. export class RawTexture2DArray extends Texture {
  60944. /** Gets or sets the texture format to use */
  60945. format: number;
  60946. /**
  60947. * Create a new RawTexture2DArray
  60948. * @param data defines the data of the texture
  60949. * @param width defines the width of the texture
  60950. * @param height defines the height of the texture
  60951. * @param depth defines the number of layers of the texture
  60952. * @param format defines the texture format to use
  60953. * @param scene defines the hosting scene
  60954. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60955. * @param invertY defines if texture must be stored with Y axis inverted
  60956. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60957. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60958. */
  60959. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60960. /** Gets or sets the texture format to use */
  60961. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60962. /**
  60963. * Update the texture with new data
  60964. * @param data defines the data to store in the texture
  60965. */
  60966. update(data: ArrayBufferView): void;
  60967. }
  60968. }
  60969. declare module BABYLON {
  60970. /**
  60971. * Class used to store 3D textures containing user data
  60972. */
  60973. export class RawTexture3D extends Texture {
  60974. /** Gets or sets the texture format to use */
  60975. format: number;
  60976. /**
  60977. * Create a new RawTexture3D
  60978. * @param data defines the data of the texture
  60979. * @param width defines the width of the texture
  60980. * @param height defines the height of the texture
  60981. * @param depth defines the depth of the texture
  60982. * @param format defines the texture format to use
  60983. * @param scene defines the hosting scene
  60984. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60985. * @param invertY defines if texture must be stored with Y axis inverted
  60986. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60987. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60988. */
  60989. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60990. /** Gets or sets the texture format to use */
  60991. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60992. /**
  60993. * Update the texture with new data
  60994. * @param data defines the data to store in the texture
  60995. */
  60996. update(data: ArrayBufferView): void;
  60997. }
  60998. }
  60999. declare module BABYLON {
  61000. /**
  61001. * Creates a refraction texture used by refraction channel of the standard material.
  61002. * It is like a mirror but to see through a material.
  61003. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61004. */
  61005. export class RefractionTexture extends RenderTargetTexture {
  61006. /**
  61007. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61008. * 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.
  61009. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61010. */
  61011. refractionPlane: Plane;
  61012. /**
  61013. * Define how deep under the surface we should see.
  61014. */
  61015. depth: number;
  61016. /**
  61017. * Creates a refraction texture used by refraction channel of the standard material.
  61018. * It is like a mirror but to see through a material.
  61019. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61020. * @param name Define the texture name
  61021. * @param size Define the size of the underlying texture
  61022. * @param scene Define the scene the refraction belongs to
  61023. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61024. */
  61025. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61026. /**
  61027. * Clone the refraction texture.
  61028. * @returns the cloned texture
  61029. */
  61030. clone(): RefractionTexture;
  61031. /**
  61032. * Serialize the texture to a JSON representation you could use in Parse later on
  61033. * @returns the serialized JSON representation
  61034. */
  61035. serialize(): any;
  61036. }
  61037. }
  61038. declare module BABYLON {
  61039. /**
  61040. * Block used to add support for vertex skinning (bones)
  61041. */
  61042. export class BonesBlock extends NodeMaterialBlock {
  61043. /**
  61044. * Creates a new BonesBlock
  61045. * @param name defines the block name
  61046. */
  61047. constructor(name: string);
  61048. /**
  61049. * Initialize the block and prepare the context for build
  61050. * @param state defines the state that will be used for the build
  61051. */
  61052. initialize(state: NodeMaterialBuildState): void;
  61053. /**
  61054. * Gets the current class name
  61055. * @returns the class name
  61056. */
  61057. getClassName(): string;
  61058. /**
  61059. * Gets the matrix indices input component
  61060. */
  61061. get matricesIndices(): NodeMaterialConnectionPoint;
  61062. /**
  61063. * Gets the matrix weights input component
  61064. */
  61065. get matricesWeights(): NodeMaterialConnectionPoint;
  61066. /**
  61067. * Gets the extra matrix indices input component
  61068. */
  61069. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61070. /**
  61071. * Gets the extra matrix weights input component
  61072. */
  61073. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61074. /**
  61075. * Gets the world input component
  61076. */
  61077. get world(): NodeMaterialConnectionPoint;
  61078. /**
  61079. * Gets the output component
  61080. */
  61081. get output(): NodeMaterialConnectionPoint;
  61082. autoConfigure(material: NodeMaterial): void;
  61083. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61084. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61086. protected _buildBlock(state: NodeMaterialBuildState): this;
  61087. }
  61088. }
  61089. declare module BABYLON {
  61090. /**
  61091. * Block used to add support for instances
  61092. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61093. */
  61094. export class InstancesBlock extends NodeMaterialBlock {
  61095. /**
  61096. * Creates a new InstancesBlock
  61097. * @param name defines the block name
  61098. */
  61099. constructor(name: string);
  61100. /**
  61101. * Gets the current class name
  61102. * @returns the class name
  61103. */
  61104. getClassName(): string;
  61105. /**
  61106. * Gets the first world row input component
  61107. */
  61108. get world0(): NodeMaterialConnectionPoint;
  61109. /**
  61110. * Gets the second world row input component
  61111. */
  61112. get world1(): NodeMaterialConnectionPoint;
  61113. /**
  61114. * Gets the third world row input component
  61115. */
  61116. get world2(): NodeMaterialConnectionPoint;
  61117. /**
  61118. * Gets the forth world row input component
  61119. */
  61120. get world3(): NodeMaterialConnectionPoint;
  61121. /**
  61122. * Gets the world input component
  61123. */
  61124. get world(): NodeMaterialConnectionPoint;
  61125. /**
  61126. * Gets the output component
  61127. */
  61128. get output(): NodeMaterialConnectionPoint;
  61129. /**
  61130. * Gets the isntanceID component
  61131. */
  61132. get instanceID(): NodeMaterialConnectionPoint;
  61133. autoConfigure(material: NodeMaterial): void;
  61134. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61135. protected _buildBlock(state: NodeMaterialBuildState): this;
  61136. }
  61137. }
  61138. declare module BABYLON {
  61139. /**
  61140. * Block used to add morph targets support to vertex shader
  61141. */
  61142. export class MorphTargetsBlock extends NodeMaterialBlock {
  61143. private _repeatableContentAnchor;
  61144. /**
  61145. * Create a new MorphTargetsBlock
  61146. * @param name defines the block name
  61147. */
  61148. constructor(name: string);
  61149. /**
  61150. * Gets the current class name
  61151. * @returns the class name
  61152. */
  61153. getClassName(): string;
  61154. /**
  61155. * Gets the position input component
  61156. */
  61157. get position(): NodeMaterialConnectionPoint;
  61158. /**
  61159. * Gets the normal input component
  61160. */
  61161. get normal(): NodeMaterialConnectionPoint;
  61162. /**
  61163. * Gets the tangent input component
  61164. */
  61165. get tangent(): NodeMaterialConnectionPoint;
  61166. /**
  61167. * Gets the tangent input component
  61168. */
  61169. get uv(): NodeMaterialConnectionPoint;
  61170. /**
  61171. * Gets the position output component
  61172. */
  61173. get positionOutput(): NodeMaterialConnectionPoint;
  61174. /**
  61175. * Gets the normal output component
  61176. */
  61177. get normalOutput(): NodeMaterialConnectionPoint;
  61178. /**
  61179. * Gets the tangent output component
  61180. */
  61181. get tangentOutput(): NodeMaterialConnectionPoint;
  61182. /**
  61183. * Gets the tangent output component
  61184. */
  61185. get uvOutput(): NodeMaterialConnectionPoint;
  61186. initialize(state: NodeMaterialBuildState): void;
  61187. autoConfigure(material: NodeMaterial): void;
  61188. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61189. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61190. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61191. protected _buildBlock(state: NodeMaterialBuildState): this;
  61192. }
  61193. }
  61194. declare module BABYLON {
  61195. /**
  61196. * Block used to get data information from a light
  61197. */
  61198. export class LightInformationBlock extends NodeMaterialBlock {
  61199. private _lightDataUniformName;
  61200. private _lightColorUniformName;
  61201. private _lightTypeDefineName;
  61202. /**
  61203. * Gets or sets the light associated with this block
  61204. */
  61205. light: Nullable<Light>;
  61206. /**
  61207. * Creates a new LightInformationBlock
  61208. * @param name defines the block name
  61209. */
  61210. constructor(name: string);
  61211. /**
  61212. * Gets the current class name
  61213. * @returns the class name
  61214. */
  61215. getClassName(): string;
  61216. /**
  61217. * Gets the world position input component
  61218. */
  61219. get worldPosition(): NodeMaterialConnectionPoint;
  61220. /**
  61221. * Gets the direction output component
  61222. */
  61223. get direction(): NodeMaterialConnectionPoint;
  61224. /**
  61225. * Gets the direction output component
  61226. */
  61227. get color(): NodeMaterialConnectionPoint;
  61228. /**
  61229. * Gets the direction output component
  61230. */
  61231. get intensity(): NodeMaterialConnectionPoint;
  61232. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61233. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61234. protected _buildBlock(state: NodeMaterialBuildState): this;
  61235. serialize(): any;
  61236. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61237. }
  61238. }
  61239. declare module BABYLON {
  61240. /**
  61241. * Block used to add image processing support to fragment shader
  61242. */
  61243. export class ImageProcessingBlock extends NodeMaterialBlock {
  61244. /**
  61245. * Create a new ImageProcessingBlock
  61246. * @param name defines the block name
  61247. */
  61248. constructor(name: string);
  61249. /**
  61250. * Gets the current class name
  61251. * @returns the class name
  61252. */
  61253. getClassName(): string;
  61254. /**
  61255. * Gets the color input component
  61256. */
  61257. get color(): NodeMaterialConnectionPoint;
  61258. /**
  61259. * Gets the output component
  61260. */
  61261. get output(): NodeMaterialConnectionPoint;
  61262. /**
  61263. * Initialize the block and prepare the context for build
  61264. * @param state defines the state that will be used for the build
  61265. */
  61266. initialize(state: NodeMaterialBuildState): void;
  61267. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61268. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61269. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61270. protected _buildBlock(state: NodeMaterialBuildState): this;
  61271. }
  61272. }
  61273. declare module BABYLON {
  61274. /**
  61275. * Block used to pertub normals based on a normal map
  61276. */
  61277. export class PerturbNormalBlock extends NodeMaterialBlock {
  61278. private _tangentSpaceParameterName;
  61279. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61280. invertX: boolean;
  61281. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61282. invertY: boolean;
  61283. /**
  61284. * Create a new PerturbNormalBlock
  61285. * @param name defines the block name
  61286. */
  61287. constructor(name: string);
  61288. /**
  61289. * Gets the current class name
  61290. * @returns the class name
  61291. */
  61292. getClassName(): string;
  61293. /**
  61294. * Gets the world position input component
  61295. */
  61296. get worldPosition(): NodeMaterialConnectionPoint;
  61297. /**
  61298. * Gets the world normal input component
  61299. */
  61300. get worldNormal(): NodeMaterialConnectionPoint;
  61301. /**
  61302. * Gets the world tangent input component
  61303. */
  61304. get worldTangent(): NodeMaterialConnectionPoint;
  61305. /**
  61306. * Gets the uv input component
  61307. */
  61308. get uv(): NodeMaterialConnectionPoint;
  61309. /**
  61310. * Gets the normal map color input component
  61311. */
  61312. get normalMapColor(): NodeMaterialConnectionPoint;
  61313. /**
  61314. * Gets the strength input component
  61315. */
  61316. get strength(): NodeMaterialConnectionPoint;
  61317. /**
  61318. * Gets the output component
  61319. */
  61320. get output(): NodeMaterialConnectionPoint;
  61321. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61322. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61323. autoConfigure(material: NodeMaterial): void;
  61324. protected _buildBlock(state: NodeMaterialBuildState): this;
  61325. protected _dumpPropertiesCode(): string;
  61326. serialize(): any;
  61327. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61328. }
  61329. }
  61330. declare module BABYLON {
  61331. /**
  61332. * Block used to discard a pixel if a value is smaller than a cutoff
  61333. */
  61334. export class DiscardBlock extends NodeMaterialBlock {
  61335. /**
  61336. * Create a new DiscardBlock
  61337. * @param name defines the block name
  61338. */
  61339. constructor(name: string);
  61340. /**
  61341. * Gets the current class name
  61342. * @returns the class name
  61343. */
  61344. getClassName(): string;
  61345. /**
  61346. * Gets the color input component
  61347. */
  61348. get value(): NodeMaterialConnectionPoint;
  61349. /**
  61350. * Gets the cutoff input component
  61351. */
  61352. get cutoff(): NodeMaterialConnectionPoint;
  61353. protected _buildBlock(state: NodeMaterialBuildState): this;
  61354. }
  61355. }
  61356. declare module BABYLON {
  61357. /**
  61358. * Block used to test if the fragment shader is front facing
  61359. */
  61360. export class FrontFacingBlock extends NodeMaterialBlock {
  61361. /**
  61362. * Creates a new FrontFacingBlock
  61363. * @param name defines the block name
  61364. */
  61365. constructor(name: string);
  61366. /**
  61367. * Gets the current class name
  61368. * @returns the class name
  61369. */
  61370. getClassName(): string;
  61371. /**
  61372. * Gets the output component
  61373. */
  61374. get output(): NodeMaterialConnectionPoint;
  61375. protected _buildBlock(state: NodeMaterialBuildState): this;
  61376. }
  61377. }
  61378. declare module BABYLON {
  61379. /**
  61380. * Block used to get the derivative value on x and y of a given input
  61381. */
  61382. export class DerivativeBlock extends NodeMaterialBlock {
  61383. /**
  61384. * Create a new DerivativeBlock
  61385. * @param name defines the block name
  61386. */
  61387. constructor(name: string);
  61388. /**
  61389. * Gets the current class name
  61390. * @returns the class name
  61391. */
  61392. getClassName(): string;
  61393. /**
  61394. * Gets the input component
  61395. */
  61396. get input(): NodeMaterialConnectionPoint;
  61397. /**
  61398. * Gets the derivative output on x
  61399. */
  61400. get dx(): NodeMaterialConnectionPoint;
  61401. /**
  61402. * Gets the derivative output on y
  61403. */
  61404. get dy(): NodeMaterialConnectionPoint;
  61405. protected _buildBlock(state: NodeMaterialBuildState): this;
  61406. }
  61407. }
  61408. declare module BABYLON {
  61409. /**
  61410. * Block used to make gl_FragCoord available
  61411. */
  61412. export class FragCoordBlock extends NodeMaterialBlock {
  61413. /**
  61414. * Creates a new FragCoordBlock
  61415. * @param name defines the block name
  61416. */
  61417. constructor(name: string);
  61418. /**
  61419. * Gets the current class name
  61420. * @returns the class name
  61421. */
  61422. getClassName(): string;
  61423. /**
  61424. * Gets the xy component
  61425. */
  61426. get xy(): NodeMaterialConnectionPoint;
  61427. /**
  61428. * Gets the xyz component
  61429. */
  61430. get xyz(): NodeMaterialConnectionPoint;
  61431. /**
  61432. * Gets the xyzw component
  61433. */
  61434. get xyzw(): NodeMaterialConnectionPoint;
  61435. /**
  61436. * Gets the x component
  61437. */
  61438. get x(): NodeMaterialConnectionPoint;
  61439. /**
  61440. * Gets the y component
  61441. */
  61442. get y(): NodeMaterialConnectionPoint;
  61443. /**
  61444. * Gets the z component
  61445. */
  61446. get z(): NodeMaterialConnectionPoint;
  61447. /**
  61448. * Gets the w component
  61449. */
  61450. get output(): NodeMaterialConnectionPoint;
  61451. protected writeOutputs(state: NodeMaterialBuildState): string;
  61452. protected _buildBlock(state: NodeMaterialBuildState): this;
  61453. }
  61454. }
  61455. declare module BABYLON {
  61456. /**
  61457. * Block used to get the screen sizes
  61458. */
  61459. export class ScreenSizeBlock extends NodeMaterialBlock {
  61460. private _varName;
  61461. private _scene;
  61462. /**
  61463. * Creates a new ScreenSizeBlock
  61464. * @param name defines the block name
  61465. */
  61466. constructor(name: string);
  61467. /**
  61468. * Gets the current class name
  61469. * @returns the class name
  61470. */
  61471. getClassName(): string;
  61472. /**
  61473. * Gets the xy component
  61474. */
  61475. get xy(): NodeMaterialConnectionPoint;
  61476. /**
  61477. * Gets the x component
  61478. */
  61479. get x(): NodeMaterialConnectionPoint;
  61480. /**
  61481. * Gets the y component
  61482. */
  61483. get y(): NodeMaterialConnectionPoint;
  61484. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61485. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61486. protected _buildBlock(state: NodeMaterialBuildState): this;
  61487. }
  61488. }
  61489. declare module BABYLON {
  61490. /**
  61491. * Block used to add support for scene fog
  61492. */
  61493. export class FogBlock extends NodeMaterialBlock {
  61494. private _fogDistanceName;
  61495. private _fogParameters;
  61496. /**
  61497. * Create a new FogBlock
  61498. * @param name defines the block name
  61499. */
  61500. constructor(name: string);
  61501. /**
  61502. * Gets the current class name
  61503. * @returns the class name
  61504. */
  61505. getClassName(): string;
  61506. /**
  61507. * Gets the world position input component
  61508. */
  61509. get worldPosition(): NodeMaterialConnectionPoint;
  61510. /**
  61511. * Gets the view input component
  61512. */
  61513. get view(): NodeMaterialConnectionPoint;
  61514. /**
  61515. * Gets the color input component
  61516. */
  61517. get input(): NodeMaterialConnectionPoint;
  61518. /**
  61519. * Gets the fog color input component
  61520. */
  61521. get fogColor(): NodeMaterialConnectionPoint;
  61522. /**
  61523. * Gets the output component
  61524. */
  61525. get output(): NodeMaterialConnectionPoint;
  61526. autoConfigure(material: NodeMaterial): void;
  61527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61528. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61529. protected _buildBlock(state: NodeMaterialBuildState): this;
  61530. }
  61531. }
  61532. declare module BABYLON {
  61533. /**
  61534. * Block used to add light in the fragment shader
  61535. */
  61536. export class LightBlock extends NodeMaterialBlock {
  61537. private _lightId;
  61538. /**
  61539. * Gets or sets the light associated with this block
  61540. */
  61541. light: Nullable<Light>;
  61542. /**
  61543. * Create a new LightBlock
  61544. * @param name defines the block name
  61545. */
  61546. constructor(name: string);
  61547. /**
  61548. * Gets the current class name
  61549. * @returns the class name
  61550. */
  61551. getClassName(): string;
  61552. /**
  61553. * Gets the world position input component
  61554. */
  61555. get worldPosition(): NodeMaterialConnectionPoint;
  61556. /**
  61557. * Gets the world normal input component
  61558. */
  61559. get worldNormal(): NodeMaterialConnectionPoint;
  61560. /**
  61561. * Gets the camera (or eye) position component
  61562. */
  61563. get cameraPosition(): NodeMaterialConnectionPoint;
  61564. /**
  61565. * Gets the glossiness component
  61566. */
  61567. get glossiness(): NodeMaterialConnectionPoint;
  61568. /**
  61569. * Gets the glossinness power component
  61570. */
  61571. get glossPower(): NodeMaterialConnectionPoint;
  61572. /**
  61573. * Gets the diffuse color component
  61574. */
  61575. get diffuseColor(): NodeMaterialConnectionPoint;
  61576. /**
  61577. * Gets the specular color component
  61578. */
  61579. get specularColor(): NodeMaterialConnectionPoint;
  61580. /**
  61581. * Gets the diffuse output component
  61582. */
  61583. get diffuseOutput(): NodeMaterialConnectionPoint;
  61584. /**
  61585. * Gets the specular output component
  61586. */
  61587. get specularOutput(): NodeMaterialConnectionPoint;
  61588. /**
  61589. * Gets the shadow output component
  61590. */
  61591. get shadow(): NodeMaterialConnectionPoint;
  61592. autoConfigure(material: NodeMaterial): void;
  61593. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61594. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61595. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61596. private _injectVertexCode;
  61597. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61598. serialize(): any;
  61599. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61600. }
  61601. }
  61602. declare module BABYLON {
  61603. /**
  61604. * Block used to read a reflection texture from a sampler
  61605. */
  61606. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61607. /**
  61608. * Create a new ReflectionTextureBlock
  61609. * @param name defines the block name
  61610. */
  61611. constructor(name: string);
  61612. /**
  61613. * Gets the current class name
  61614. * @returns the class name
  61615. */
  61616. getClassName(): string;
  61617. /**
  61618. * Gets the world position input component
  61619. */
  61620. get position(): NodeMaterialConnectionPoint;
  61621. /**
  61622. * Gets the world position input component
  61623. */
  61624. get worldPosition(): NodeMaterialConnectionPoint;
  61625. /**
  61626. * Gets the world normal input component
  61627. */
  61628. get worldNormal(): NodeMaterialConnectionPoint;
  61629. /**
  61630. * Gets the world input component
  61631. */
  61632. get world(): NodeMaterialConnectionPoint;
  61633. /**
  61634. * Gets the camera (or eye) position component
  61635. */
  61636. get cameraPosition(): NodeMaterialConnectionPoint;
  61637. /**
  61638. * Gets the view input component
  61639. */
  61640. get view(): NodeMaterialConnectionPoint;
  61641. /**
  61642. * Gets the rgb output component
  61643. */
  61644. get rgb(): NodeMaterialConnectionPoint;
  61645. /**
  61646. * Gets the r output component
  61647. */
  61648. get r(): NodeMaterialConnectionPoint;
  61649. /**
  61650. * Gets the g output component
  61651. */
  61652. get g(): NodeMaterialConnectionPoint;
  61653. /**
  61654. * Gets the b output component
  61655. */
  61656. get b(): NodeMaterialConnectionPoint;
  61657. autoConfigure(material: NodeMaterial): void;
  61658. protected _buildBlock(state: NodeMaterialBuildState): this;
  61659. }
  61660. }
  61661. declare module BABYLON {
  61662. /**
  61663. * Block used to add 2 vectors
  61664. */
  61665. export class AddBlock extends NodeMaterialBlock {
  61666. /**
  61667. * Creates a new AddBlock
  61668. * @param name defines the block name
  61669. */
  61670. constructor(name: string);
  61671. /**
  61672. * Gets the current class name
  61673. * @returns the class name
  61674. */
  61675. getClassName(): string;
  61676. /**
  61677. * Gets the left operand input component
  61678. */
  61679. get left(): NodeMaterialConnectionPoint;
  61680. /**
  61681. * Gets the right operand input component
  61682. */
  61683. get right(): NodeMaterialConnectionPoint;
  61684. /**
  61685. * Gets the output component
  61686. */
  61687. get output(): NodeMaterialConnectionPoint;
  61688. protected _buildBlock(state: NodeMaterialBuildState): this;
  61689. }
  61690. }
  61691. declare module BABYLON {
  61692. /**
  61693. * Block used to scale a vector by a float
  61694. */
  61695. export class ScaleBlock extends NodeMaterialBlock {
  61696. /**
  61697. * Creates a new ScaleBlock
  61698. * @param name defines the block name
  61699. */
  61700. constructor(name: string);
  61701. /**
  61702. * Gets the current class name
  61703. * @returns the class name
  61704. */
  61705. getClassName(): string;
  61706. /**
  61707. * Gets the input component
  61708. */
  61709. get input(): NodeMaterialConnectionPoint;
  61710. /**
  61711. * Gets the factor input component
  61712. */
  61713. get factor(): NodeMaterialConnectionPoint;
  61714. /**
  61715. * Gets the output component
  61716. */
  61717. get output(): NodeMaterialConnectionPoint;
  61718. protected _buildBlock(state: NodeMaterialBuildState): this;
  61719. }
  61720. }
  61721. declare module BABYLON {
  61722. /**
  61723. * Block used to clamp a float
  61724. */
  61725. export class ClampBlock extends NodeMaterialBlock {
  61726. /** Gets or sets the minimum range */
  61727. minimum: number;
  61728. /** Gets or sets the maximum range */
  61729. maximum: number;
  61730. /**
  61731. * Creates a new ClampBlock
  61732. * @param name defines the block name
  61733. */
  61734. constructor(name: string);
  61735. /**
  61736. * Gets the current class name
  61737. * @returns the class name
  61738. */
  61739. getClassName(): string;
  61740. /**
  61741. * Gets the value input component
  61742. */
  61743. get value(): NodeMaterialConnectionPoint;
  61744. /**
  61745. * Gets the output component
  61746. */
  61747. get output(): NodeMaterialConnectionPoint;
  61748. protected _buildBlock(state: NodeMaterialBuildState): this;
  61749. protected _dumpPropertiesCode(): string;
  61750. serialize(): any;
  61751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61752. }
  61753. }
  61754. declare module BABYLON {
  61755. /**
  61756. * Block used to apply a cross product between 2 vectors
  61757. */
  61758. export class CrossBlock extends NodeMaterialBlock {
  61759. /**
  61760. * Creates a new CrossBlock
  61761. * @param name defines the block name
  61762. */
  61763. constructor(name: string);
  61764. /**
  61765. * Gets the current class name
  61766. * @returns the class name
  61767. */
  61768. getClassName(): string;
  61769. /**
  61770. * Gets the left operand input component
  61771. */
  61772. get left(): NodeMaterialConnectionPoint;
  61773. /**
  61774. * Gets the right operand input component
  61775. */
  61776. get right(): NodeMaterialConnectionPoint;
  61777. /**
  61778. * Gets the output component
  61779. */
  61780. get output(): NodeMaterialConnectionPoint;
  61781. protected _buildBlock(state: NodeMaterialBuildState): this;
  61782. }
  61783. }
  61784. declare module BABYLON {
  61785. /**
  61786. * Block used to apply a dot product between 2 vectors
  61787. */
  61788. export class DotBlock extends NodeMaterialBlock {
  61789. /**
  61790. * Creates a new DotBlock
  61791. * @param name defines the block name
  61792. */
  61793. constructor(name: string);
  61794. /**
  61795. * Gets the current class name
  61796. * @returns the class name
  61797. */
  61798. getClassName(): string;
  61799. /**
  61800. * Gets the left operand input component
  61801. */
  61802. get left(): NodeMaterialConnectionPoint;
  61803. /**
  61804. * Gets the right operand input component
  61805. */
  61806. get right(): NodeMaterialConnectionPoint;
  61807. /**
  61808. * Gets the output component
  61809. */
  61810. get output(): NodeMaterialConnectionPoint;
  61811. protected _buildBlock(state: NodeMaterialBuildState): this;
  61812. }
  61813. }
  61814. declare module BABYLON {
  61815. /**
  61816. * Block used to normalize a vector
  61817. */
  61818. export class NormalizeBlock extends NodeMaterialBlock {
  61819. /**
  61820. * Creates a new NormalizeBlock
  61821. * @param name defines the block name
  61822. */
  61823. constructor(name: string);
  61824. /**
  61825. * Gets the current class name
  61826. * @returns the class name
  61827. */
  61828. getClassName(): string;
  61829. /**
  61830. * Gets the input component
  61831. */
  61832. get input(): NodeMaterialConnectionPoint;
  61833. /**
  61834. * Gets the output component
  61835. */
  61836. get output(): NodeMaterialConnectionPoint;
  61837. protected _buildBlock(state: NodeMaterialBuildState): this;
  61838. }
  61839. }
  61840. declare module BABYLON {
  61841. /**
  61842. * Operations supported by the Trigonometry block
  61843. */
  61844. export enum TrigonometryBlockOperations {
  61845. /** Cos */
  61846. Cos = 0,
  61847. /** Sin */
  61848. Sin = 1,
  61849. /** Abs */
  61850. Abs = 2,
  61851. /** Exp */
  61852. Exp = 3,
  61853. /** Exp2 */
  61854. Exp2 = 4,
  61855. /** Round */
  61856. Round = 5,
  61857. /** Floor */
  61858. Floor = 6,
  61859. /** Ceiling */
  61860. Ceiling = 7,
  61861. /** Square root */
  61862. Sqrt = 8,
  61863. /** Log */
  61864. Log = 9,
  61865. /** Tangent */
  61866. Tan = 10,
  61867. /** Arc tangent */
  61868. ArcTan = 11,
  61869. /** Arc cosinus */
  61870. ArcCos = 12,
  61871. /** Arc sinus */
  61872. ArcSin = 13,
  61873. /** Fraction */
  61874. Fract = 14,
  61875. /** Sign */
  61876. Sign = 15,
  61877. /** To radians (from degrees) */
  61878. Radians = 16,
  61879. /** To degrees (from radians) */
  61880. Degrees = 17
  61881. }
  61882. /**
  61883. * Block used to apply trigonometry operation to floats
  61884. */
  61885. export class TrigonometryBlock extends NodeMaterialBlock {
  61886. /**
  61887. * Gets or sets the operation applied by the block
  61888. */
  61889. operation: TrigonometryBlockOperations;
  61890. /**
  61891. * Creates a new TrigonometryBlock
  61892. * @param name defines the block name
  61893. */
  61894. constructor(name: string);
  61895. /**
  61896. * Gets the current class name
  61897. * @returns the class name
  61898. */
  61899. getClassName(): string;
  61900. /**
  61901. * Gets the input component
  61902. */
  61903. get input(): NodeMaterialConnectionPoint;
  61904. /**
  61905. * Gets the output component
  61906. */
  61907. get output(): NodeMaterialConnectionPoint;
  61908. protected _buildBlock(state: NodeMaterialBuildState): this;
  61909. serialize(): any;
  61910. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61911. protected _dumpPropertiesCode(): string;
  61912. }
  61913. }
  61914. declare module BABYLON {
  61915. /**
  61916. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61917. */
  61918. export class ColorMergerBlock extends NodeMaterialBlock {
  61919. /**
  61920. * Create a new ColorMergerBlock
  61921. * @param name defines the block name
  61922. */
  61923. constructor(name: string);
  61924. /**
  61925. * Gets the current class name
  61926. * @returns the class name
  61927. */
  61928. getClassName(): string;
  61929. /**
  61930. * Gets the rgb component (input)
  61931. */
  61932. get rgbIn(): NodeMaterialConnectionPoint;
  61933. /**
  61934. * Gets the r component (input)
  61935. */
  61936. get r(): NodeMaterialConnectionPoint;
  61937. /**
  61938. * Gets the g component (input)
  61939. */
  61940. get g(): NodeMaterialConnectionPoint;
  61941. /**
  61942. * Gets the b component (input)
  61943. */
  61944. get b(): NodeMaterialConnectionPoint;
  61945. /**
  61946. * Gets the a component (input)
  61947. */
  61948. get a(): NodeMaterialConnectionPoint;
  61949. /**
  61950. * Gets the rgba component (output)
  61951. */
  61952. get rgba(): NodeMaterialConnectionPoint;
  61953. /**
  61954. * Gets the rgb component (output)
  61955. */
  61956. get rgbOut(): NodeMaterialConnectionPoint;
  61957. /**
  61958. * Gets the rgb component (output)
  61959. * @deprecated Please use rgbOut instead.
  61960. */
  61961. get rgb(): NodeMaterialConnectionPoint;
  61962. protected _buildBlock(state: NodeMaterialBuildState): this;
  61963. }
  61964. }
  61965. declare module BABYLON {
  61966. /**
  61967. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61968. */
  61969. export class VectorSplitterBlock extends NodeMaterialBlock {
  61970. /**
  61971. * Create a new VectorSplitterBlock
  61972. * @param name defines the block name
  61973. */
  61974. constructor(name: string);
  61975. /**
  61976. * Gets the current class name
  61977. * @returns the class name
  61978. */
  61979. getClassName(): string;
  61980. /**
  61981. * Gets the xyzw component (input)
  61982. */
  61983. get xyzw(): NodeMaterialConnectionPoint;
  61984. /**
  61985. * Gets the xyz component (input)
  61986. */
  61987. get xyzIn(): NodeMaterialConnectionPoint;
  61988. /**
  61989. * Gets the xy component (input)
  61990. */
  61991. get xyIn(): NodeMaterialConnectionPoint;
  61992. /**
  61993. * Gets the xyz component (output)
  61994. */
  61995. get xyzOut(): NodeMaterialConnectionPoint;
  61996. /**
  61997. * Gets the xy component (output)
  61998. */
  61999. get xyOut(): NodeMaterialConnectionPoint;
  62000. /**
  62001. * Gets the x component (output)
  62002. */
  62003. get x(): NodeMaterialConnectionPoint;
  62004. /**
  62005. * Gets the y component (output)
  62006. */
  62007. get y(): NodeMaterialConnectionPoint;
  62008. /**
  62009. * Gets the z component (output)
  62010. */
  62011. get z(): NodeMaterialConnectionPoint;
  62012. /**
  62013. * Gets the w component (output)
  62014. */
  62015. get w(): NodeMaterialConnectionPoint;
  62016. protected _inputRename(name: string): string;
  62017. protected _outputRename(name: string): string;
  62018. protected _buildBlock(state: NodeMaterialBuildState): this;
  62019. }
  62020. }
  62021. declare module BABYLON {
  62022. /**
  62023. * Block used to lerp between 2 values
  62024. */
  62025. export class LerpBlock extends NodeMaterialBlock {
  62026. /**
  62027. * Creates a new LerpBlock
  62028. * @param name defines the block name
  62029. */
  62030. constructor(name: string);
  62031. /**
  62032. * Gets the current class name
  62033. * @returns the class name
  62034. */
  62035. getClassName(): string;
  62036. /**
  62037. * Gets the left operand input component
  62038. */
  62039. get left(): NodeMaterialConnectionPoint;
  62040. /**
  62041. * Gets the right operand input component
  62042. */
  62043. get right(): NodeMaterialConnectionPoint;
  62044. /**
  62045. * Gets the gradient operand input component
  62046. */
  62047. get gradient(): NodeMaterialConnectionPoint;
  62048. /**
  62049. * Gets the output component
  62050. */
  62051. get output(): NodeMaterialConnectionPoint;
  62052. protected _buildBlock(state: NodeMaterialBuildState): this;
  62053. }
  62054. }
  62055. declare module BABYLON {
  62056. /**
  62057. * Block used to divide 2 vectors
  62058. */
  62059. export class DivideBlock extends NodeMaterialBlock {
  62060. /**
  62061. * Creates a new DivideBlock
  62062. * @param name defines the block name
  62063. */
  62064. constructor(name: string);
  62065. /**
  62066. * Gets the current class name
  62067. * @returns the class name
  62068. */
  62069. getClassName(): string;
  62070. /**
  62071. * Gets the left operand input component
  62072. */
  62073. get left(): NodeMaterialConnectionPoint;
  62074. /**
  62075. * Gets the right operand input component
  62076. */
  62077. get right(): NodeMaterialConnectionPoint;
  62078. /**
  62079. * Gets the output component
  62080. */
  62081. get output(): NodeMaterialConnectionPoint;
  62082. protected _buildBlock(state: NodeMaterialBuildState): this;
  62083. }
  62084. }
  62085. declare module BABYLON {
  62086. /**
  62087. * Block used to subtract 2 vectors
  62088. */
  62089. export class SubtractBlock extends NodeMaterialBlock {
  62090. /**
  62091. * Creates a new SubtractBlock
  62092. * @param name defines the block name
  62093. */
  62094. constructor(name: string);
  62095. /**
  62096. * Gets the current class name
  62097. * @returns the class name
  62098. */
  62099. getClassName(): string;
  62100. /**
  62101. * Gets the left operand input component
  62102. */
  62103. get left(): NodeMaterialConnectionPoint;
  62104. /**
  62105. * Gets the right operand input component
  62106. */
  62107. get right(): NodeMaterialConnectionPoint;
  62108. /**
  62109. * Gets the output component
  62110. */
  62111. get output(): NodeMaterialConnectionPoint;
  62112. protected _buildBlock(state: NodeMaterialBuildState): this;
  62113. }
  62114. }
  62115. declare module BABYLON {
  62116. /**
  62117. * Block used to step a value
  62118. */
  62119. export class StepBlock extends NodeMaterialBlock {
  62120. /**
  62121. * Creates a new StepBlock
  62122. * @param name defines the block name
  62123. */
  62124. constructor(name: string);
  62125. /**
  62126. * Gets the current class name
  62127. * @returns the class name
  62128. */
  62129. getClassName(): string;
  62130. /**
  62131. * Gets the value operand input component
  62132. */
  62133. get value(): NodeMaterialConnectionPoint;
  62134. /**
  62135. * Gets the edge operand input component
  62136. */
  62137. get edge(): NodeMaterialConnectionPoint;
  62138. /**
  62139. * Gets the output component
  62140. */
  62141. get output(): NodeMaterialConnectionPoint;
  62142. protected _buildBlock(state: NodeMaterialBuildState): this;
  62143. }
  62144. }
  62145. declare module BABYLON {
  62146. /**
  62147. * Block used to get the opposite (1 - x) of a value
  62148. */
  62149. export class OneMinusBlock extends NodeMaterialBlock {
  62150. /**
  62151. * Creates a new OneMinusBlock
  62152. * @param name defines the block name
  62153. */
  62154. constructor(name: string);
  62155. /**
  62156. * Gets the current class name
  62157. * @returns the class name
  62158. */
  62159. getClassName(): string;
  62160. /**
  62161. * Gets the input component
  62162. */
  62163. get input(): NodeMaterialConnectionPoint;
  62164. /**
  62165. * Gets the output component
  62166. */
  62167. get output(): NodeMaterialConnectionPoint;
  62168. protected _buildBlock(state: NodeMaterialBuildState): this;
  62169. }
  62170. }
  62171. declare module BABYLON {
  62172. /**
  62173. * Block used to get the view direction
  62174. */
  62175. export class ViewDirectionBlock extends NodeMaterialBlock {
  62176. /**
  62177. * Creates a new ViewDirectionBlock
  62178. * @param name defines the block name
  62179. */
  62180. constructor(name: string);
  62181. /**
  62182. * Gets the current class name
  62183. * @returns the class name
  62184. */
  62185. getClassName(): string;
  62186. /**
  62187. * Gets the world position component
  62188. */
  62189. get worldPosition(): NodeMaterialConnectionPoint;
  62190. /**
  62191. * Gets the camera position component
  62192. */
  62193. get cameraPosition(): NodeMaterialConnectionPoint;
  62194. /**
  62195. * Gets the output component
  62196. */
  62197. get output(): NodeMaterialConnectionPoint;
  62198. autoConfigure(material: NodeMaterial): void;
  62199. protected _buildBlock(state: NodeMaterialBuildState): this;
  62200. }
  62201. }
  62202. declare module BABYLON {
  62203. /**
  62204. * Block used to compute fresnel value
  62205. */
  62206. export class FresnelBlock extends NodeMaterialBlock {
  62207. /**
  62208. * Create a new FresnelBlock
  62209. * @param name defines the block name
  62210. */
  62211. constructor(name: string);
  62212. /**
  62213. * Gets the current class name
  62214. * @returns the class name
  62215. */
  62216. getClassName(): string;
  62217. /**
  62218. * Gets the world normal input component
  62219. */
  62220. get worldNormal(): NodeMaterialConnectionPoint;
  62221. /**
  62222. * Gets the view direction input component
  62223. */
  62224. get viewDirection(): NodeMaterialConnectionPoint;
  62225. /**
  62226. * Gets the bias input component
  62227. */
  62228. get bias(): NodeMaterialConnectionPoint;
  62229. /**
  62230. * Gets the camera (or eye) position component
  62231. */
  62232. get power(): NodeMaterialConnectionPoint;
  62233. /**
  62234. * Gets the fresnel output component
  62235. */
  62236. get fresnel(): NodeMaterialConnectionPoint;
  62237. autoConfigure(material: NodeMaterial): void;
  62238. protected _buildBlock(state: NodeMaterialBuildState): this;
  62239. }
  62240. }
  62241. declare module BABYLON {
  62242. /**
  62243. * Block used to get the max of 2 values
  62244. */
  62245. export class MaxBlock extends NodeMaterialBlock {
  62246. /**
  62247. * Creates a new MaxBlock
  62248. * @param name defines the block name
  62249. */
  62250. constructor(name: string);
  62251. /**
  62252. * Gets the current class name
  62253. * @returns the class name
  62254. */
  62255. getClassName(): string;
  62256. /**
  62257. * Gets the left operand input component
  62258. */
  62259. get left(): NodeMaterialConnectionPoint;
  62260. /**
  62261. * Gets the right operand input component
  62262. */
  62263. get right(): NodeMaterialConnectionPoint;
  62264. /**
  62265. * Gets the output component
  62266. */
  62267. get output(): NodeMaterialConnectionPoint;
  62268. protected _buildBlock(state: NodeMaterialBuildState): this;
  62269. }
  62270. }
  62271. declare module BABYLON {
  62272. /**
  62273. * Block used to get the min of 2 values
  62274. */
  62275. export class MinBlock extends NodeMaterialBlock {
  62276. /**
  62277. * Creates a new MinBlock
  62278. * @param name defines the block name
  62279. */
  62280. constructor(name: string);
  62281. /**
  62282. * Gets the current class name
  62283. * @returns the class name
  62284. */
  62285. getClassName(): string;
  62286. /**
  62287. * Gets the left operand input component
  62288. */
  62289. get left(): NodeMaterialConnectionPoint;
  62290. /**
  62291. * Gets the right operand input component
  62292. */
  62293. get right(): NodeMaterialConnectionPoint;
  62294. /**
  62295. * Gets the output component
  62296. */
  62297. get output(): NodeMaterialConnectionPoint;
  62298. protected _buildBlock(state: NodeMaterialBuildState): this;
  62299. }
  62300. }
  62301. declare module BABYLON {
  62302. /**
  62303. * Block used to get the distance between 2 values
  62304. */
  62305. export class DistanceBlock extends NodeMaterialBlock {
  62306. /**
  62307. * Creates a new DistanceBlock
  62308. * @param name defines the block name
  62309. */
  62310. constructor(name: string);
  62311. /**
  62312. * Gets the current class name
  62313. * @returns the class name
  62314. */
  62315. getClassName(): string;
  62316. /**
  62317. * Gets the left operand input component
  62318. */
  62319. get left(): NodeMaterialConnectionPoint;
  62320. /**
  62321. * Gets the right operand input component
  62322. */
  62323. get right(): NodeMaterialConnectionPoint;
  62324. /**
  62325. * Gets the output component
  62326. */
  62327. get output(): NodeMaterialConnectionPoint;
  62328. protected _buildBlock(state: NodeMaterialBuildState): this;
  62329. }
  62330. }
  62331. declare module BABYLON {
  62332. /**
  62333. * Block used to get the length of a vector
  62334. */
  62335. export class LengthBlock extends NodeMaterialBlock {
  62336. /**
  62337. * Creates a new LengthBlock
  62338. * @param name defines the block name
  62339. */
  62340. constructor(name: string);
  62341. /**
  62342. * Gets the current class name
  62343. * @returns the class name
  62344. */
  62345. getClassName(): string;
  62346. /**
  62347. * Gets the value input component
  62348. */
  62349. get value(): NodeMaterialConnectionPoint;
  62350. /**
  62351. * Gets the output component
  62352. */
  62353. get output(): NodeMaterialConnectionPoint;
  62354. protected _buildBlock(state: NodeMaterialBuildState): this;
  62355. }
  62356. }
  62357. declare module BABYLON {
  62358. /**
  62359. * Block used to get negative version of a value (i.e. x * -1)
  62360. */
  62361. export class NegateBlock extends NodeMaterialBlock {
  62362. /**
  62363. * Creates a new NegateBlock
  62364. * @param name defines the block name
  62365. */
  62366. constructor(name: string);
  62367. /**
  62368. * Gets the current class name
  62369. * @returns the class name
  62370. */
  62371. getClassName(): string;
  62372. /**
  62373. * Gets the value input component
  62374. */
  62375. get value(): NodeMaterialConnectionPoint;
  62376. /**
  62377. * Gets the output component
  62378. */
  62379. get output(): NodeMaterialConnectionPoint;
  62380. protected _buildBlock(state: NodeMaterialBuildState): this;
  62381. }
  62382. }
  62383. declare module BABYLON {
  62384. /**
  62385. * Block used to get the value of the first parameter raised to the power of the second
  62386. */
  62387. export class PowBlock extends NodeMaterialBlock {
  62388. /**
  62389. * Creates a new PowBlock
  62390. * @param name defines the block name
  62391. */
  62392. constructor(name: string);
  62393. /**
  62394. * Gets the current class name
  62395. * @returns the class name
  62396. */
  62397. getClassName(): string;
  62398. /**
  62399. * Gets the value operand input component
  62400. */
  62401. get value(): NodeMaterialConnectionPoint;
  62402. /**
  62403. * Gets the power operand input component
  62404. */
  62405. get power(): NodeMaterialConnectionPoint;
  62406. /**
  62407. * Gets the output component
  62408. */
  62409. get output(): NodeMaterialConnectionPoint;
  62410. protected _buildBlock(state: NodeMaterialBuildState): this;
  62411. }
  62412. }
  62413. declare module BABYLON {
  62414. /**
  62415. * Block used to get a random number
  62416. */
  62417. export class RandomNumberBlock extends NodeMaterialBlock {
  62418. /**
  62419. * Creates a new RandomNumberBlock
  62420. * @param name defines the block name
  62421. */
  62422. constructor(name: string);
  62423. /**
  62424. * Gets the current class name
  62425. * @returns the class name
  62426. */
  62427. getClassName(): string;
  62428. /**
  62429. * Gets the seed input component
  62430. */
  62431. get seed(): NodeMaterialConnectionPoint;
  62432. /**
  62433. * Gets the output component
  62434. */
  62435. get output(): NodeMaterialConnectionPoint;
  62436. protected _buildBlock(state: NodeMaterialBuildState): this;
  62437. }
  62438. }
  62439. declare module BABYLON {
  62440. /**
  62441. * Block used to compute arc tangent of 2 values
  62442. */
  62443. export class ArcTan2Block extends NodeMaterialBlock {
  62444. /**
  62445. * Creates a new ArcTan2Block
  62446. * @param name defines the block name
  62447. */
  62448. constructor(name: string);
  62449. /**
  62450. * Gets the current class name
  62451. * @returns the class name
  62452. */
  62453. getClassName(): string;
  62454. /**
  62455. * Gets the x operand input component
  62456. */
  62457. get x(): NodeMaterialConnectionPoint;
  62458. /**
  62459. * Gets the y operand input component
  62460. */
  62461. get y(): NodeMaterialConnectionPoint;
  62462. /**
  62463. * Gets the output component
  62464. */
  62465. get output(): NodeMaterialConnectionPoint;
  62466. protected _buildBlock(state: NodeMaterialBuildState): this;
  62467. }
  62468. }
  62469. declare module BABYLON {
  62470. /**
  62471. * Block used to smooth step a value
  62472. */
  62473. export class SmoothStepBlock extends NodeMaterialBlock {
  62474. /**
  62475. * Creates a new SmoothStepBlock
  62476. * @param name defines the block name
  62477. */
  62478. constructor(name: string);
  62479. /**
  62480. * Gets the current class name
  62481. * @returns the class name
  62482. */
  62483. getClassName(): string;
  62484. /**
  62485. * Gets the value operand input component
  62486. */
  62487. get value(): NodeMaterialConnectionPoint;
  62488. /**
  62489. * Gets the first edge operand input component
  62490. */
  62491. get edge0(): NodeMaterialConnectionPoint;
  62492. /**
  62493. * Gets the second edge operand input component
  62494. */
  62495. get edge1(): NodeMaterialConnectionPoint;
  62496. /**
  62497. * Gets the output component
  62498. */
  62499. get output(): NodeMaterialConnectionPoint;
  62500. protected _buildBlock(state: NodeMaterialBuildState): this;
  62501. }
  62502. }
  62503. declare module BABYLON {
  62504. /**
  62505. * Block used to get the reciprocal (1 / x) of a value
  62506. */
  62507. export class ReciprocalBlock extends NodeMaterialBlock {
  62508. /**
  62509. * Creates a new ReciprocalBlock
  62510. * @param name defines the block name
  62511. */
  62512. constructor(name: string);
  62513. /**
  62514. * Gets the current class name
  62515. * @returns the class name
  62516. */
  62517. getClassName(): string;
  62518. /**
  62519. * Gets the input component
  62520. */
  62521. get input(): NodeMaterialConnectionPoint;
  62522. /**
  62523. * Gets the output component
  62524. */
  62525. get output(): NodeMaterialConnectionPoint;
  62526. protected _buildBlock(state: NodeMaterialBuildState): this;
  62527. }
  62528. }
  62529. declare module BABYLON {
  62530. /**
  62531. * Block used to replace a color by another one
  62532. */
  62533. export class ReplaceColorBlock extends NodeMaterialBlock {
  62534. /**
  62535. * Creates a new ReplaceColorBlock
  62536. * @param name defines the block name
  62537. */
  62538. constructor(name: string);
  62539. /**
  62540. * Gets the current class name
  62541. * @returns the class name
  62542. */
  62543. getClassName(): string;
  62544. /**
  62545. * Gets the value input component
  62546. */
  62547. get value(): NodeMaterialConnectionPoint;
  62548. /**
  62549. * Gets the reference input component
  62550. */
  62551. get reference(): NodeMaterialConnectionPoint;
  62552. /**
  62553. * Gets the distance input component
  62554. */
  62555. get distance(): NodeMaterialConnectionPoint;
  62556. /**
  62557. * Gets the replacement input component
  62558. */
  62559. get replacement(): NodeMaterialConnectionPoint;
  62560. /**
  62561. * Gets the output component
  62562. */
  62563. get output(): NodeMaterialConnectionPoint;
  62564. protected _buildBlock(state: NodeMaterialBuildState): this;
  62565. }
  62566. }
  62567. declare module BABYLON {
  62568. /**
  62569. * Block used to posterize a value
  62570. * @see https://en.wikipedia.org/wiki/Posterization
  62571. */
  62572. export class PosterizeBlock extends NodeMaterialBlock {
  62573. /**
  62574. * Creates a new PosterizeBlock
  62575. * @param name defines the block name
  62576. */
  62577. constructor(name: string);
  62578. /**
  62579. * Gets the current class name
  62580. * @returns the class name
  62581. */
  62582. getClassName(): string;
  62583. /**
  62584. * Gets the value input component
  62585. */
  62586. get value(): NodeMaterialConnectionPoint;
  62587. /**
  62588. * Gets the steps input component
  62589. */
  62590. get steps(): NodeMaterialConnectionPoint;
  62591. /**
  62592. * Gets the output component
  62593. */
  62594. get output(): NodeMaterialConnectionPoint;
  62595. protected _buildBlock(state: NodeMaterialBuildState): this;
  62596. }
  62597. }
  62598. declare module BABYLON {
  62599. /**
  62600. * Operations supported by the Wave block
  62601. */
  62602. export enum WaveBlockKind {
  62603. /** SawTooth */
  62604. SawTooth = 0,
  62605. /** Square */
  62606. Square = 1,
  62607. /** Triangle */
  62608. Triangle = 2
  62609. }
  62610. /**
  62611. * Block used to apply wave operation to floats
  62612. */
  62613. export class WaveBlock extends NodeMaterialBlock {
  62614. /**
  62615. * Gets or sets the kibnd of wave to be applied by the block
  62616. */
  62617. kind: WaveBlockKind;
  62618. /**
  62619. * Creates a new WaveBlock
  62620. * @param name defines the block name
  62621. */
  62622. constructor(name: string);
  62623. /**
  62624. * Gets the current class name
  62625. * @returns the class name
  62626. */
  62627. getClassName(): string;
  62628. /**
  62629. * Gets the input component
  62630. */
  62631. get input(): NodeMaterialConnectionPoint;
  62632. /**
  62633. * Gets the output component
  62634. */
  62635. get output(): NodeMaterialConnectionPoint;
  62636. protected _buildBlock(state: NodeMaterialBuildState): this;
  62637. serialize(): any;
  62638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62639. }
  62640. }
  62641. declare module BABYLON {
  62642. /**
  62643. * Class used to store a color step for the GradientBlock
  62644. */
  62645. export class GradientBlockColorStep {
  62646. /**
  62647. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62648. */
  62649. step: number;
  62650. /**
  62651. * Gets or sets the color associated with this step
  62652. */
  62653. color: Color3;
  62654. /**
  62655. * Creates a new GradientBlockColorStep
  62656. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62657. * @param color defines the color associated with this step
  62658. */
  62659. constructor(
  62660. /**
  62661. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62662. */
  62663. step: number,
  62664. /**
  62665. * Gets or sets the color associated with this step
  62666. */
  62667. color: Color3);
  62668. }
  62669. /**
  62670. * Block used to return a color from a gradient based on an input value between 0 and 1
  62671. */
  62672. export class GradientBlock extends NodeMaterialBlock {
  62673. /**
  62674. * Gets or sets the list of color steps
  62675. */
  62676. colorSteps: GradientBlockColorStep[];
  62677. /**
  62678. * Creates a new GradientBlock
  62679. * @param name defines the block name
  62680. */
  62681. constructor(name: string);
  62682. /**
  62683. * Gets the current class name
  62684. * @returns the class name
  62685. */
  62686. getClassName(): string;
  62687. /**
  62688. * Gets the gradient input component
  62689. */
  62690. get gradient(): NodeMaterialConnectionPoint;
  62691. /**
  62692. * Gets the output component
  62693. */
  62694. get output(): NodeMaterialConnectionPoint;
  62695. private _writeColorConstant;
  62696. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62697. serialize(): any;
  62698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62699. protected _dumpPropertiesCode(): string;
  62700. }
  62701. }
  62702. declare module BABYLON {
  62703. /**
  62704. * Block used to normalize lerp between 2 values
  62705. */
  62706. export class NLerpBlock extends NodeMaterialBlock {
  62707. /**
  62708. * Creates a new NLerpBlock
  62709. * @param name defines the block name
  62710. */
  62711. constructor(name: string);
  62712. /**
  62713. * Gets the current class name
  62714. * @returns the class name
  62715. */
  62716. getClassName(): string;
  62717. /**
  62718. * Gets the left operand input component
  62719. */
  62720. get left(): NodeMaterialConnectionPoint;
  62721. /**
  62722. * Gets the right operand input component
  62723. */
  62724. get right(): NodeMaterialConnectionPoint;
  62725. /**
  62726. * Gets the gradient operand input component
  62727. */
  62728. get gradient(): NodeMaterialConnectionPoint;
  62729. /**
  62730. * Gets the output component
  62731. */
  62732. get output(): NodeMaterialConnectionPoint;
  62733. protected _buildBlock(state: NodeMaterialBuildState): this;
  62734. }
  62735. }
  62736. declare module BABYLON {
  62737. /**
  62738. * block used to Generate a Worley Noise 3D Noise Pattern
  62739. */
  62740. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62741. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62742. manhattanDistance: boolean;
  62743. /**
  62744. * Creates a new WorleyNoise3DBlock
  62745. * @param name defines the block name
  62746. */
  62747. constructor(name: string);
  62748. /**
  62749. * Gets the current class name
  62750. * @returns the class name
  62751. */
  62752. getClassName(): string;
  62753. /**
  62754. * Gets the seed input component
  62755. */
  62756. get seed(): NodeMaterialConnectionPoint;
  62757. /**
  62758. * Gets the jitter input component
  62759. */
  62760. get jitter(): NodeMaterialConnectionPoint;
  62761. /**
  62762. * Gets the output component
  62763. */
  62764. get output(): NodeMaterialConnectionPoint;
  62765. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62766. /**
  62767. * Exposes the properties to the UI?
  62768. */
  62769. protected _dumpPropertiesCode(): string;
  62770. /**
  62771. * Exposes the properties to the Seralize?
  62772. */
  62773. serialize(): any;
  62774. /**
  62775. * Exposes the properties to the deseralize?
  62776. */
  62777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62778. }
  62779. }
  62780. declare module BABYLON {
  62781. /**
  62782. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62783. */
  62784. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62785. /**
  62786. * Creates a new SimplexPerlin3DBlock
  62787. * @param name defines the block name
  62788. */
  62789. constructor(name: string);
  62790. /**
  62791. * Gets the current class name
  62792. * @returns the class name
  62793. */
  62794. getClassName(): string;
  62795. /**
  62796. * Gets the seed operand input component
  62797. */
  62798. get seed(): NodeMaterialConnectionPoint;
  62799. /**
  62800. * Gets the output component
  62801. */
  62802. get output(): NodeMaterialConnectionPoint;
  62803. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62804. }
  62805. }
  62806. declare module BABYLON {
  62807. /**
  62808. * Block used to blend normals
  62809. */
  62810. export class NormalBlendBlock extends NodeMaterialBlock {
  62811. /**
  62812. * Creates a new NormalBlendBlock
  62813. * @param name defines the block name
  62814. */
  62815. constructor(name: string);
  62816. /**
  62817. * Gets the current class name
  62818. * @returns the class name
  62819. */
  62820. getClassName(): string;
  62821. /**
  62822. * Gets the first input component
  62823. */
  62824. get normalMap0(): NodeMaterialConnectionPoint;
  62825. /**
  62826. * Gets the second input component
  62827. */
  62828. get normalMap1(): NodeMaterialConnectionPoint;
  62829. /**
  62830. * Gets the output component
  62831. */
  62832. get output(): NodeMaterialConnectionPoint;
  62833. protected _buildBlock(state: NodeMaterialBuildState): this;
  62834. }
  62835. }
  62836. declare module BABYLON {
  62837. /**
  62838. * Block used to rotate a 2d vector by a given angle
  62839. */
  62840. export class Rotate2dBlock extends NodeMaterialBlock {
  62841. /**
  62842. * Creates a new Rotate2dBlock
  62843. * @param name defines the block name
  62844. */
  62845. constructor(name: string);
  62846. /**
  62847. * Gets the current class name
  62848. * @returns the class name
  62849. */
  62850. getClassName(): string;
  62851. /**
  62852. * Gets the input vector
  62853. */
  62854. get input(): NodeMaterialConnectionPoint;
  62855. /**
  62856. * Gets the input angle
  62857. */
  62858. get angle(): NodeMaterialConnectionPoint;
  62859. /**
  62860. * Gets the output component
  62861. */
  62862. get output(): NodeMaterialConnectionPoint;
  62863. autoConfigure(material: NodeMaterial): void;
  62864. protected _buildBlock(state: NodeMaterialBuildState): this;
  62865. }
  62866. }
  62867. declare module BABYLON {
  62868. /**
  62869. * Block used to get the reflected vector from a direction and a normal
  62870. */
  62871. export class ReflectBlock extends NodeMaterialBlock {
  62872. /**
  62873. * Creates a new ReflectBlock
  62874. * @param name defines the block name
  62875. */
  62876. constructor(name: string);
  62877. /**
  62878. * Gets the current class name
  62879. * @returns the class name
  62880. */
  62881. getClassName(): string;
  62882. /**
  62883. * Gets the incident component
  62884. */
  62885. get incident(): NodeMaterialConnectionPoint;
  62886. /**
  62887. * Gets the normal component
  62888. */
  62889. get normal(): NodeMaterialConnectionPoint;
  62890. /**
  62891. * Gets the output component
  62892. */
  62893. get output(): NodeMaterialConnectionPoint;
  62894. protected _buildBlock(state: NodeMaterialBuildState): this;
  62895. }
  62896. }
  62897. declare module BABYLON {
  62898. /**
  62899. * Block used to get the refracted vector from a direction and a normal
  62900. */
  62901. export class RefractBlock extends NodeMaterialBlock {
  62902. /**
  62903. * Creates a new RefractBlock
  62904. * @param name defines the block name
  62905. */
  62906. constructor(name: string);
  62907. /**
  62908. * Gets the current class name
  62909. * @returns the class name
  62910. */
  62911. getClassName(): string;
  62912. /**
  62913. * Gets the incident component
  62914. */
  62915. get incident(): NodeMaterialConnectionPoint;
  62916. /**
  62917. * Gets the normal component
  62918. */
  62919. get normal(): NodeMaterialConnectionPoint;
  62920. /**
  62921. * Gets the index of refraction component
  62922. */
  62923. get ior(): NodeMaterialConnectionPoint;
  62924. /**
  62925. * Gets the output component
  62926. */
  62927. get output(): NodeMaterialConnectionPoint;
  62928. protected _buildBlock(state: NodeMaterialBuildState): this;
  62929. }
  62930. }
  62931. declare module BABYLON {
  62932. /**
  62933. * Block used to desaturate a color
  62934. */
  62935. export class DesaturateBlock extends NodeMaterialBlock {
  62936. /**
  62937. * Creates a new DesaturateBlock
  62938. * @param name defines the block name
  62939. */
  62940. constructor(name: string);
  62941. /**
  62942. * Gets the current class name
  62943. * @returns the class name
  62944. */
  62945. getClassName(): string;
  62946. /**
  62947. * Gets the color operand input component
  62948. */
  62949. get color(): NodeMaterialConnectionPoint;
  62950. /**
  62951. * Gets the level operand input component
  62952. */
  62953. get level(): NodeMaterialConnectionPoint;
  62954. /**
  62955. * Gets the output component
  62956. */
  62957. get output(): NodeMaterialConnectionPoint;
  62958. protected _buildBlock(state: NodeMaterialBuildState): this;
  62959. }
  62960. }
  62961. declare module BABYLON {
  62962. /**
  62963. * Block used to implement the ambient occlusion module of the PBR material
  62964. */
  62965. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62966. /**
  62967. * Create a new AmbientOcclusionBlock
  62968. * @param name defines the block name
  62969. */
  62970. constructor(name: string);
  62971. /**
  62972. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62973. */
  62974. useAmbientInGrayScale: boolean;
  62975. /**
  62976. * Initialize the block and prepare the context for build
  62977. * @param state defines the state that will be used for the build
  62978. */
  62979. initialize(state: NodeMaterialBuildState): void;
  62980. /**
  62981. * Gets the current class name
  62982. * @returns the class name
  62983. */
  62984. getClassName(): string;
  62985. /**
  62986. * Gets the texture input component
  62987. */
  62988. get texture(): NodeMaterialConnectionPoint;
  62989. /**
  62990. * Gets the texture intensity component
  62991. */
  62992. get intensity(): NodeMaterialConnectionPoint;
  62993. /**
  62994. * Gets the direct light intensity input component
  62995. */
  62996. get directLightIntensity(): NodeMaterialConnectionPoint;
  62997. /**
  62998. * Gets the ambient occlusion object output component
  62999. */
  63000. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63001. /**
  63002. * Gets the main code of the block (fragment side)
  63003. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63004. * @returns the shader code
  63005. */
  63006. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63007. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63008. protected _buildBlock(state: NodeMaterialBuildState): this;
  63009. protected _dumpPropertiesCode(): string;
  63010. serialize(): any;
  63011. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63012. }
  63013. }
  63014. declare module BABYLON {
  63015. /**
  63016. * Block used to implement the reflection module of the PBR material
  63017. */
  63018. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63019. /** @hidden */
  63020. _defineLODReflectionAlpha: string;
  63021. /** @hidden */
  63022. _defineLinearSpecularReflection: string;
  63023. private _vEnvironmentIrradianceName;
  63024. /** @hidden */
  63025. _vReflectionMicrosurfaceInfosName: string;
  63026. /** @hidden */
  63027. _vReflectionInfosName: string;
  63028. /** @hidden */
  63029. _vReflectionFilteringInfoName: string;
  63030. private _scene;
  63031. /**
  63032. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63033. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63034. * It's less burden on the user side in the editor part.
  63035. */
  63036. /** @hidden */
  63037. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63038. /** @hidden */
  63039. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63040. /** @hidden */
  63041. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63042. /**
  63043. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63044. * diffuse part of the IBL.
  63045. */
  63046. useSphericalHarmonics: boolean;
  63047. /**
  63048. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63049. */
  63050. forceIrradianceInFragment: boolean;
  63051. /**
  63052. * Create a new ReflectionBlock
  63053. * @param name defines the block name
  63054. */
  63055. constructor(name: string);
  63056. /**
  63057. * Gets the current class name
  63058. * @returns the class name
  63059. */
  63060. getClassName(): string;
  63061. /**
  63062. * Gets the position input component
  63063. */
  63064. get position(): NodeMaterialConnectionPoint;
  63065. /**
  63066. * Gets the world position input component
  63067. */
  63068. get worldPosition(): NodeMaterialConnectionPoint;
  63069. /**
  63070. * Gets the world normal input component
  63071. */
  63072. get worldNormal(): NodeMaterialConnectionPoint;
  63073. /**
  63074. * Gets the world input component
  63075. */
  63076. get world(): NodeMaterialConnectionPoint;
  63077. /**
  63078. * Gets the camera (or eye) position component
  63079. */
  63080. get cameraPosition(): NodeMaterialConnectionPoint;
  63081. /**
  63082. * Gets the view input component
  63083. */
  63084. get view(): NodeMaterialConnectionPoint;
  63085. /**
  63086. * Gets the color input component
  63087. */
  63088. get color(): NodeMaterialConnectionPoint;
  63089. /**
  63090. * Gets the reflection object output component
  63091. */
  63092. get reflection(): NodeMaterialConnectionPoint;
  63093. /**
  63094. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63095. */
  63096. get hasTexture(): boolean;
  63097. /**
  63098. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63099. */
  63100. get reflectionColor(): string;
  63101. protected _getTexture(): Nullable<BaseTexture>;
  63102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63103. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63104. /**
  63105. * Gets the code to inject in the vertex shader
  63106. * @param state current state of the node material building
  63107. * @returns the shader code
  63108. */
  63109. handleVertexSide(state: NodeMaterialBuildState): string;
  63110. /**
  63111. * Gets the main code of the block (fragment side)
  63112. * @param state current state of the node material building
  63113. * @param normalVarName name of the existing variable corresponding to the normal
  63114. * @returns the shader code
  63115. */
  63116. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63117. protected _buildBlock(state: NodeMaterialBuildState): this;
  63118. protected _dumpPropertiesCode(): string;
  63119. serialize(): any;
  63120. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63121. }
  63122. }
  63123. declare module BABYLON {
  63124. /**
  63125. * Block used to implement the sheen module of the PBR material
  63126. */
  63127. export class SheenBlock extends NodeMaterialBlock {
  63128. /**
  63129. * Create a new SheenBlock
  63130. * @param name defines the block name
  63131. */
  63132. constructor(name: string);
  63133. /**
  63134. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63135. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63136. * making it easier to setup and tweak the effect
  63137. */
  63138. albedoScaling: boolean;
  63139. /**
  63140. * Defines if the sheen is linked to the sheen color.
  63141. */
  63142. linkSheenWithAlbedo: boolean;
  63143. /**
  63144. * Initialize the block and prepare the context for build
  63145. * @param state defines the state that will be used for the build
  63146. */
  63147. initialize(state: NodeMaterialBuildState): void;
  63148. /**
  63149. * Gets the current class name
  63150. * @returns the class name
  63151. */
  63152. getClassName(): string;
  63153. /**
  63154. * Gets the intensity input component
  63155. */
  63156. get intensity(): NodeMaterialConnectionPoint;
  63157. /**
  63158. * Gets the color input component
  63159. */
  63160. get color(): NodeMaterialConnectionPoint;
  63161. /**
  63162. * Gets the roughness input component
  63163. */
  63164. get roughness(): NodeMaterialConnectionPoint;
  63165. /**
  63166. * Gets the sheen object output component
  63167. */
  63168. get sheen(): NodeMaterialConnectionPoint;
  63169. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63170. /**
  63171. * Gets the main code of the block (fragment side)
  63172. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63173. * @returns the shader code
  63174. */
  63175. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63176. protected _buildBlock(state: NodeMaterialBuildState): this;
  63177. protected _dumpPropertiesCode(): string;
  63178. serialize(): any;
  63179. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63180. }
  63181. }
  63182. declare module BABYLON {
  63183. /**
  63184. * Block used to implement the reflectivity module of the PBR material
  63185. */
  63186. export class ReflectivityBlock extends NodeMaterialBlock {
  63187. private _metallicReflectanceColor;
  63188. private _metallicF0Factor;
  63189. /** @hidden */
  63190. _vMetallicReflectanceFactorsName: string;
  63191. /**
  63192. * The property below is set by the main PBR block prior to calling methods of this class.
  63193. */
  63194. /** @hidden */
  63195. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63196. /**
  63197. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63198. */
  63199. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63200. /**
  63201. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63202. */
  63203. useMetallnessFromMetallicTextureBlue: boolean;
  63204. /**
  63205. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63206. */
  63207. useRoughnessFromMetallicTextureAlpha: boolean;
  63208. /**
  63209. * Specifies if the metallic texture contains the roughness information in its green channel.
  63210. */
  63211. useRoughnessFromMetallicTextureGreen: boolean;
  63212. /**
  63213. * Create a new ReflectivityBlock
  63214. * @param name defines the block name
  63215. */
  63216. constructor(name: string);
  63217. /**
  63218. * Initialize the block and prepare the context for build
  63219. * @param state defines the state that will be used for the build
  63220. */
  63221. initialize(state: NodeMaterialBuildState): void;
  63222. /**
  63223. * Gets the current class name
  63224. * @returns the class name
  63225. */
  63226. getClassName(): string;
  63227. /**
  63228. * Gets the metallic input component
  63229. */
  63230. get metallic(): NodeMaterialConnectionPoint;
  63231. /**
  63232. * Gets the roughness input component
  63233. */
  63234. get roughness(): NodeMaterialConnectionPoint;
  63235. /**
  63236. * Gets the texture input component
  63237. */
  63238. get texture(): NodeMaterialConnectionPoint;
  63239. /**
  63240. * Gets the reflectivity object output component
  63241. */
  63242. get reflectivity(): NodeMaterialConnectionPoint;
  63243. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63244. /**
  63245. * Gets the main code of the block (fragment side)
  63246. * @param state current state of the node material building
  63247. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63248. * @returns the shader code
  63249. */
  63250. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63252. protected _buildBlock(state: NodeMaterialBuildState): this;
  63253. protected _dumpPropertiesCode(): string;
  63254. serialize(): any;
  63255. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63256. }
  63257. }
  63258. declare module BABYLON {
  63259. /**
  63260. * Block used to implement the anisotropy module of the PBR material
  63261. */
  63262. export class AnisotropyBlock extends NodeMaterialBlock {
  63263. /**
  63264. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63265. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63266. * It's less burden on the user side in the editor part.
  63267. */
  63268. /** @hidden */
  63269. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63270. /** @hidden */
  63271. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63272. /**
  63273. * Create a new AnisotropyBlock
  63274. * @param name defines the block name
  63275. */
  63276. constructor(name: string);
  63277. /**
  63278. * Initialize the block and prepare the context for build
  63279. * @param state defines the state that will be used for the build
  63280. */
  63281. initialize(state: NodeMaterialBuildState): void;
  63282. /**
  63283. * Gets the current class name
  63284. * @returns the class name
  63285. */
  63286. getClassName(): string;
  63287. /**
  63288. * Gets the intensity input component
  63289. */
  63290. get intensity(): NodeMaterialConnectionPoint;
  63291. /**
  63292. * Gets the direction input component
  63293. */
  63294. get direction(): NodeMaterialConnectionPoint;
  63295. /**
  63296. * Gets the texture input component
  63297. */
  63298. get texture(): NodeMaterialConnectionPoint;
  63299. /**
  63300. * Gets the uv input component
  63301. */
  63302. get uv(): NodeMaterialConnectionPoint;
  63303. /**
  63304. * Gets the worldTangent input component
  63305. */
  63306. get worldTangent(): NodeMaterialConnectionPoint;
  63307. /**
  63308. * Gets the anisotropy object output component
  63309. */
  63310. get anisotropy(): NodeMaterialConnectionPoint;
  63311. private _generateTBNSpace;
  63312. /**
  63313. * Gets the main code of the block (fragment side)
  63314. * @param state current state of the node material building
  63315. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63316. * @returns the shader code
  63317. */
  63318. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63320. protected _buildBlock(state: NodeMaterialBuildState): this;
  63321. }
  63322. }
  63323. declare module BABYLON {
  63324. /**
  63325. * Block used to implement the clear coat module of the PBR material
  63326. */
  63327. export class ClearCoatBlock extends NodeMaterialBlock {
  63328. private _scene;
  63329. /**
  63330. * Create a new ClearCoatBlock
  63331. * @param name defines the block name
  63332. */
  63333. constructor(name: string);
  63334. /**
  63335. * Initialize the block and prepare the context for build
  63336. * @param state defines the state that will be used for the build
  63337. */
  63338. initialize(state: NodeMaterialBuildState): void;
  63339. /**
  63340. * Gets the current class name
  63341. * @returns the class name
  63342. */
  63343. getClassName(): string;
  63344. /**
  63345. * Gets the intensity input component
  63346. */
  63347. get intensity(): NodeMaterialConnectionPoint;
  63348. /**
  63349. * Gets the roughness input component
  63350. */
  63351. get roughness(): NodeMaterialConnectionPoint;
  63352. /**
  63353. * Gets the ior input component
  63354. */
  63355. get ior(): NodeMaterialConnectionPoint;
  63356. /**
  63357. * Gets the texture input component
  63358. */
  63359. get texture(): NodeMaterialConnectionPoint;
  63360. /**
  63361. * Gets the bump texture input component
  63362. */
  63363. get bumpTexture(): NodeMaterialConnectionPoint;
  63364. /**
  63365. * Gets the uv input component
  63366. */
  63367. get uv(): NodeMaterialConnectionPoint;
  63368. /**
  63369. * Gets the tint color input component
  63370. */
  63371. get tintColor(): NodeMaterialConnectionPoint;
  63372. /**
  63373. * Gets the tint "at distance" input component
  63374. */
  63375. get tintAtDistance(): NodeMaterialConnectionPoint;
  63376. /**
  63377. * Gets the tint thickness input component
  63378. */
  63379. get tintThickness(): NodeMaterialConnectionPoint;
  63380. /**
  63381. * Gets the world tangent input component
  63382. */
  63383. get worldTangent(): NodeMaterialConnectionPoint;
  63384. /**
  63385. * Gets the clear coat object output component
  63386. */
  63387. get clearcoat(): NodeMaterialConnectionPoint;
  63388. autoConfigure(material: NodeMaterial): void;
  63389. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63390. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63391. private _generateTBNSpace;
  63392. /**
  63393. * Gets the main code of the block (fragment side)
  63394. * @param state current state of the node material building
  63395. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63396. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63397. * @param worldPosVarName name of the variable holding the world position
  63398. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63399. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63400. * @param worldNormalVarName name of the variable holding the world normal
  63401. * @returns the shader code
  63402. */
  63403. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63404. protected _buildBlock(state: NodeMaterialBuildState): this;
  63405. }
  63406. }
  63407. declare module BABYLON {
  63408. /**
  63409. * Block used to implement the sub surface module of the PBR material
  63410. */
  63411. export class SubSurfaceBlock extends NodeMaterialBlock {
  63412. /**
  63413. * Create a new SubSurfaceBlock
  63414. * @param name defines the block name
  63415. */
  63416. constructor(name: string);
  63417. /**
  63418. * Stores the intensity of the different subsurface effects in the thickness texture.
  63419. * * the green channel is the translucency intensity.
  63420. * * the blue channel is the scattering intensity.
  63421. * * the alpha channel is the refraction intensity.
  63422. */
  63423. useMaskFromThicknessTexture: boolean;
  63424. /**
  63425. * Initialize the block and prepare the context for build
  63426. * @param state defines the state that will be used for the build
  63427. */
  63428. initialize(state: NodeMaterialBuildState): void;
  63429. /**
  63430. * Gets the current class name
  63431. * @returns the class name
  63432. */
  63433. getClassName(): string;
  63434. /**
  63435. * Gets the min thickness input component
  63436. */
  63437. get minThickness(): NodeMaterialConnectionPoint;
  63438. /**
  63439. * Gets the max thickness input component
  63440. */
  63441. get maxThickness(): NodeMaterialConnectionPoint;
  63442. /**
  63443. * Gets the thickness texture component
  63444. */
  63445. get thicknessTexture(): NodeMaterialConnectionPoint;
  63446. /**
  63447. * Gets the tint color input component
  63448. */
  63449. get tintColor(): NodeMaterialConnectionPoint;
  63450. /**
  63451. * Gets the translucency intensity input component
  63452. */
  63453. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63454. /**
  63455. * Gets the translucency diffusion distance input component
  63456. */
  63457. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63458. /**
  63459. * Gets the refraction object parameters
  63460. */
  63461. get refraction(): NodeMaterialConnectionPoint;
  63462. /**
  63463. * Gets the sub surface object output component
  63464. */
  63465. get subsurface(): NodeMaterialConnectionPoint;
  63466. autoConfigure(material: NodeMaterial): void;
  63467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63468. /**
  63469. * Gets the main code of the block (fragment side)
  63470. * @param state current state of the node material building
  63471. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63472. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63473. * @param worldPosVarName name of the variable holding the world position
  63474. * @returns the shader code
  63475. */
  63476. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63477. protected _buildBlock(state: NodeMaterialBuildState): this;
  63478. }
  63479. }
  63480. declare module BABYLON {
  63481. /**
  63482. * Block used to implement the PBR metallic/roughness model
  63483. */
  63484. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63485. /**
  63486. * Gets or sets the light associated with this block
  63487. */
  63488. light: Nullable<Light>;
  63489. private _lightId;
  63490. private _scene;
  63491. private _environmentBRDFTexture;
  63492. private _environmentBrdfSamplerName;
  63493. private _vNormalWName;
  63494. private _invertNormalName;
  63495. /**
  63496. * Create a new ReflectionBlock
  63497. * @param name defines the block name
  63498. */
  63499. constructor(name: string);
  63500. /**
  63501. * Intensity of the direct lights e.g. the four lights available in your scene.
  63502. * This impacts both the direct diffuse and specular highlights.
  63503. */
  63504. directIntensity: number;
  63505. /**
  63506. * Intensity of the environment e.g. how much the environment will light the object
  63507. * either through harmonics for rough material or through the refelction for shiny ones.
  63508. */
  63509. environmentIntensity: number;
  63510. /**
  63511. * This is a special control allowing the reduction of the specular highlights coming from the
  63512. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63513. */
  63514. specularIntensity: number;
  63515. /**
  63516. * Defines the falloff type used in this material.
  63517. * It by default is Physical.
  63518. */
  63519. lightFalloff: number;
  63520. /**
  63521. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63522. */
  63523. useAlphaFromAlbedoTexture: boolean;
  63524. /**
  63525. * Specifies that alpha test should be used
  63526. */
  63527. useAlphaTest: boolean;
  63528. /**
  63529. * Defines the alpha limits in alpha test mode.
  63530. */
  63531. alphaTestCutoff: number;
  63532. /**
  63533. * Specifies that alpha blending should be used
  63534. */
  63535. useAlphaBlending: boolean;
  63536. /**
  63537. * Defines if the alpha value should be determined via the rgb values.
  63538. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63539. */
  63540. opacityRGB: boolean;
  63541. /**
  63542. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63543. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63544. */
  63545. useRadianceOverAlpha: boolean;
  63546. /**
  63547. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63548. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63549. */
  63550. useSpecularOverAlpha: boolean;
  63551. /**
  63552. * Enables specular anti aliasing in the PBR shader.
  63553. * It will both interacts on the Geometry for analytical and IBL lighting.
  63554. * It also prefilter the roughness map based on the bump values.
  63555. */
  63556. enableSpecularAntiAliasing: boolean;
  63557. /**
  63558. * Enables realtime filtering on the texture.
  63559. */
  63560. realTimeFiltering: boolean;
  63561. /**
  63562. * Quality switch for realtime filtering
  63563. */
  63564. realTimeFilteringQuality: number;
  63565. /**
  63566. * Defines if the material uses energy conservation.
  63567. */
  63568. useEnergyConservation: boolean;
  63569. /**
  63570. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63571. * too much the area relying on ambient texture to define their ambient occlusion.
  63572. */
  63573. useRadianceOcclusion: boolean;
  63574. /**
  63575. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63576. * makes the reflect vector face the model (under horizon).
  63577. */
  63578. useHorizonOcclusion: boolean;
  63579. /**
  63580. * If set to true, no lighting calculations will be applied.
  63581. */
  63582. unlit: boolean;
  63583. /**
  63584. * Force normal to face away from face.
  63585. */
  63586. forceNormalForward: boolean;
  63587. /**
  63588. * Defines the material debug mode.
  63589. * It helps seeing only some components of the material while troubleshooting.
  63590. */
  63591. debugMode: number;
  63592. /**
  63593. * Specify from where on screen the debug mode should start.
  63594. * The value goes from -1 (full screen) to 1 (not visible)
  63595. * It helps with side by side comparison against the final render
  63596. * This defaults to 0
  63597. */
  63598. debugLimit: number;
  63599. /**
  63600. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63601. * You can use the factor to better multiply the final value.
  63602. */
  63603. debugFactor: number;
  63604. /**
  63605. * Initialize the block and prepare the context for build
  63606. * @param state defines the state that will be used for the build
  63607. */
  63608. initialize(state: NodeMaterialBuildState): void;
  63609. /**
  63610. * Gets the current class name
  63611. * @returns the class name
  63612. */
  63613. getClassName(): string;
  63614. /**
  63615. * Gets the world position input component
  63616. */
  63617. get worldPosition(): NodeMaterialConnectionPoint;
  63618. /**
  63619. * Gets the world normal input component
  63620. */
  63621. get worldNormal(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Gets the perturbed normal input component
  63624. */
  63625. get perturbedNormal(): NodeMaterialConnectionPoint;
  63626. /**
  63627. * Gets the camera position input component
  63628. */
  63629. get cameraPosition(): NodeMaterialConnectionPoint;
  63630. /**
  63631. * Gets the base color input component
  63632. */
  63633. get baseColor(): NodeMaterialConnectionPoint;
  63634. /**
  63635. * Gets the opacity texture input component
  63636. */
  63637. get opacityTexture(): NodeMaterialConnectionPoint;
  63638. /**
  63639. * Gets the ambient color input component
  63640. */
  63641. get ambientColor(): NodeMaterialConnectionPoint;
  63642. /**
  63643. * Gets the reflectivity object parameters
  63644. */
  63645. get reflectivity(): NodeMaterialConnectionPoint;
  63646. /**
  63647. * Gets the ambient occlusion object parameters
  63648. */
  63649. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63650. /**
  63651. * Gets the reflection object parameters
  63652. */
  63653. get reflection(): NodeMaterialConnectionPoint;
  63654. /**
  63655. * Gets the sheen object parameters
  63656. */
  63657. get sheen(): NodeMaterialConnectionPoint;
  63658. /**
  63659. * Gets the clear coat object parameters
  63660. */
  63661. get clearcoat(): NodeMaterialConnectionPoint;
  63662. /**
  63663. * Gets the sub surface object parameters
  63664. */
  63665. get subsurface(): NodeMaterialConnectionPoint;
  63666. /**
  63667. * Gets the anisotropy object parameters
  63668. */
  63669. get anisotropy(): NodeMaterialConnectionPoint;
  63670. /**
  63671. * Gets the ambient output component
  63672. */
  63673. get ambient(): NodeMaterialConnectionPoint;
  63674. /**
  63675. * Gets the diffuse output component
  63676. */
  63677. get diffuse(): NodeMaterialConnectionPoint;
  63678. /**
  63679. * Gets the specular output component
  63680. */
  63681. get specular(): NodeMaterialConnectionPoint;
  63682. /**
  63683. * Gets the sheen output component
  63684. */
  63685. get sheenDir(): NodeMaterialConnectionPoint;
  63686. /**
  63687. * Gets the clear coat output component
  63688. */
  63689. get clearcoatDir(): NodeMaterialConnectionPoint;
  63690. /**
  63691. * Gets the indirect diffuse output component
  63692. */
  63693. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63694. /**
  63695. * Gets the indirect specular output component
  63696. */
  63697. get specularIndirect(): NodeMaterialConnectionPoint;
  63698. /**
  63699. * Gets the indirect sheen output component
  63700. */
  63701. get sheenIndirect(): NodeMaterialConnectionPoint;
  63702. /**
  63703. * Gets the indirect clear coat output component
  63704. */
  63705. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63706. /**
  63707. * Gets the refraction output component
  63708. */
  63709. get refraction(): NodeMaterialConnectionPoint;
  63710. /**
  63711. * Gets the global lighting output component
  63712. */
  63713. get lighting(): NodeMaterialConnectionPoint;
  63714. /**
  63715. * Gets the shadow output component
  63716. */
  63717. get shadow(): NodeMaterialConnectionPoint;
  63718. /**
  63719. * Gets the alpha output component
  63720. */
  63721. get alpha(): NodeMaterialConnectionPoint;
  63722. autoConfigure(material: NodeMaterial): void;
  63723. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63724. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63725. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63726. private _injectVertexCode;
  63727. /**
  63728. * Gets the code corresponding to the albedo/opacity module
  63729. * @returns the shader code
  63730. */
  63731. getAlbedoOpacityCode(): string;
  63732. protected _buildBlock(state: NodeMaterialBuildState): this;
  63733. protected _dumpPropertiesCode(): string;
  63734. serialize(): any;
  63735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63736. }
  63737. }
  63738. declare module BABYLON {
  63739. /**
  63740. * Block used to compute value of one parameter modulo another
  63741. */
  63742. export class ModBlock extends NodeMaterialBlock {
  63743. /**
  63744. * Creates a new ModBlock
  63745. * @param name defines the block name
  63746. */
  63747. constructor(name: string);
  63748. /**
  63749. * Gets the current class name
  63750. * @returns the class name
  63751. */
  63752. getClassName(): string;
  63753. /**
  63754. * Gets the left operand input component
  63755. */
  63756. get left(): NodeMaterialConnectionPoint;
  63757. /**
  63758. * Gets the right operand input component
  63759. */
  63760. get right(): NodeMaterialConnectionPoint;
  63761. /**
  63762. * Gets the output component
  63763. */
  63764. get output(): NodeMaterialConnectionPoint;
  63765. protected _buildBlock(state: NodeMaterialBuildState): this;
  63766. }
  63767. }
  63768. declare module BABYLON {
  63769. /**
  63770. * Helper class to push actions to a pool of workers.
  63771. */
  63772. export class WorkerPool implements IDisposable {
  63773. private _workerInfos;
  63774. private _pendingActions;
  63775. /**
  63776. * Constructor
  63777. * @param workers Array of workers to use for actions
  63778. */
  63779. constructor(workers: Array<Worker>);
  63780. /**
  63781. * Terminates all workers and clears any pending actions.
  63782. */
  63783. dispose(): void;
  63784. /**
  63785. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63786. * pended until a worker has completed its action.
  63787. * @param action The action to perform. Call onComplete when the action is complete.
  63788. */
  63789. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63790. private _execute;
  63791. }
  63792. }
  63793. declare module BABYLON {
  63794. /**
  63795. * Configuration for Draco compression
  63796. */
  63797. export interface IDracoCompressionConfiguration {
  63798. /**
  63799. * Configuration for the decoder.
  63800. */
  63801. decoder: {
  63802. /**
  63803. * The url to the WebAssembly module.
  63804. */
  63805. wasmUrl?: string;
  63806. /**
  63807. * The url to the WebAssembly binary.
  63808. */
  63809. wasmBinaryUrl?: string;
  63810. /**
  63811. * The url to the fallback JavaScript module.
  63812. */
  63813. fallbackUrl?: string;
  63814. };
  63815. }
  63816. /**
  63817. * Draco compression (https://google.github.io/draco/)
  63818. *
  63819. * This class wraps the Draco module.
  63820. *
  63821. * **Encoder**
  63822. *
  63823. * The encoder is not currently implemented.
  63824. *
  63825. * **Decoder**
  63826. *
  63827. * 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.
  63828. *
  63829. * To update the configuration, use the following code:
  63830. * ```javascript
  63831. * DracoCompression.Configuration = {
  63832. * decoder: {
  63833. * wasmUrl: "<url to the WebAssembly library>",
  63834. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63835. * fallbackUrl: "<url to the fallback JavaScript library>",
  63836. * }
  63837. * };
  63838. * ```
  63839. *
  63840. * 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.
  63841. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63842. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63843. *
  63844. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63845. * ```javascript
  63846. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63847. * ```
  63848. *
  63849. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63850. */
  63851. export class DracoCompression implements IDisposable {
  63852. private _workerPoolPromise?;
  63853. private _decoderModulePromise?;
  63854. /**
  63855. * The configuration. Defaults to the following urls:
  63856. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63857. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63858. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63859. */
  63860. static Configuration: IDracoCompressionConfiguration;
  63861. /**
  63862. * Returns true if the decoder configuration is available.
  63863. */
  63864. static get DecoderAvailable(): boolean;
  63865. /**
  63866. * Default number of workers to create when creating the draco compression object.
  63867. */
  63868. static DefaultNumWorkers: number;
  63869. private static GetDefaultNumWorkers;
  63870. private static _Default;
  63871. /**
  63872. * Default instance for the draco compression object.
  63873. */
  63874. static get Default(): DracoCompression;
  63875. /**
  63876. * Constructor
  63877. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63878. */
  63879. constructor(numWorkers?: number);
  63880. /**
  63881. * Stop all async operations and release resources.
  63882. */
  63883. dispose(): void;
  63884. /**
  63885. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63886. * @returns a promise that resolves when ready
  63887. */
  63888. whenReadyAsync(): Promise<void>;
  63889. /**
  63890. * Decode Draco compressed mesh data to vertex data.
  63891. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63892. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63893. * @returns A promise that resolves with the decoded vertex data
  63894. */
  63895. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63896. [kind: string]: number;
  63897. }): Promise<VertexData>;
  63898. }
  63899. }
  63900. declare module BABYLON {
  63901. /**
  63902. * Class for building Constructive Solid Geometry
  63903. */
  63904. export class CSG {
  63905. private polygons;
  63906. /**
  63907. * The world matrix
  63908. */
  63909. matrix: Matrix;
  63910. /**
  63911. * Stores the position
  63912. */
  63913. position: Vector3;
  63914. /**
  63915. * Stores the rotation
  63916. */
  63917. rotation: Vector3;
  63918. /**
  63919. * Stores the rotation quaternion
  63920. */
  63921. rotationQuaternion: Nullable<Quaternion>;
  63922. /**
  63923. * Stores the scaling vector
  63924. */
  63925. scaling: Vector3;
  63926. /**
  63927. * Convert the Mesh to CSG
  63928. * @param mesh The Mesh to convert to CSG
  63929. * @returns A new CSG from the Mesh
  63930. */
  63931. static FromMesh(mesh: Mesh): CSG;
  63932. /**
  63933. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63934. * @param polygons Polygons used to construct a CSG solid
  63935. */
  63936. private static FromPolygons;
  63937. /**
  63938. * Clones, or makes a deep copy, of the CSG
  63939. * @returns A new CSG
  63940. */
  63941. clone(): CSG;
  63942. /**
  63943. * Unions this CSG with another CSG
  63944. * @param csg The CSG to union against this CSG
  63945. * @returns The unioned CSG
  63946. */
  63947. union(csg: CSG): CSG;
  63948. /**
  63949. * Unions this CSG with another CSG in place
  63950. * @param csg The CSG to union against this CSG
  63951. */
  63952. unionInPlace(csg: CSG): void;
  63953. /**
  63954. * Subtracts this CSG with another CSG
  63955. * @param csg The CSG to subtract against this CSG
  63956. * @returns A new CSG
  63957. */
  63958. subtract(csg: CSG): CSG;
  63959. /**
  63960. * Subtracts this CSG with another CSG in place
  63961. * @param csg The CSG to subtact against this CSG
  63962. */
  63963. subtractInPlace(csg: CSG): void;
  63964. /**
  63965. * Intersect this CSG with another CSG
  63966. * @param csg The CSG to intersect against this CSG
  63967. * @returns A new CSG
  63968. */
  63969. intersect(csg: CSG): CSG;
  63970. /**
  63971. * Intersects this CSG with another CSG in place
  63972. * @param csg The CSG to intersect against this CSG
  63973. */
  63974. intersectInPlace(csg: CSG): void;
  63975. /**
  63976. * Return a new CSG solid with solid and empty space switched. This solid is
  63977. * not modified.
  63978. * @returns A new CSG solid with solid and empty space switched
  63979. */
  63980. inverse(): CSG;
  63981. /**
  63982. * Inverses the CSG in place
  63983. */
  63984. inverseInPlace(): void;
  63985. /**
  63986. * This is used to keep meshes transformations so they can be restored
  63987. * when we build back a Babylon Mesh
  63988. * NB : All CSG operations are performed in world coordinates
  63989. * @param csg The CSG to copy the transform attributes from
  63990. * @returns This CSG
  63991. */
  63992. copyTransformAttributes(csg: CSG): CSG;
  63993. /**
  63994. * Build Raw mesh from CSG
  63995. * Coordinates here are in world space
  63996. * @param name The name of the mesh geometry
  63997. * @param scene The Scene
  63998. * @param keepSubMeshes Specifies if the submeshes should be kept
  63999. * @returns A new Mesh
  64000. */
  64001. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64002. /**
  64003. * Build Mesh from CSG taking material and transforms into account
  64004. * @param name The name of the Mesh
  64005. * @param material The material of the Mesh
  64006. * @param scene The Scene
  64007. * @param keepSubMeshes Specifies if submeshes should be kept
  64008. * @returns The new Mesh
  64009. */
  64010. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64011. }
  64012. }
  64013. declare module BABYLON {
  64014. /**
  64015. * Class used to create a trail following a mesh
  64016. */
  64017. export class TrailMesh extends Mesh {
  64018. private _generator;
  64019. private _autoStart;
  64020. private _running;
  64021. private _diameter;
  64022. private _length;
  64023. private _sectionPolygonPointsCount;
  64024. private _sectionVectors;
  64025. private _sectionNormalVectors;
  64026. private _beforeRenderObserver;
  64027. /**
  64028. * @constructor
  64029. * @param name The value used by scene.getMeshByName() to do a lookup.
  64030. * @param generator The mesh or transform node to generate a trail.
  64031. * @param scene The scene to add this mesh to.
  64032. * @param diameter Diameter of trailing mesh. Default is 1.
  64033. * @param length Length of trailing mesh. Default is 60.
  64034. * @param autoStart Automatically start trailing mesh. Default true.
  64035. */
  64036. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64037. /**
  64038. * "TrailMesh"
  64039. * @returns "TrailMesh"
  64040. */
  64041. getClassName(): string;
  64042. private _createMesh;
  64043. /**
  64044. * Start trailing mesh.
  64045. */
  64046. start(): void;
  64047. /**
  64048. * Stop trailing mesh.
  64049. */
  64050. stop(): void;
  64051. /**
  64052. * Update trailing mesh geometry.
  64053. */
  64054. update(): void;
  64055. /**
  64056. * Returns a new TrailMesh object.
  64057. * @param name is a string, the name given to the new mesh
  64058. * @param newGenerator use new generator object for cloned trail mesh
  64059. * @returns a new mesh
  64060. */
  64061. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64062. /**
  64063. * Serializes this trail mesh
  64064. * @param serializationObject object to write serialization to
  64065. */
  64066. serialize(serializationObject: any): void;
  64067. /**
  64068. * Parses a serialized trail mesh
  64069. * @param parsedMesh the serialized mesh
  64070. * @param scene the scene to create the trail mesh in
  64071. * @returns the created trail mesh
  64072. */
  64073. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64074. }
  64075. }
  64076. declare module BABYLON {
  64077. /**
  64078. * Class containing static functions to help procedurally build meshes
  64079. */
  64080. export class TiledBoxBuilder {
  64081. /**
  64082. * Creates a box mesh
  64083. * 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)
  64084. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64086. * * 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
  64087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64088. * @param name defines the name of the mesh
  64089. * @param options defines the options used to create the mesh
  64090. * @param scene defines the hosting scene
  64091. * @returns the box mesh
  64092. */
  64093. static CreateTiledBox(name: string, options: {
  64094. pattern?: number;
  64095. width?: number;
  64096. height?: number;
  64097. depth?: number;
  64098. tileSize?: number;
  64099. tileWidth?: number;
  64100. tileHeight?: number;
  64101. alignHorizontal?: number;
  64102. alignVertical?: number;
  64103. faceUV?: Vector4[];
  64104. faceColors?: Color4[];
  64105. sideOrientation?: number;
  64106. updatable?: boolean;
  64107. }, scene?: Nullable<Scene>): Mesh;
  64108. }
  64109. }
  64110. declare module BABYLON {
  64111. /**
  64112. * Class containing static functions to help procedurally build meshes
  64113. */
  64114. export class TorusKnotBuilder {
  64115. /**
  64116. * Creates a torus knot mesh
  64117. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64118. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64119. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64120. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64122. * * 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
  64123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64124. * @param name defines the name of the mesh
  64125. * @param options defines the options used to create the mesh
  64126. * @param scene defines the hosting scene
  64127. * @returns the torus knot mesh
  64128. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64129. */
  64130. static CreateTorusKnot(name: string, options: {
  64131. radius?: number;
  64132. tube?: number;
  64133. radialSegments?: number;
  64134. tubularSegments?: number;
  64135. p?: number;
  64136. q?: number;
  64137. updatable?: boolean;
  64138. sideOrientation?: number;
  64139. frontUVs?: Vector4;
  64140. backUVs?: Vector4;
  64141. }, scene: any): Mesh;
  64142. }
  64143. }
  64144. declare module BABYLON {
  64145. /**
  64146. * Polygon
  64147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64148. */
  64149. export class Polygon {
  64150. /**
  64151. * Creates a rectangle
  64152. * @param xmin bottom X coord
  64153. * @param ymin bottom Y coord
  64154. * @param xmax top X coord
  64155. * @param ymax top Y coord
  64156. * @returns points that make the resulting rectation
  64157. */
  64158. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64159. /**
  64160. * Creates a circle
  64161. * @param radius radius of circle
  64162. * @param cx scale in x
  64163. * @param cy scale in y
  64164. * @param numberOfSides number of sides that make up the circle
  64165. * @returns points that make the resulting circle
  64166. */
  64167. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64168. /**
  64169. * Creates a polygon from input string
  64170. * @param input Input polygon data
  64171. * @returns the parsed points
  64172. */
  64173. static Parse(input: string): Vector2[];
  64174. /**
  64175. * Starts building a polygon from x and y coordinates
  64176. * @param x x coordinate
  64177. * @param y y coordinate
  64178. * @returns the started path2
  64179. */
  64180. static StartingAt(x: number, y: number): Path2;
  64181. }
  64182. /**
  64183. * Builds a polygon
  64184. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64185. */
  64186. export class PolygonMeshBuilder {
  64187. private _points;
  64188. private _outlinepoints;
  64189. private _holes;
  64190. private _name;
  64191. private _scene;
  64192. private _epoints;
  64193. private _eholes;
  64194. private _addToepoint;
  64195. /**
  64196. * Babylon reference to the earcut plugin.
  64197. */
  64198. bjsEarcut: any;
  64199. /**
  64200. * Creates a PolygonMeshBuilder
  64201. * @param name name of the builder
  64202. * @param contours Path of the polygon
  64203. * @param scene scene to add to when creating the mesh
  64204. * @param earcutInjection can be used to inject your own earcut reference
  64205. */
  64206. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64207. /**
  64208. * Adds a whole within the polygon
  64209. * @param hole Array of points defining the hole
  64210. * @returns this
  64211. */
  64212. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64213. /**
  64214. * Creates the polygon
  64215. * @param updatable If the mesh should be updatable
  64216. * @param depth The depth of the mesh created
  64217. * @returns the created mesh
  64218. */
  64219. build(updatable?: boolean, depth?: number): Mesh;
  64220. /**
  64221. * Creates the polygon
  64222. * @param depth The depth of the mesh created
  64223. * @returns the created VertexData
  64224. */
  64225. buildVertexData(depth?: number): VertexData;
  64226. /**
  64227. * Adds a side to the polygon
  64228. * @param positions points that make the polygon
  64229. * @param normals normals of the polygon
  64230. * @param uvs uvs of the polygon
  64231. * @param indices indices of the polygon
  64232. * @param bounds bounds of the polygon
  64233. * @param points points of the polygon
  64234. * @param depth depth of the polygon
  64235. * @param flip flip of the polygon
  64236. */
  64237. private addSide;
  64238. }
  64239. }
  64240. declare module BABYLON {
  64241. /**
  64242. * Class containing static functions to help procedurally build meshes
  64243. */
  64244. export class PolygonBuilder {
  64245. /**
  64246. * Creates a polygon mesh
  64247. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64248. * * 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
  64249. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64251. * * 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)
  64252. * * Remember you can only change the shape positions, not their number when updating a polygon
  64253. * @param name defines the name of the mesh
  64254. * @param options defines the options used to create the mesh
  64255. * @param scene defines the hosting scene
  64256. * @param earcutInjection can be used to inject your own earcut reference
  64257. * @returns the polygon mesh
  64258. */
  64259. static CreatePolygon(name: string, options: {
  64260. shape: Vector3[];
  64261. holes?: Vector3[][];
  64262. depth?: number;
  64263. faceUV?: Vector4[];
  64264. faceColors?: Color4[];
  64265. updatable?: boolean;
  64266. sideOrientation?: number;
  64267. frontUVs?: Vector4;
  64268. backUVs?: Vector4;
  64269. wrap?: boolean;
  64270. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64271. /**
  64272. * Creates an extruded polygon mesh, with depth in the Y direction.
  64273. * * 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)
  64274. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64275. * @param name defines the name of the mesh
  64276. * @param options defines the options used to create the mesh
  64277. * @param scene defines the hosting scene
  64278. * @param earcutInjection can be used to inject your own earcut reference
  64279. * @returns the polygon mesh
  64280. */
  64281. static ExtrudePolygon(name: string, options: {
  64282. shape: Vector3[];
  64283. holes?: Vector3[][];
  64284. depth?: number;
  64285. faceUV?: Vector4[];
  64286. faceColors?: Color4[];
  64287. updatable?: boolean;
  64288. sideOrientation?: number;
  64289. frontUVs?: Vector4;
  64290. backUVs?: Vector4;
  64291. wrap?: boolean;
  64292. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64293. }
  64294. }
  64295. declare module BABYLON {
  64296. /**
  64297. * Class containing static functions to help procedurally build meshes
  64298. */
  64299. export class LatheBuilder {
  64300. /**
  64301. * Creates lathe mesh.
  64302. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64303. * * 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
  64304. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64305. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64306. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64307. * * 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
  64308. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64309. * * 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
  64310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64311. * * 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
  64312. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64314. * @param name defines the name of the mesh
  64315. * @param options defines the options used to create the mesh
  64316. * @param scene defines the hosting scene
  64317. * @returns the lathe mesh
  64318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64319. */
  64320. static CreateLathe(name: string, options: {
  64321. shape: Vector3[];
  64322. radius?: number;
  64323. tessellation?: number;
  64324. clip?: number;
  64325. arc?: number;
  64326. closed?: boolean;
  64327. updatable?: boolean;
  64328. sideOrientation?: number;
  64329. frontUVs?: Vector4;
  64330. backUVs?: Vector4;
  64331. cap?: number;
  64332. invertUV?: boolean;
  64333. }, scene?: Nullable<Scene>): Mesh;
  64334. }
  64335. }
  64336. declare module BABYLON {
  64337. /**
  64338. * Class containing static functions to help procedurally build meshes
  64339. */
  64340. export class TiledPlaneBuilder {
  64341. /**
  64342. * Creates a tiled plane mesh
  64343. * * The parameter `pattern` will, depending on value, do nothing or
  64344. * * * flip (reflect about central vertical) alternate tiles across and up
  64345. * * * flip every tile on alternate rows
  64346. * * * rotate (180 degs) alternate tiles across and up
  64347. * * * rotate every tile on alternate rows
  64348. * * * flip and rotate alternate tiles across and up
  64349. * * * flip and rotate every tile on alternate rows
  64350. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64351. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64352. * * 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
  64353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64354. * * 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)
  64355. * * 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)
  64356. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64357. * @param name defines the name of the mesh
  64358. * @param options defines the options used to create the mesh
  64359. * @param scene defines the hosting scene
  64360. * @returns the box mesh
  64361. */
  64362. static CreateTiledPlane(name: string, options: {
  64363. pattern?: number;
  64364. tileSize?: number;
  64365. tileWidth?: number;
  64366. tileHeight?: number;
  64367. size?: number;
  64368. width?: number;
  64369. height?: number;
  64370. alignHorizontal?: number;
  64371. alignVertical?: number;
  64372. sideOrientation?: number;
  64373. frontUVs?: Vector4;
  64374. backUVs?: Vector4;
  64375. updatable?: boolean;
  64376. }, scene?: Nullable<Scene>): Mesh;
  64377. }
  64378. }
  64379. declare module BABYLON {
  64380. /**
  64381. * Class containing static functions to help procedurally build meshes
  64382. */
  64383. export class TubeBuilder {
  64384. /**
  64385. * Creates a tube mesh.
  64386. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64387. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64388. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64389. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64390. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64391. * * 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)
  64392. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64393. * * 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
  64394. * * 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
  64395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64396. * * 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
  64397. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64399. * @param name defines the name of the mesh
  64400. * @param options defines the options used to create the mesh
  64401. * @param scene defines the hosting scene
  64402. * @returns the tube mesh
  64403. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64404. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64405. */
  64406. static CreateTube(name: string, options: {
  64407. path: Vector3[];
  64408. radius?: number;
  64409. tessellation?: number;
  64410. radiusFunction?: {
  64411. (i: number, distance: number): number;
  64412. };
  64413. cap?: number;
  64414. arc?: number;
  64415. updatable?: boolean;
  64416. sideOrientation?: number;
  64417. frontUVs?: Vector4;
  64418. backUVs?: Vector4;
  64419. instance?: Mesh;
  64420. invertUV?: boolean;
  64421. }, scene?: Nullable<Scene>): Mesh;
  64422. }
  64423. }
  64424. declare module BABYLON {
  64425. /**
  64426. * Class containing static functions to help procedurally build meshes
  64427. */
  64428. export class IcoSphereBuilder {
  64429. /**
  64430. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64431. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64432. * * 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`)
  64433. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64434. * * 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
  64435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64436. * * 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
  64437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64438. * @param name defines the name of the mesh
  64439. * @param options defines the options used to create the mesh
  64440. * @param scene defines the hosting scene
  64441. * @returns the icosahedron mesh
  64442. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64443. */
  64444. static CreateIcoSphere(name: string, options: {
  64445. radius?: number;
  64446. radiusX?: number;
  64447. radiusY?: number;
  64448. radiusZ?: number;
  64449. flat?: boolean;
  64450. subdivisions?: number;
  64451. sideOrientation?: number;
  64452. frontUVs?: Vector4;
  64453. backUVs?: Vector4;
  64454. updatable?: boolean;
  64455. }, scene?: Nullable<Scene>): Mesh;
  64456. }
  64457. }
  64458. declare module BABYLON {
  64459. /**
  64460. * Class containing static functions to help procedurally build meshes
  64461. */
  64462. export class DecalBuilder {
  64463. /**
  64464. * Creates a decal mesh.
  64465. * 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
  64466. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64467. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64468. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64469. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64470. * @param name defines the name of the mesh
  64471. * @param sourceMesh defines the mesh where the decal must be applied
  64472. * @param options defines the options used to create the mesh
  64473. * @param scene defines the hosting scene
  64474. * @returns the decal mesh
  64475. * @see https://doc.babylonjs.com/how_to/decals
  64476. */
  64477. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64478. position?: Vector3;
  64479. normal?: Vector3;
  64480. size?: Vector3;
  64481. angle?: number;
  64482. }): Mesh;
  64483. }
  64484. }
  64485. declare module BABYLON {
  64486. /**
  64487. * Class containing static functions to help procedurally build meshes
  64488. */
  64489. export class MeshBuilder {
  64490. /**
  64491. * Creates a box mesh
  64492. * * The parameter `size` sets the size (float) of each box side (default 1)
  64493. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64494. * * 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)
  64495. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64497. * * 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
  64498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64499. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64500. * @param name defines the name of the mesh
  64501. * @param options defines the options used to create the mesh
  64502. * @param scene defines the hosting scene
  64503. * @returns the box mesh
  64504. */
  64505. static CreateBox(name: string, options: {
  64506. size?: number;
  64507. width?: number;
  64508. height?: number;
  64509. depth?: number;
  64510. faceUV?: Vector4[];
  64511. faceColors?: Color4[];
  64512. sideOrientation?: number;
  64513. frontUVs?: Vector4;
  64514. backUVs?: Vector4;
  64515. wrap?: boolean;
  64516. topBaseAt?: number;
  64517. bottomBaseAt?: number;
  64518. updatable?: boolean;
  64519. }, scene?: Nullable<Scene>): Mesh;
  64520. /**
  64521. * Creates a tiled box mesh
  64522. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64524. * @param name defines the name of the mesh
  64525. * @param options defines the options used to create the mesh
  64526. * @param scene defines the hosting scene
  64527. * @returns the tiled box mesh
  64528. */
  64529. static CreateTiledBox(name: string, options: {
  64530. pattern?: number;
  64531. size?: number;
  64532. width?: number;
  64533. height?: number;
  64534. depth: number;
  64535. tileSize?: number;
  64536. tileWidth?: number;
  64537. tileHeight?: number;
  64538. faceUV?: Vector4[];
  64539. faceColors?: Color4[];
  64540. alignHorizontal?: number;
  64541. alignVertical?: number;
  64542. sideOrientation?: number;
  64543. updatable?: boolean;
  64544. }, scene?: Nullable<Scene>): Mesh;
  64545. /**
  64546. * Creates a sphere mesh
  64547. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64548. * * 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`)
  64549. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64550. * * 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
  64551. * * 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)
  64552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64553. * * 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
  64554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64555. * @param name defines the name of the mesh
  64556. * @param options defines the options used to create the mesh
  64557. * @param scene defines the hosting scene
  64558. * @returns the sphere mesh
  64559. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64560. */
  64561. static CreateSphere(name: string, options: {
  64562. segments?: number;
  64563. diameter?: number;
  64564. diameterX?: number;
  64565. diameterY?: number;
  64566. diameterZ?: number;
  64567. arc?: number;
  64568. slice?: number;
  64569. sideOrientation?: number;
  64570. frontUVs?: Vector4;
  64571. backUVs?: Vector4;
  64572. updatable?: boolean;
  64573. }, scene?: Nullable<Scene>): Mesh;
  64574. /**
  64575. * Creates a plane polygonal mesh. By default, this is a disc
  64576. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64577. * * 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
  64578. * * 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
  64579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64580. * * 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
  64581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64582. * @param name defines the name of the mesh
  64583. * @param options defines the options used to create the mesh
  64584. * @param scene defines the hosting scene
  64585. * @returns the plane polygonal mesh
  64586. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64587. */
  64588. static CreateDisc(name: string, options: {
  64589. radius?: number;
  64590. tessellation?: number;
  64591. arc?: number;
  64592. updatable?: boolean;
  64593. sideOrientation?: number;
  64594. frontUVs?: Vector4;
  64595. backUVs?: Vector4;
  64596. }, scene?: Nullable<Scene>): Mesh;
  64597. /**
  64598. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64599. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64600. * * 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`)
  64601. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64602. * * 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
  64603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64604. * * 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
  64605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64606. * @param name defines the name of the mesh
  64607. * @param options defines the options used to create the mesh
  64608. * @param scene defines the hosting scene
  64609. * @returns the icosahedron mesh
  64610. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64611. */
  64612. static CreateIcoSphere(name: string, options: {
  64613. radius?: number;
  64614. radiusX?: number;
  64615. radiusY?: number;
  64616. radiusZ?: number;
  64617. flat?: boolean;
  64618. subdivisions?: number;
  64619. sideOrientation?: number;
  64620. frontUVs?: Vector4;
  64621. backUVs?: Vector4;
  64622. updatable?: boolean;
  64623. }, scene?: Nullable<Scene>): Mesh;
  64624. /**
  64625. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64626. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64627. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64628. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64629. * * 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
  64630. * * 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
  64631. * * 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
  64632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64633. * * 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
  64634. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64635. * * 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
  64636. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64637. * * 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
  64638. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64640. * @param name defines the name of the mesh
  64641. * @param options defines the options used to create the mesh
  64642. * @param scene defines the hosting scene
  64643. * @returns the ribbon mesh
  64644. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64645. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64646. */
  64647. static CreateRibbon(name: string, options: {
  64648. pathArray: Vector3[][];
  64649. closeArray?: boolean;
  64650. closePath?: boolean;
  64651. offset?: number;
  64652. updatable?: boolean;
  64653. sideOrientation?: number;
  64654. frontUVs?: Vector4;
  64655. backUVs?: Vector4;
  64656. instance?: Mesh;
  64657. invertUV?: boolean;
  64658. uvs?: Vector2[];
  64659. colors?: Color4[];
  64660. }, scene?: Nullable<Scene>): Mesh;
  64661. /**
  64662. * Creates a cylinder or a cone mesh
  64663. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64664. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64665. * * 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.
  64666. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64667. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64668. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64669. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64670. * * 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).
  64671. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64672. * * 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).
  64673. * * 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
  64674. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64675. * * 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
  64676. * * 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.
  64677. * * If `enclose` is false, a ring surface is one element.
  64678. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64679. * * 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
  64680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64681. * * 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
  64682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64683. * @param name defines the name of the mesh
  64684. * @param options defines the options used to create the mesh
  64685. * @param scene defines the hosting scene
  64686. * @returns the cylinder mesh
  64687. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64688. */
  64689. static CreateCylinder(name: string, options: {
  64690. height?: number;
  64691. diameterTop?: number;
  64692. diameterBottom?: number;
  64693. diameter?: number;
  64694. tessellation?: number;
  64695. subdivisions?: number;
  64696. arc?: number;
  64697. faceColors?: Color4[];
  64698. faceUV?: Vector4[];
  64699. updatable?: boolean;
  64700. hasRings?: boolean;
  64701. enclose?: boolean;
  64702. cap?: number;
  64703. sideOrientation?: number;
  64704. frontUVs?: Vector4;
  64705. backUVs?: Vector4;
  64706. }, scene?: Nullable<Scene>): Mesh;
  64707. /**
  64708. * Creates a torus mesh
  64709. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64710. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64711. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64713. * * 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
  64714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64715. * @param name defines the name of the mesh
  64716. * @param options defines the options used to create the mesh
  64717. * @param scene defines the hosting scene
  64718. * @returns the torus mesh
  64719. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64720. */
  64721. static CreateTorus(name: string, options: {
  64722. diameter?: number;
  64723. thickness?: number;
  64724. tessellation?: number;
  64725. updatable?: boolean;
  64726. sideOrientation?: number;
  64727. frontUVs?: Vector4;
  64728. backUVs?: Vector4;
  64729. }, scene?: Nullable<Scene>): Mesh;
  64730. /**
  64731. * Creates a torus knot mesh
  64732. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64733. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64734. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64735. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64737. * * 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
  64738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64739. * @param name defines the name of the mesh
  64740. * @param options defines the options used to create the mesh
  64741. * @param scene defines the hosting scene
  64742. * @returns the torus knot mesh
  64743. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64744. */
  64745. static CreateTorusKnot(name: string, options: {
  64746. radius?: number;
  64747. tube?: number;
  64748. radialSegments?: number;
  64749. tubularSegments?: number;
  64750. p?: number;
  64751. q?: number;
  64752. updatable?: boolean;
  64753. sideOrientation?: number;
  64754. frontUVs?: Vector4;
  64755. backUVs?: Vector4;
  64756. }, scene?: Nullable<Scene>): Mesh;
  64757. /**
  64758. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64759. * * 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
  64760. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64761. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64762. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64763. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64764. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64765. * * 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
  64766. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64769. * @param name defines the name of the new line system
  64770. * @param options defines the options used to create the line system
  64771. * @param scene defines the hosting scene
  64772. * @returns a new line system mesh
  64773. */
  64774. static CreateLineSystem(name: string, options: {
  64775. lines: Vector3[][];
  64776. updatable?: boolean;
  64777. instance?: Nullable<LinesMesh>;
  64778. colors?: Nullable<Color4[][]>;
  64779. useVertexAlpha?: boolean;
  64780. }, scene: Nullable<Scene>): LinesMesh;
  64781. /**
  64782. * Creates a line mesh
  64783. * 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
  64784. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64785. * * The parameter `points` is an array successive Vector3
  64786. * * 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
  64787. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64788. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64789. * * When updating an instance, remember that only point positions can change, not the number of points
  64790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64792. * @param name defines the name of the new line system
  64793. * @param options defines the options used to create the line system
  64794. * @param scene defines the hosting scene
  64795. * @returns a new line mesh
  64796. */
  64797. static CreateLines(name: string, options: {
  64798. points: Vector3[];
  64799. updatable?: boolean;
  64800. instance?: Nullable<LinesMesh>;
  64801. colors?: Color4[];
  64802. useVertexAlpha?: boolean;
  64803. }, scene?: Nullable<Scene>): LinesMesh;
  64804. /**
  64805. * Creates a dashed line mesh
  64806. * * 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
  64807. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64808. * * The parameter `points` is an array successive Vector3
  64809. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64810. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64811. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64812. * * 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
  64813. * * When updating an instance, remember that only point positions can change, not the number of points
  64814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64815. * @param name defines the name of the mesh
  64816. * @param options defines the options used to create the mesh
  64817. * @param scene defines the hosting scene
  64818. * @returns the dashed line mesh
  64819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64820. */
  64821. static CreateDashedLines(name: string, options: {
  64822. points: Vector3[];
  64823. dashSize?: number;
  64824. gapSize?: number;
  64825. dashNb?: number;
  64826. updatable?: boolean;
  64827. instance?: LinesMesh;
  64828. }, scene?: Nullable<Scene>): LinesMesh;
  64829. /**
  64830. * 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.
  64831. * * 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.
  64832. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64833. * * 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.
  64834. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64835. * * 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
  64836. * * 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
  64837. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64839. * * 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
  64840. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64842. * @param name defines the name of the mesh
  64843. * @param options defines the options used to create the mesh
  64844. * @param scene defines the hosting scene
  64845. * @returns the extruded shape mesh
  64846. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64848. */
  64849. static ExtrudeShape(name: string, options: {
  64850. shape: Vector3[];
  64851. path: Vector3[];
  64852. scale?: number;
  64853. rotation?: number;
  64854. cap?: number;
  64855. updatable?: boolean;
  64856. sideOrientation?: number;
  64857. frontUVs?: Vector4;
  64858. backUVs?: Vector4;
  64859. instance?: Mesh;
  64860. invertUV?: boolean;
  64861. }, scene?: Nullable<Scene>): Mesh;
  64862. /**
  64863. * Creates an custom extruded shape mesh.
  64864. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64865. * * 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.
  64866. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64867. * * 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
  64868. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64869. * * 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
  64870. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64871. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64872. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64873. * * 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
  64874. * * 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
  64875. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64877. * * 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
  64878. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64880. * @param name defines the name of the mesh
  64881. * @param options defines the options used to create the mesh
  64882. * @param scene defines the hosting scene
  64883. * @returns the custom extruded shape mesh
  64884. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64885. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64887. */
  64888. static ExtrudeShapeCustom(name: string, options: {
  64889. shape: Vector3[];
  64890. path: Vector3[];
  64891. scaleFunction?: any;
  64892. rotationFunction?: any;
  64893. ribbonCloseArray?: boolean;
  64894. ribbonClosePath?: boolean;
  64895. cap?: number;
  64896. updatable?: boolean;
  64897. sideOrientation?: number;
  64898. frontUVs?: Vector4;
  64899. backUVs?: Vector4;
  64900. instance?: Mesh;
  64901. invertUV?: boolean;
  64902. }, scene?: Nullable<Scene>): Mesh;
  64903. /**
  64904. * Creates lathe mesh.
  64905. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64906. * * 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
  64907. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64908. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64909. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64910. * * 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
  64911. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64912. * * 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
  64913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64914. * * 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
  64915. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64917. * @param name defines the name of the mesh
  64918. * @param options defines the options used to create the mesh
  64919. * @param scene defines the hosting scene
  64920. * @returns the lathe mesh
  64921. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64922. */
  64923. static CreateLathe(name: string, options: {
  64924. shape: Vector3[];
  64925. radius?: number;
  64926. tessellation?: number;
  64927. clip?: number;
  64928. arc?: number;
  64929. closed?: boolean;
  64930. updatable?: boolean;
  64931. sideOrientation?: number;
  64932. frontUVs?: Vector4;
  64933. backUVs?: Vector4;
  64934. cap?: number;
  64935. invertUV?: boolean;
  64936. }, scene?: Nullable<Scene>): Mesh;
  64937. /**
  64938. * Creates a tiled plane mesh
  64939. * * You can set a limited pattern arrangement with the tiles
  64940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64941. * * 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
  64942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64943. * @param name defines the name of the mesh
  64944. * @param options defines the options used to create the mesh
  64945. * @param scene defines the hosting scene
  64946. * @returns the plane mesh
  64947. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64948. */
  64949. static CreateTiledPlane(name: string, options: {
  64950. pattern?: number;
  64951. tileSize?: number;
  64952. tileWidth?: number;
  64953. tileHeight?: number;
  64954. size?: number;
  64955. width?: number;
  64956. height?: number;
  64957. alignHorizontal?: number;
  64958. alignVertical?: number;
  64959. sideOrientation?: number;
  64960. frontUVs?: Vector4;
  64961. backUVs?: Vector4;
  64962. updatable?: boolean;
  64963. }, scene?: Nullable<Scene>): Mesh;
  64964. /**
  64965. * Creates a plane mesh
  64966. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64967. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64968. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64970. * * 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
  64971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64972. * @param name defines the name of the mesh
  64973. * @param options defines the options used to create the mesh
  64974. * @param scene defines the hosting scene
  64975. * @returns the plane mesh
  64976. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64977. */
  64978. static CreatePlane(name: string, options: {
  64979. size?: number;
  64980. width?: number;
  64981. height?: number;
  64982. sideOrientation?: number;
  64983. frontUVs?: Vector4;
  64984. backUVs?: Vector4;
  64985. updatable?: boolean;
  64986. sourcePlane?: Plane;
  64987. }, scene?: Nullable<Scene>): Mesh;
  64988. /**
  64989. * Creates a ground mesh
  64990. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64991. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  64997. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64998. */
  64999. static CreateGround(name: string, options: {
  65000. width?: number;
  65001. height?: number;
  65002. subdivisions?: number;
  65003. subdivisionsX?: number;
  65004. subdivisionsY?: number;
  65005. updatable?: boolean;
  65006. }, scene?: Nullable<Scene>): Mesh;
  65007. /**
  65008. * Creates a tiled ground mesh
  65009. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65010. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65011. * * 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
  65012. * * 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
  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 tiled ground mesh
  65018. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65019. */
  65020. static CreateTiledGround(name: string, options: {
  65021. xmin: number;
  65022. zmin: number;
  65023. xmax: number;
  65024. zmax: number;
  65025. subdivisions?: {
  65026. w: number;
  65027. h: number;
  65028. };
  65029. precision?: {
  65030. w: number;
  65031. h: number;
  65032. };
  65033. updatable?: boolean;
  65034. }, scene?: Nullable<Scene>): Mesh;
  65035. /**
  65036. * Creates a ground mesh from a height map
  65037. * * The parameter `url` sets the URL of the height map image resource.
  65038. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65039. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65040. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65041. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65042. * * 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.
  65043. * * 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).
  65044. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65046. * @param name defines the name of the mesh
  65047. * @param url defines the url to the height map
  65048. * @param options defines the options used to create the mesh
  65049. * @param scene defines the hosting scene
  65050. * @returns the ground mesh
  65051. * @see https://doc.babylonjs.com/babylon101/height_map
  65052. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65053. */
  65054. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65055. width?: number;
  65056. height?: number;
  65057. subdivisions?: number;
  65058. minHeight?: number;
  65059. maxHeight?: number;
  65060. colorFilter?: Color3;
  65061. alphaFilter?: number;
  65062. updatable?: boolean;
  65063. onReady?: (mesh: GroundMesh) => void;
  65064. }, scene?: Nullable<Scene>): GroundMesh;
  65065. /**
  65066. * Creates a polygon mesh
  65067. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65068. * * 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
  65069. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65071. * * 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)
  65072. * * Remember you can only change the shape positions, not their number when updating a polygon
  65073. * @param name defines the name of the mesh
  65074. * @param options defines the options used to create the mesh
  65075. * @param scene defines the hosting scene
  65076. * @param earcutInjection can be used to inject your own earcut reference
  65077. * @returns the polygon mesh
  65078. */
  65079. static CreatePolygon(name: string, options: {
  65080. shape: Vector3[];
  65081. holes?: Vector3[][];
  65082. depth?: number;
  65083. faceUV?: Vector4[];
  65084. faceColors?: Color4[];
  65085. updatable?: boolean;
  65086. sideOrientation?: number;
  65087. frontUVs?: Vector4;
  65088. backUVs?: Vector4;
  65089. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65090. /**
  65091. * Creates an extruded polygon mesh, with depth in the Y direction.
  65092. * * 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)
  65093. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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 ExtrudePolygon(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 a tube mesh.
  65113. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65114. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65115. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65116. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65117. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65118. * * 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)
  65119. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65120. * * 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
  65121. * * 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
  65122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65123. * * 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
  65124. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65126. * @param name defines the name of the mesh
  65127. * @param options defines the options used to create the mesh
  65128. * @param scene defines the hosting scene
  65129. * @returns the tube mesh
  65130. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65131. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65132. */
  65133. static CreateTube(name: string, options: {
  65134. path: Vector3[];
  65135. radius?: number;
  65136. tessellation?: number;
  65137. radiusFunction?: {
  65138. (i: number, distance: number): number;
  65139. };
  65140. cap?: number;
  65141. arc?: number;
  65142. updatable?: boolean;
  65143. sideOrientation?: number;
  65144. frontUVs?: Vector4;
  65145. backUVs?: Vector4;
  65146. instance?: Mesh;
  65147. invertUV?: boolean;
  65148. }, scene?: Nullable<Scene>): Mesh;
  65149. /**
  65150. * Creates a polyhedron mesh
  65151. * * 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
  65152. * * The parameter `size` (positive float, default 1) sets the polygon size
  65153. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65154. * * 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`
  65155. * * 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
  65156. * * 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)`)
  65157. * * 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
  65158. * * 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
  65159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65160. * * 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
  65161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65162. * @param name defines the name of the mesh
  65163. * @param options defines the options used to create the mesh
  65164. * @param scene defines the hosting scene
  65165. * @returns the polyhedron mesh
  65166. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65167. */
  65168. static CreatePolyhedron(name: string, options: {
  65169. type?: number;
  65170. size?: number;
  65171. sizeX?: number;
  65172. sizeY?: number;
  65173. sizeZ?: number;
  65174. custom?: any;
  65175. faceUV?: Vector4[];
  65176. faceColors?: Color4[];
  65177. flat?: boolean;
  65178. updatable?: boolean;
  65179. sideOrientation?: number;
  65180. frontUVs?: Vector4;
  65181. backUVs?: Vector4;
  65182. }, scene?: Nullable<Scene>): Mesh;
  65183. /**
  65184. * Creates a decal mesh.
  65185. * 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
  65186. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65187. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65188. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65189. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65190. * @param name defines the name of the mesh
  65191. * @param sourceMesh defines the mesh where the decal must be applied
  65192. * @param options defines the options used to create the mesh
  65193. * @param scene defines the hosting scene
  65194. * @returns the decal mesh
  65195. * @see https://doc.babylonjs.com/how_to/decals
  65196. */
  65197. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65198. position?: Vector3;
  65199. normal?: Vector3;
  65200. size?: Vector3;
  65201. angle?: number;
  65202. }): Mesh;
  65203. }
  65204. }
  65205. declare module BABYLON {
  65206. /**
  65207. * A simplifier interface for future simplification implementations
  65208. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65209. */
  65210. export interface ISimplifier {
  65211. /**
  65212. * Simplification of a given mesh according to the given settings.
  65213. * Since this requires computation, it is assumed that the function runs async.
  65214. * @param settings The settings of the simplification, including quality and distance
  65215. * @param successCallback A callback that will be called after the mesh was simplified.
  65216. * @param errorCallback in case of an error, this callback will be called. optional.
  65217. */
  65218. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65219. }
  65220. /**
  65221. * Expected simplification settings.
  65222. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65223. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65224. */
  65225. export interface ISimplificationSettings {
  65226. /**
  65227. * Gets or sets the expected quality
  65228. */
  65229. quality: number;
  65230. /**
  65231. * Gets or sets the distance when this optimized version should be used
  65232. */
  65233. distance: number;
  65234. /**
  65235. * Gets an already optimized mesh
  65236. */
  65237. optimizeMesh?: boolean;
  65238. }
  65239. /**
  65240. * Class used to specify simplification options
  65241. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65242. */
  65243. export class SimplificationSettings implements ISimplificationSettings {
  65244. /** expected quality */
  65245. quality: number;
  65246. /** distance when this optimized version should be used */
  65247. distance: number;
  65248. /** already optimized mesh */
  65249. optimizeMesh?: boolean | undefined;
  65250. /**
  65251. * Creates a SimplificationSettings
  65252. * @param quality expected quality
  65253. * @param distance distance when this optimized version should be used
  65254. * @param optimizeMesh already optimized mesh
  65255. */
  65256. constructor(
  65257. /** expected quality */
  65258. quality: number,
  65259. /** distance when this optimized version should be used */
  65260. distance: number,
  65261. /** already optimized mesh */
  65262. optimizeMesh?: boolean | undefined);
  65263. }
  65264. /**
  65265. * Interface used to define a simplification task
  65266. */
  65267. export interface ISimplificationTask {
  65268. /**
  65269. * Array of settings
  65270. */
  65271. settings: Array<ISimplificationSettings>;
  65272. /**
  65273. * Simplification type
  65274. */
  65275. simplificationType: SimplificationType;
  65276. /**
  65277. * Mesh to simplify
  65278. */
  65279. mesh: Mesh;
  65280. /**
  65281. * Callback called on success
  65282. */
  65283. successCallback?: () => void;
  65284. /**
  65285. * Defines if parallel processing can be used
  65286. */
  65287. parallelProcessing: boolean;
  65288. }
  65289. /**
  65290. * Queue used to order the simplification tasks
  65291. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65292. */
  65293. export class SimplificationQueue {
  65294. private _simplificationArray;
  65295. /**
  65296. * Gets a boolean indicating that the process is still running
  65297. */
  65298. running: boolean;
  65299. /**
  65300. * Creates a new queue
  65301. */
  65302. constructor();
  65303. /**
  65304. * Adds a new simplification task
  65305. * @param task defines a task to add
  65306. */
  65307. addTask(task: ISimplificationTask): void;
  65308. /**
  65309. * Execute next task
  65310. */
  65311. executeNext(): void;
  65312. /**
  65313. * Execute a simplification task
  65314. * @param task defines the task to run
  65315. */
  65316. runSimplification(task: ISimplificationTask): void;
  65317. private getSimplifier;
  65318. }
  65319. /**
  65320. * The implemented types of simplification
  65321. * At the moment only Quadratic Error Decimation is implemented
  65322. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65323. */
  65324. export enum SimplificationType {
  65325. /** Quadratic error decimation */
  65326. QUADRATIC = 0
  65327. }
  65328. /**
  65329. * An implementation of the Quadratic Error simplification algorithm.
  65330. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65331. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65332. * @author RaananW
  65333. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65334. */
  65335. export class QuadraticErrorSimplification implements ISimplifier {
  65336. private _mesh;
  65337. private triangles;
  65338. private vertices;
  65339. private references;
  65340. private _reconstructedMesh;
  65341. /** Gets or sets the number pf sync interations */
  65342. syncIterations: number;
  65343. /** Gets or sets the aggressiveness of the simplifier */
  65344. aggressiveness: number;
  65345. /** Gets or sets the number of allowed iterations for decimation */
  65346. decimationIterations: number;
  65347. /** Gets or sets the espilon to use for bounding box computation */
  65348. boundingBoxEpsilon: number;
  65349. /**
  65350. * Creates a new QuadraticErrorSimplification
  65351. * @param _mesh defines the target mesh
  65352. */
  65353. constructor(_mesh: Mesh);
  65354. /**
  65355. * Simplification of a given mesh according to the given settings.
  65356. * Since this requires computation, it is assumed that the function runs async.
  65357. * @param settings The settings of the simplification, including quality and distance
  65358. * @param successCallback A callback that will be called after the mesh was simplified.
  65359. */
  65360. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65361. private runDecimation;
  65362. private initWithMesh;
  65363. private init;
  65364. private reconstructMesh;
  65365. private initDecimatedMesh;
  65366. private isFlipped;
  65367. private updateTriangles;
  65368. private identifyBorder;
  65369. private updateMesh;
  65370. private vertexError;
  65371. private calculateError;
  65372. }
  65373. }
  65374. declare module BABYLON {
  65375. interface Scene {
  65376. /** @hidden (Backing field) */
  65377. _simplificationQueue: SimplificationQueue;
  65378. /**
  65379. * Gets or sets the simplification queue attached to the scene
  65380. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65381. */
  65382. simplificationQueue: SimplificationQueue;
  65383. }
  65384. interface Mesh {
  65385. /**
  65386. * Simplify the mesh according to the given array of settings.
  65387. * Function will return immediately and will simplify async
  65388. * @param settings a collection of simplification settings
  65389. * @param parallelProcessing should all levels calculate parallel or one after the other
  65390. * @param simplificationType the type of simplification to run
  65391. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65392. * @returns the current mesh
  65393. */
  65394. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65395. }
  65396. /**
  65397. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65398. * created in a scene
  65399. */
  65400. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65401. /**
  65402. * The component name helpfull to identify the component in the list of scene components.
  65403. */
  65404. readonly name: string;
  65405. /**
  65406. * The scene the component belongs to.
  65407. */
  65408. scene: Scene;
  65409. /**
  65410. * Creates a new instance of the component for the given scene
  65411. * @param scene Defines the scene to register the component in
  65412. */
  65413. constructor(scene: Scene);
  65414. /**
  65415. * Registers the component in a given scene
  65416. */
  65417. register(): void;
  65418. /**
  65419. * Rebuilds the elements related to this component in case of
  65420. * context lost for instance.
  65421. */
  65422. rebuild(): void;
  65423. /**
  65424. * Disposes the component and the associated ressources
  65425. */
  65426. dispose(): void;
  65427. private _beforeCameraUpdate;
  65428. }
  65429. }
  65430. declare module BABYLON {
  65431. interface Mesh {
  65432. /**
  65433. * Creates a new thin instance
  65434. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65435. * @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
  65436. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65437. */
  65438. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65439. /**
  65440. * Adds the transformation (matrix) of the current mesh as a thin instance
  65441. * @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
  65442. * @returns the thin instance index number
  65443. */
  65444. thinInstanceAddSelf(refresh: boolean): number;
  65445. /**
  65446. * Registers a custom attribute to be used with thin instances
  65447. * @param kind name of the attribute
  65448. * @param stride size in floats of the attribute
  65449. */
  65450. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65451. /**
  65452. * Sets the matrix of a thin instance
  65453. * @param index index of the thin instance
  65454. * @param matrix matrix to set
  65455. * @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
  65456. */
  65457. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65458. /**
  65459. * Sets the value of a custom attribute for a thin instance
  65460. * @param kind name of the attribute
  65461. * @param index index of the thin instance
  65462. * @param value value to set
  65463. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  65464. */
  65465. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65466. /**
  65467. * 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.
  65468. */
  65469. thinInstanceCount: number;
  65470. /**
  65471. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65472. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65473. * @param buffer buffer to set
  65474. * @param stride size in floats of each value of the buffer
  65475. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65476. */
  65477. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65478. /**
  65479. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65480. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65481. */
  65482. thinInstanceBufferUpdated(kind: string): void;
  65483. /**
  65484. * Refreshes the bounding info, taking into account all the thin instances defined
  65485. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65486. */
  65487. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65488. /** @hidden */
  65489. _thinInstanceInitializeUserStorage(): void;
  65490. /** @hidden */
  65491. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65492. /** @hidden */
  65493. _userThinInstanceBuffersStorage: {
  65494. data: {
  65495. [key: string]: Float32Array;
  65496. };
  65497. sizes: {
  65498. [key: string]: number;
  65499. };
  65500. vertexBuffers: {
  65501. [key: string]: Nullable<VertexBuffer>;
  65502. };
  65503. strides: {
  65504. [key: string]: number;
  65505. };
  65506. };
  65507. }
  65508. }
  65509. declare module BABYLON {
  65510. /**
  65511. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65512. */
  65513. export interface INavigationEnginePlugin {
  65514. /**
  65515. * plugin name
  65516. */
  65517. name: string;
  65518. /**
  65519. * Creates a navigation mesh
  65520. * @param meshes array of all the geometry used to compute the navigatio mesh
  65521. * @param parameters bunch of parameters used to filter geometry
  65522. */
  65523. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65524. /**
  65525. * Create a navigation mesh debug mesh
  65526. * @param scene is where the mesh will be added
  65527. * @returns debug display mesh
  65528. */
  65529. createDebugNavMesh(scene: Scene): Mesh;
  65530. /**
  65531. * Get a navigation mesh constrained position, closest to the parameter position
  65532. * @param position world position
  65533. * @returns the closest point to position constrained by the navigation mesh
  65534. */
  65535. getClosestPoint(position: Vector3): Vector3;
  65536. /**
  65537. * Get a navigation mesh constrained position, closest to the parameter position
  65538. * @param position world position
  65539. * @param result output the closest point to position constrained by the navigation mesh
  65540. */
  65541. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65542. /**
  65543. * Get a navigation mesh constrained position, within a particular radius
  65544. * @param position world position
  65545. * @param maxRadius the maximum distance to the constrained world position
  65546. * @returns the closest point to position constrained by the navigation mesh
  65547. */
  65548. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65549. /**
  65550. * Get a navigation mesh constrained position, within a particular radius
  65551. * @param position world position
  65552. * @param maxRadius the maximum distance to the constrained world position
  65553. * @param result output the closest point to position constrained by the navigation mesh
  65554. */
  65555. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65556. /**
  65557. * Compute the final position from a segment made of destination-position
  65558. * @param position world position
  65559. * @param destination world position
  65560. * @returns the resulting point along the navmesh
  65561. */
  65562. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65563. /**
  65564. * Compute the final position from a segment made of destination-position
  65565. * @param position world position
  65566. * @param destination world position
  65567. * @param result output the resulting point along the navmesh
  65568. */
  65569. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65570. /**
  65571. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65572. * @param start world position
  65573. * @param end world position
  65574. * @returns array containing world position composing the path
  65575. */
  65576. computePath(start: Vector3, end: Vector3): Vector3[];
  65577. /**
  65578. * If this plugin is supported
  65579. * @returns true if plugin is supported
  65580. */
  65581. isSupported(): boolean;
  65582. /**
  65583. * Create a new Crowd so you can add agents
  65584. * @param maxAgents the maximum agent count in the crowd
  65585. * @param maxAgentRadius the maximum radius an agent can have
  65586. * @param scene to attach the crowd to
  65587. * @returns the crowd you can add agents to
  65588. */
  65589. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65590. /**
  65591. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65592. * The queries will try to find a solution within those bounds
  65593. * default is (1,1,1)
  65594. * @param extent x,y,z value that define the extent around the queries point of reference
  65595. */
  65596. setDefaultQueryExtent(extent: Vector3): void;
  65597. /**
  65598. * Get the Bounding box extent specified by setDefaultQueryExtent
  65599. * @returns the box extent values
  65600. */
  65601. getDefaultQueryExtent(): Vector3;
  65602. /**
  65603. * build the navmesh from a previously saved state using getNavmeshData
  65604. * @param data the Uint8Array returned by getNavmeshData
  65605. */
  65606. buildFromNavmeshData(data: Uint8Array): void;
  65607. /**
  65608. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65609. * @returns data the Uint8Array that can be saved and reused
  65610. */
  65611. getNavmeshData(): Uint8Array;
  65612. /**
  65613. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65614. * @param result output the box extent values
  65615. */
  65616. getDefaultQueryExtentToRef(result: Vector3): void;
  65617. /**
  65618. * Release all resources
  65619. */
  65620. dispose(): void;
  65621. }
  65622. /**
  65623. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65624. */
  65625. export interface ICrowd {
  65626. /**
  65627. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65628. * You can attach anything to that node. The node position is updated in the scene update tick.
  65629. * @param pos world position that will be constrained by the navigation mesh
  65630. * @param parameters agent parameters
  65631. * @param transform hooked to the agent that will be update by the scene
  65632. * @returns agent index
  65633. */
  65634. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65635. /**
  65636. * Returns the agent position in world space
  65637. * @param index agent index returned by addAgent
  65638. * @returns world space position
  65639. */
  65640. getAgentPosition(index: number): Vector3;
  65641. /**
  65642. * Gets the agent position result in world space
  65643. * @param index agent index returned by addAgent
  65644. * @param result output world space position
  65645. */
  65646. getAgentPositionToRef(index: number, result: Vector3): void;
  65647. /**
  65648. * Gets the agent velocity in world space
  65649. * @param index agent index returned by addAgent
  65650. * @returns world space velocity
  65651. */
  65652. getAgentVelocity(index: number): Vector3;
  65653. /**
  65654. * Gets the agent velocity result in world space
  65655. * @param index agent index returned by addAgent
  65656. * @param result output world space velocity
  65657. */
  65658. getAgentVelocityToRef(index: number, result: Vector3): void;
  65659. /**
  65660. * remove a particular agent previously created
  65661. * @param index agent index returned by addAgent
  65662. */
  65663. removeAgent(index: number): void;
  65664. /**
  65665. * get the list of all agents attached to this crowd
  65666. * @returns list of agent indices
  65667. */
  65668. getAgents(): number[];
  65669. /**
  65670. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65671. * @param deltaTime in seconds
  65672. */
  65673. update(deltaTime: number): void;
  65674. /**
  65675. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65676. * @param index agent index returned by addAgent
  65677. * @param destination targeted world position
  65678. */
  65679. agentGoto(index: number, destination: Vector3): void;
  65680. /**
  65681. * Teleport the agent to a new position
  65682. * @param index agent index returned by addAgent
  65683. * @param destination targeted world position
  65684. */
  65685. agentTeleport(index: number, destination: Vector3): void;
  65686. /**
  65687. * Update agent parameters
  65688. * @param index agent index returned by addAgent
  65689. * @param parameters agent parameters
  65690. */
  65691. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65692. /**
  65693. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65694. * The queries will try to find a solution within those bounds
  65695. * default is (1,1,1)
  65696. * @param extent x,y,z value that define the extent around the queries point of reference
  65697. */
  65698. setDefaultQueryExtent(extent: Vector3): void;
  65699. /**
  65700. * Get the Bounding box extent specified by setDefaultQueryExtent
  65701. * @returns the box extent values
  65702. */
  65703. getDefaultQueryExtent(): Vector3;
  65704. /**
  65705. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65706. * @param result output the box extent values
  65707. */
  65708. getDefaultQueryExtentToRef(result: Vector3): void;
  65709. /**
  65710. * Release all resources
  65711. */
  65712. dispose(): void;
  65713. }
  65714. /**
  65715. * Configures an agent
  65716. */
  65717. export interface IAgentParameters {
  65718. /**
  65719. * Agent radius. [Limit: >= 0]
  65720. */
  65721. radius: number;
  65722. /**
  65723. * Agent height. [Limit: > 0]
  65724. */
  65725. height: number;
  65726. /**
  65727. * Maximum allowed acceleration. [Limit: >= 0]
  65728. */
  65729. maxAcceleration: number;
  65730. /**
  65731. * Maximum allowed speed. [Limit: >= 0]
  65732. */
  65733. maxSpeed: number;
  65734. /**
  65735. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65736. */
  65737. collisionQueryRange: number;
  65738. /**
  65739. * The path visibility optimization range. [Limit: > 0]
  65740. */
  65741. pathOptimizationRange: number;
  65742. /**
  65743. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65744. */
  65745. separationWeight: number;
  65746. }
  65747. /**
  65748. * Configures the navigation mesh creation
  65749. */
  65750. export interface INavMeshParameters {
  65751. /**
  65752. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65753. */
  65754. cs: number;
  65755. /**
  65756. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65757. */
  65758. ch: number;
  65759. /**
  65760. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65761. */
  65762. walkableSlopeAngle: number;
  65763. /**
  65764. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65765. * be considered walkable. [Limit: >= 3] [Units: vx]
  65766. */
  65767. walkableHeight: number;
  65768. /**
  65769. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65770. */
  65771. walkableClimb: number;
  65772. /**
  65773. * The distance to erode/shrink the walkable area of the heightfield away from
  65774. * obstructions. [Limit: >=0] [Units: vx]
  65775. */
  65776. walkableRadius: number;
  65777. /**
  65778. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65779. */
  65780. maxEdgeLen: number;
  65781. /**
  65782. * The maximum distance a simplfied contour's border edges should deviate
  65783. * the original raw contour. [Limit: >=0] [Units: vx]
  65784. */
  65785. maxSimplificationError: number;
  65786. /**
  65787. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65788. */
  65789. minRegionArea: number;
  65790. /**
  65791. * Any regions with a span count smaller than this value will, if possible,
  65792. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65793. */
  65794. mergeRegionArea: number;
  65795. /**
  65796. * The maximum number of vertices allowed for polygons generated during the
  65797. * contour to polygon conversion process. [Limit: >= 3]
  65798. */
  65799. maxVertsPerPoly: number;
  65800. /**
  65801. * Sets the sampling distance to use when generating the detail mesh.
  65802. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65803. */
  65804. detailSampleDist: number;
  65805. /**
  65806. * The maximum distance the detail mesh surface should deviate from heightfield
  65807. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65808. */
  65809. detailSampleMaxError: number;
  65810. }
  65811. }
  65812. declare module BABYLON {
  65813. /**
  65814. * RecastJS navigation plugin
  65815. */
  65816. export class RecastJSPlugin implements INavigationEnginePlugin {
  65817. /**
  65818. * Reference to the Recast library
  65819. */
  65820. bjsRECAST: any;
  65821. /**
  65822. * plugin name
  65823. */
  65824. name: string;
  65825. /**
  65826. * the first navmesh created. We might extend this to support multiple navmeshes
  65827. */
  65828. navMesh: any;
  65829. /**
  65830. * Initializes the recastJS plugin
  65831. * @param recastInjection can be used to inject your own recast reference
  65832. */
  65833. constructor(recastInjection?: any);
  65834. /**
  65835. * Creates a navigation mesh
  65836. * @param meshes array of all the geometry used to compute the navigatio mesh
  65837. * @param parameters bunch of parameters used to filter geometry
  65838. */
  65839. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65840. /**
  65841. * Create a navigation mesh debug mesh
  65842. * @param scene is where the mesh will be added
  65843. * @returns debug display mesh
  65844. */
  65845. createDebugNavMesh(scene: Scene): Mesh;
  65846. /**
  65847. * Get a navigation mesh constrained position, closest to the parameter position
  65848. * @param position world position
  65849. * @returns the closest point to position constrained by the navigation mesh
  65850. */
  65851. getClosestPoint(position: Vector3): Vector3;
  65852. /**
  65853. * Get a navigation mesh constrained position, closest to the parameter position
  65854. * @param position world position
  65855. * @param result output the closest point to position constrained by the navigation mesh
  65856. */
  65857. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65858. /**
  65859. * Get a navigation mesh constrained position, within a particular radius
  65860. * @param position world position
  65861. * @param maxRadius the maximum distance to the constrained world position
  65862. * @returns the closest point to position constrained by the navigation mesh
  65863. */
  65864. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65865. /**
  65866. * Get a navigation mesh constrained position, within a particular radius
  65867. * @param position world position
  65868. * @param maxRadius the maximum distance to the constrained world position
  65869. * @param result output the closest point to position constrained by the navigation mesh
  65870. */
  65871. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65872. /**
  65873. * Compute the final position from a segment made of destination-position
  65874. * @param position world position
  65875. * @param destination world position
  65876. * @returns the resulting point along the navmesh
  65877. */
  65878. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65879. /**
  65880. * Compute the final position from a segment made of destination-position
  65881. * @param position world position
  65882. * @param destination world position
  65883. * @param result output the resulting point along the navmesh
  65884. */
  65885. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65886. /**
  65887. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65888. * @param start world position
  65889. * @param end world position
  65890. * @returns array containing world position composing the path
  65891. */
  65892. computePath(start: Vector3, end: Vector3): Vector3[];
  65893. /**
  65894. * Create a new Crowd so you can add agents
  65895. * @param maxAgents the maximum agent count in the crowd
  65896. * @param maxAgentRadius the maximum radius an agent can have
  65897. * @param scene to attach the crowd to
  65898. * @returns the crowd you can add agents to
  65899. */
  65900. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65901. /**
  65902. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65903. * The queries will try to find a solution within those bounds
  65904. * default is (1,1,1)
  65905. * @param extent x,y,z value that define the extent around the queries point of reference
  65906. */
  65907. setDefaultQueryExtent(extent: Vector3): void;
  65908. /**
  65909. * Get the Bounding box extent specified by setDefaultQueryExtent
  65910. * @returns the box extent values
  65911. */
  65912. getDefaultQueryExtent(): Vector3;
  65913. /**
  65914. * build the navmesh from a previously saved state using getNavmeshData
  65915. * @param data the Uint8Array returned by getNavmeshData
  65916. */
  65917. buildFromNavmeshData(data: Uint8Array): void;
  65918. /**
  65919. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65920. * @returns data the Uint8Array that can be saved and reused
  65921. */
  65922. getNavmeshData(): Uint8Array;
  65923. /**
  65924. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65925. * @param result output the box extent values
  65926. */
  65927. getDefaultQueryExtentToRef(result: Vector3): void;
  65928. /**
  65929. * Disposes
  65930. */
  65931. dispose(): void;
  65932. /**
  65933. * If this plugin is supported
  65934. * @returns true if plugin is supported
  65935. */
  65936. isSupported(): boolean;
  65937. }
  65938. /**
  65939. * Recast detour crowd implementation
  65940. */
  65941. export class RecastJSCrowd implements ICrowd {
  65942. /**
  65943. * Recast/detour plugin
  65944. */
  65945. bjsRECASTPlugin: RecastJSPlugin;
  65946. /**
  65947. * Link to the detour crowd
  65948. */
  65949. recastCrowd: any;
  65950. /**
  65951. * One transform per agent
  65952. */
  65953. transforms: TransformNode[];
  65954. /**
  65955. * All agents created
  65956. */
  65957. agents: number[];
  65958. /**
  65959. * Link to the scene is kept to unregister the crowd from the scene
  65960. */
  65961. private _scene;
  65962. /**
  65963. * Observer for crowd updates
  65964. */
  65965. private _onBeforeAnimationsObserver;
  65966. /**
  65967. * Constructor
  65968. * @param plugin recastJS plugin
  65969. * @param maxAgents the maximum agent count in the crowd
  65970. * @param maxAgentRadius the maximum radius an agent can have
  65971. * @param scene to attach the crowd to
  65972. * @returns the crowd you can add agents to
  65973. */
  65974. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65975. /**
  65976. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65977. * You can attach anything to that node. The node position is updated in the scene update tick.
  65978. * @param pos world position that will be constrained by the navigation mesh
  65979. * @param parameters agent parameters
  65980. * @param transform hooked to the agent that will be update by the scene
  65981. * @returns agent index
  65982. */
  65983. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65984. /**
  65985. * Returns the agent position in world space
  65986. * @param index agent index returned by addAgent
  65987. * @returns world space position
  65988. */
  65989. getAgentPosition(index: number): Vector3;
  65990. /**
  65991. * Returns the agent position result in world space
  65992. * @param index agent index returned by addAgent
  65993. * @param result output world space position
  65994. */
  65995. getAgentPositionToRef(index: number, result: Vector3): void;
  65996. /**
  65997. * Returns the agent velocity in world space
  65998. * @param index agent index returned by addAgent
  65999. * @returns world space velocity
  66000. */
  66001. getAgentVelocity(index: number): Vector3;
  66002. /**
  66003. * Returns the agent velocity result in world space
  66004. * @param index agent index returned by addAgent
  66005. * @param result output world space velocity
  66006. */
  66007. getAgentVelocityToRef(index: number, result: Vector3): void;
  66008. /**
  66009. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66010. * @param index agent index returned by addAgent
  66011. * @param destination targeted world position
  66012. */
  66013. agentGoto(index: number, destination: Vector3): void;
  66014. /**
  66015. * Teleport the agent to a new position
  66016. * @param index agent index returned by addAgent
  66017. * @param destination targeted world position
  66018. */
  66019. agentTeleport(index: number, destination: Vector3): void;
  66020. /**
  66021. * Update agent parameters
  66022. * @param index agent index returned by addAgent
  66023. * @param parameters agent parameters
  66024. */
  66025. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66026. /**
  66027. * remove a particular agent previously created
  66028. * @param index agent index returned by addAgent
  66029. */
  66030. removeAgent(index: number): void;
  66031. /**
  66032. * get the list of all agents attached to this crowd
  66033. * @returns list of agent indices
  66034. */
  66035. getAgents(): number[];
  66036. /**
  66037. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66038. * @param deltaTime in seconds
  66039. */
  66040. update(deltaTime: number): void;
  66041. /**
  66042. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66043. * The queries will try to find a solution within those bounds
  66044. * default is (1,1,1)
  66045. * @param extent x,y,z value that define the extent around the queries point of reference
  66046. */
  66047. setDefaultQueryExtent(extent: Vector3): void;
  66048. /**
  66049. * Get the Bounding box extent specified by setDefaultQueryExtent
  66050. * @returns the box extent values
  66051. */
  66052. getDefaultQueryExtent(): Vector3;
  66053. /**
  66054. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66055. * @param result output the box extent values
  66056. */
  66057. getDefaultQueryExtentToRef(result: Vector3): void;
  66058. /**
  66059. * Release all resources
  66060. */
  66061. dispose(): void;
  66062. }
  66063. }
  66064. declare module BABYLON {
  66065. /**
  66066. * Class used to enable access to IndexedDB
  66067. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66068. */
  66069. export class Database implements IOfflineProvider {
  66070. private _callbackManifestChecked;
  66071. private _currentSceneUrl;
  66072. private _db;
  66073. private _enableSceneOffline;
  66074. private _enableTexturesOffline;
  66075. private _manifestVersionFound;
  66076. private _mustUpdateRessources;
  66077. private _hasReachedQuota;
  66078. private _isSupported;
  66079. private _idbFactory;
  66080. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66081. private static IsUASupportingBlobStorage;
  66082. /**
  66083. * Gets a boolean indicating if Database storate is enabled (off by default)
  66084. */
  66085. static IDBStorageEnabled: boolean;
  66086. /**
  66087. * Gets a boolean indicating if scene must be saved in the database
  66088. */
  66089. get enableSceneOffline(): boolean;
  66090. /**
  66091. * Gets a boolean indicating if textures must be saved in the database
  66092. */
  66093. get enableTexturesOffline(): boolean;
  66094. /**
  66095. * Creates a new Database
  66096. * @param urlToScene defines the url to load the scene
  66097. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66098. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66099. */
  66100. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66101. private static _ParseURL;
  66102. private static _ReturnFullUrlLocation;
  66103. private _checkManifestFile;
  66104. /**
  66105. * Open the database and make it available
  66106. * @param successCallback defines the callback to call on success
  66107. * @param errorCallback defines the callback to call on error
  66108. */
  66109. open(successCallback: () => void, errorCallback: () => void): void;
  66110. /**
  66111. * Loads an image from the database
  66112. * @param url defines the url to load from
  66113. * @param image defines the target DOM image
  66114. */
  66115. loadImage(url: string, image: HTMLImageElement): void;
  66116. private _loadImageFromDBAsync;
  66117. private _saveImageIntoDBAsync;
  66118. private _checkVersionFromDB;
  66119. private _loadVersionFromDBAsync;
  66120. private _saveVersionIntoDBAsync;
  66121. /**
  66122. * Loads a file from database
  66123. * @param url defines the URL to load from
  66124. * @param sceneLoaded defines a callback to call on success
  66125. * @param progressCallBack defines a callback to call when progress changed
  66126. * @param errorCallback defines a callback to call on error
  66127. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66128. */
  66129. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66130. private _loadFileAsync;
  66131. private _saveFileAsync;
  66132. /**
  66133. * Validates if xhr data is correct
  66134. * @param xhr defines the request to validate
  66135. * @param dataType defines the expected data type
  66136. * @returns true if data is correct
  66137. */
  66138. private static _ValidateXHRData;
  66139. }
  66140. }
  66141. declare module BABYLON {
  66142. /** @hidden */
  66143. export var gpuUpdateParticlesPixelShader: {
  66144. name: string;
  66145. shader: string;
  66146. };
  66147. }
  66148. declare module BABYLON {
  66149. /** @hidden */
  66150. export var gpuUpdateParticlesVertexShader: {
  66151. name: string;
  66152. shader: string;
  66153. };
  66154. }
  66155. declare module BABYLON {
  66156. /** @hidden */
  66157. export var clipPlaneFragmentDeclaration2: {
  66158. name: string;
  66159. shader: string;
  66160. };
  66161. }
  66162. declare module BABYLON {
  66163. /** @hidden */
  66164. export var gpuRenderParticlesPixelShader: {
  66165. name: string;
  66166. shader: string;
  66167. };
  66168. }
  66169. declare module BABYLON {
  66170. /** @hidden */
  66171. export var clipPlaneVertexDeclaration2: {
  66172. name: string;
  66173. shader: string;
  66174. };
  66175. }
  66176. declare module BABYLON {
  66177. /** @hidden */
  66178. export var gpuRenderParticlesVertexShader: {
  66179. name: string;
  66180. shader: string;
  66181. };
  66182. }
  66183. declare module BABYLON {
  66184. /**
  66185. * This represents a GPU particle system in Babylon
  66186. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66187. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66188. */
  66189. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66190. /**
  66191. * The layer mask we are rendering the particles through.
  66192. */
  66193. layerMask: number;
  66194. private _capacity;
  66195. private _activeCount;
  66196. private _currentActiveCount;
  66197. private _accumulatedCount;
  66198. private _renderEffect;
  66199. private _updateEffect;
  66200. private _buffer0;
  66201. private _buffer1;
  66202. private _spriteBuffer;
  66203. private _updateVAO;
  66204. private _renderVAO;
  66205. private _targetIndex;
  66206. private _sourceBuffer;
  66207. private _targetBuffer;
  66208. private _engine;
  66209. private _currentRenderId;
  66210. private _started;
  66211. private _stopped;
  66212. private _timeDelta;
  66213. private _randomTexture;
  66214. private _randomTexture2;
  66215. private _attributesStrideSize;
  66216. private _updateEffectOptions;
  66217. private _randomTextureSize;
  66218. private _actualFrame;
  66219. private _customEffect;
  66220. private readonly _rawTextureWidth;
  66221. /**
  66222. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66223. */
  66224. static get IsSupported(): boolean;
  66225. /**
  66226. * An event triggered when the system is disposed.
  66227. */
  66228. onDisposeObservable: Observable<IParticleSystem>;
  66229. /**
  66230. * Gets the maximum number of particles active at the same time.
  66231. * @returns The max number of active particles.
  66232. */
  66233. getCapacity(): number;
  66234. /**
  66235. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66236. * to override the particles.
  66237. */
  66238. forceDepthWrite: boolean;
  66239. /**
  66240. * Gets or set the number of active particles
  66241. */
  66242. get activeParticleCount(): number;
  66243. set activeParticleCount(value: number);
  66244. private _preWarmDone;
  66245. /**
  66246. * Specifies if the particles are updated in emitter local space or world space.
  66247. */
  66248. isLocal: boolean;
  66249. /**
  66250. * Is this system ready to be used/rendered
  66251. * @return true if the system is ready
  66252. */
  66253. isReady(): boolean;
  66254. /**
  66255. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66256. * @returns True if it has been started, otherwise false.
  66257. */
  66258. isStarted(): boolean;
  66259. /**
  66260. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66261. * @returns True if it has been stopped, otherwise false.
  66262. */
  66263. isStopped(): boolean;
  66264. /**
  66265. * Gets a boolean indicating that the system is stopping
  66266. * @returns true if the system is currently stopping
  66267. */
  66268. isStopping(): boolean;
  66269. /**
  66270. * Gets the number of particles active at the same time.
  66271. * @returns The number of active particles.
  66272. */
  66273. getActiveCount(): number;
  66274. /**
  66275. * Starts the particle system and begins to emit
  66276. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66277. */
  66278. start(delay?: number): void;
  66279. /**
  66280. * Stops the particle system.
  66281. */
  66282. stop(): void;
  66283. /**
  66284. * Remove all active particles
  66285. */
  66286. reset(): void;
  66287. /**
  66288. * Returns the string "GPUParticleSystem"
  66289. * @returns a string containing the class name
  66290. */
  66291. getClassName(): string;
  66292. /**
  66293. * Gets the custom effect used to render the particles
  66294. * @param blendMode Blend mode for which the effect should be retrieved
  66295. * @returns The effect
  66296. */
  66297. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66298. /**
  66299. * Sets the custom effect used to render the particles
  66300. * @param effect The effect to set
  66301. * @param blendMode Blend mode for which the effect should be set
  66302. */
  66303. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66304. /** @hidden */
  66305. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66306. /**
  66307. * Observable that will be called just before the particles are drawn
  66308. */
  66309. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66310. /**
  66311. * Gets the name of the particle vertex shader
  66312. */
  66313. get vertexShaderName(): string;
  66314. private _colorGradientsTexture;
  66315. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66316. /**
  66317. * Adds a new color gradient
  66318. * @param gradient defines the gradient to use (between 0 and 1)
  66319. * @param color1 defines the color to affect to the specified gradient
  66320. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66321. * @returns the current particle system
  66322. */
  66323. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66324. private _refreshColorGradient;
  66325. /** Force the system to rebuild all gradients that need to be resync */
  66326. forceRefreshGradients(): void;
  66327. /**
  66328. * Remove a specific color gradient
  66329. * @param gradient defines the gradient to remove
  66330. * @returns the current particle system
  66331. */
  66332. removeColorGradient(gradient: number): GPUParticleSystem;
  66333. private _angularSpeedGradientsTexture;
  66334. private _sizeGradientsTexture;
  66335. private _velocityGradientsTexture;
  66336. private _limitVelocityGradientsTexture;
  66337. private _dragGradientsTexture;
  66338. private _addFactorGradient;
  66339. /**
  66340. * Adds a new size gradient
  66341. * @param gradient defines the gradient to use (between 0 and 1)
  66342. * @param factor defines the size factor to affect to the specified gradient
  66343. * @returns the current particle system
  66344. */
  66345. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66346. /**
  66347. * Remove a specific size gradient
  66348. * @param gradient defines the gradient to remove
  66349. * @returns the current particle system
  66350. */
  66351. removeSizeGradient(gradient: number): GPUParticleSystem;
  66352. private _refreshFactorGradient;
  66353. /**
  66354. * Adds a new angular speed gradient
  66355. * @param gradient defines the gradient to use (between 0 and 1)
  66356. * @param factor defines the angular speed to affect to the specified gradient
  66357. * @returns the current particle system
  66358. */
  66359. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66360. /**
  66361. * Remove a specific angular speed gradient
  66362. * @param gradient defines the gradient to remove
  66363. * @returns the current particle system
  66364. */
  66365. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66366. /**
  66367. * Adds a new velocity gradient
  66368. * @param gradient defines the gradient to use (between 0 and 1)
  66369. * @param factor defines the velocity to affect to the specified gradient
  66370. * @returns the current particle system
  66371. */
  66372. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66373. /**
  66374. * Remove a specific velocity gradient
  66375. * @param gradient defines the gradient to remove
  66376. * @returns the current particle system
  66377. */
  66378. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66379. /**
  66380. * Adds a new limit velocity gradient
  66381. * @param gradient defines the gradient to use (between 0 and 1)
  66382. * @param factor defines the limit velocity value to affect to the specified gradient
  66383. * @returns the current particle system
  66384. */
  66385. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66386. /**
  66387. * Remove a specific limit velocity gradient
  66388. * @param gradient defines the gradient to remove
  66389. * @returns the current particle system
  66390. */
  66391. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66392. /**
  66393. * Adds a new drag gradient
  66394. * @param gradient defines the gradient to use (between 0 and 1)
  66395. * @param factor defines the drag value to affect to the specified gradient
  66396. * @returns the current particle system
  66397. */
  66398. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66399. /**
  66400. * Remove a specific drag gradient
  66401. * @param gradient defines the gradient to remove
  66402. * @returns the current particle system
  66403. */
  66404. removeDragGradient(gradient: number): GPUParticleSystem;
  66405. /**
  66406. * Not supported by GPUParticleSystem
  66407. * @param gradient defines the gradient to use (between 0 and 1)
  66408. * @param factor defines the emit rate value to affect to the specified gradient
  66409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66410. * @returns the current particle system
  66411. */
  66412. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66413. /**
  66414. * Not supported by GPUParticleSystem
  66415. * @param gradient defines the gradient to remove
  66416. * @returns the current particle system
  66417. */
  66418. removeEmitRateGradient(gradient: number): IParticleSystem;
  66419. /**
  66420. * Not supported by GPUParticleSystem
  66421. * @param gradient defines the gradient to use (between 0 and 1)
  66422. * @param factor defines the start size value to affect to the specified gradient
  66423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66424. * @returns the current particle system
  66425. */
  66426. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66427. /**
  66428. * Not supported by GPUParticleSystem
  66429. * @param gradient defines the gradient to remove
  66430. * @returns the current particle system
  66431. */
  66432. removeStartSizeGradient(gradient: number): IParticleSystem;
  66433. /**
  66434. * Not supported by GPUParticleSystem
  66435. * @param gradient defines the gradient to use (between 0 and 1)
  66436. * @param min defines the color remap minimal range
  66437. * @param max defines the color remap maximal range
  66438. * @returns the current particle system
  66439. */
  66440. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66441. /**
  66442. * Not supported by GPUParticleSystem
  66443. * @param gradient defines the gradient to remove
  66444. * @returns the current particle system
  66445. */
  66446. removeColorRemapGradient(): IParticleSystem;
  66447. /**
  66448. * Not supported by GPUParticleSystem
  66449. * @param gradient defines the gradient to use (between 0 and 1)
  66450. * @param min defines the alpha remap minimal range
  66451. * @param max defines the alpha remap maximal range
  66452. * @returns the current particle system
  66453. */
  66454. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66455. /**
  66456. * Not supported by GPUParticleSystem
  66457. * @param gradient defines the gradient to remove
  66458. * @returns the current particle system
  66459. */
  66460. removeAlphaRemapGradient(): IParticleSystem;
  66461. /**
  66462. * Not supported by GPUParticleSystem
  66463. * @param gradient defines the gradient to use (between 0 and 1)
  66464. * @param color defines the color to affect to the specified gradient
  66465. * @returns the current particle system
  66466. */
  66467. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66468. /**
  66469. * Not supported by GPUParticleSystem
  66470. * @param gradient defines the gradient to remove
  66471. * @returns the current particle system
  66472. */
  66473. removeRampGradient(): IParticleSystem;
  66474. /**
  66475. * Not supported by GPUParticleSystem
  66476. * @returns the list of ramp gradients
  66477. */
  66478. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66479. /**
  66480. * Not supported by GPUParticleSystem
  66481. * Gets or sets a boolean indicating that ramp gradients must be used
  66482. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66483. */
  66484. get useRampGradients(): boolean;
  66485. set useRampGradients(value: boolean);
  66486. /**
  66487. * Not supported by GPUParticleSystem
  66488. * @param gradient defines the gradient to use (between 0 and 1)
  66489. * @param factor defines the life time factor to affect to the specified gradient
  66490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66491. * @returns the current particle system
  66492. */
  66493. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66494. /**
  66495. * Not supported by GPUParticleSystem
  66496. * @param gradient defines the gradient to remove
  66497. * @returns the current particle system
  66498. */
  66499. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66500. /**
  66501. * Instantiates a GPU particle system.
  66502. * 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.
  66503. * @param name The name of the particle system
  66504. * @param options The options used to create the system
  66505. * @param scene The scene the particle system belongs to
  66506. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66507. * @param customEffect a custom effect used to change the way particles are rendered by default
  66508. */
  66509. constructor(name: string, options: Partial<{
  66510. capacity: number;
  66511. randomTextureSize: number;
  66512. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66513. protected _reset(): void;
  66514. private _createUpdateVAO;
  66515. private _createRenderVAO;
  66516. private _initialize;
  66517. /** @hidden */
  66518. _recreateUpdateEffect(): void;
  66519. private _getEffect;
  66520. /**
  66521. * Fill the defines array according to the current settings of the particle system
  66522. * @param defines Array to be updated
  66523. * @param blendMode blend mode to take into account when updating the array
  66524. */
  66525. fillDefines(defines: Array<string>, blendMode?: number): void;
  66526. /**
  66527. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66528. * @param uniforms Uniforms array to fill
  66529. * @param attributes Attributes array to fill
  66530. * @param samplers Samplers array to fill
  66531. */
  66532. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66533. /** @hidden */
  66534. _recreateRenderEffect(): Effect;
  66535. /**
  66536. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66537. * @param preWarm defines if we are in the pre-warmimg phase
  66538. */
  66539. animate(preWarm?: boolean): void;
  66540. private _createFactorGradientTexture;
  66541. private _createSizeGradientTexture;
  66542. private _createAngularSpeedGradientTexture;
  66543. private _createVelocityGradientTexture;
  66544. private _createLimitVelocityGradientTexture;
  66545. private _createDragGradientTexture;
  66546. private _createColorGradientTexture;
  66547. /**
  66548. * Renders the particle system in its current state
  66549. * @param preWarm defines if the system should only update the particles but not render them
  66550. * @returns the current number of particles
  66551. */
  66552. render(preWarm?: boolean): number;
  66553. /**
  66554. * Rebuilds the particle system
  66555. */
  66556. rebuild(): void;
  66557. private _releaseBuffers;
  66558. private _releaseVAOs;
  66559. /**
  66560. * Disposes the particle system and free the associated resources
  66561. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66562. */
  66563. dispose(disposeTexture?: boolean): void;
  66564. /**
  66565. * Clones the particle system.
  66566. * @param name The name of the cloned object
  66567. * @param newEmitter The new emitter to use
  66568. * @returns the cloned particle system
  66569. */
  66570. clone(name: string, newEmitter: any): GPUParticleSystem;
  66571. /**
  66572. * Serializes the particle system to a JSON object
  66573. * @param serializeTexture defines if the texture must be serialized as well
  66574. * @returns the JSON object
  66575. */
  66576. serialize(serializeTexture?: boolean): any;
  66577. /**
  66578. * Parses a JSON object to create a GPU particle system.
  66579. * @param parsedParticleSystem The JSON object to parse
  66580. * @param scene The scene to create the particle system in
  66581. * @param rootUrl The root url to use to load external dependencies like texture
  66582. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66583. * @returns the parsed GPU particle system
  66584. */
  66585. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66586. }
  66587. }
  66588. declare module BABYLON {
  66589. /**
  66590. * Represents a set of particle systems working together to create a specific effect
  66591. */
  66592. export class ParticleSystemSet implements IDisposable {
  66593. /**
  66594. * Gets or sets base Assets URL
  66595. */
  66596. static BaseAssetsUrl: string;
  66597. private _emitterCreationOptions;
  66598. private _emitterNode;
  66599. /**
  66600. * Gets the particle system list
  66601. */
  66602. systems: IParticleSystem[];
  66603. /**
  66604. * Gets the emitter node used with this set
  66605. */
  66606. get emitterNode(): Nullable<TransformNode>;
  66607. /**
  66608. * Creates a new emitter mesh as a sphere
  66609. * @param options defines the options used to create the sphere
  66610. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66611. * @param scene defines the hosting scene
  66612. */
  66613. setEmitterAsSphere(options: {
  66614. diameter: number;
  66615. segments: number;
  66616. color: Color3;
  66617. }, renderingGroupId: number, scene: Scene): void;
  66618. /**
  66619. * Starts all particle systems of the set
  66620. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66621. */
  66622. start(emitter?: AbstractMesh): void;
  66623. /**
  66624. * Release all associated resources
  66625. */
  66626. dispose(): void;
  66627. /**
  66628. * Serialize the set into a JSON compatible object
  66629. * @param serializeTexture defines if the texture must be serialized as well
  66630. * @returns a JSON compatible representation of the set
  66631. */
  66632. serialize(serializeTexture?: boolean): any;
  66633. /**
  66634. * Parse a new ParticleSystemSet from a serialized source
  66635. * @param data defines a JSON compatible representation of the set
  66636. * @param scene defines the hosting scene
  66637. * @param gpu defines if we want GPU particles or CPU particles
  66638. * @returns a new ParticleSystemSet
  66639. */
  66640. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66641. }
  66642. }
  66643. declare module BABYLON {
  66644. /**
  66645. * This class is made for on one-liner static method to help creating particle system set.
  66646. */
  66647. export class ParticleHelper {
  66648. /**
  66649. * Gets or sets base Assets URL
  66650. */
  66651. static BaseAssetsUrl: string;
  66652. /** Define the Url to load snippets */
  66653. static SnippetUrl: string;
  66654. /**
  66655. * Create a default particle system that you can tweak
  66656. * @param emitter defines the emitter to use
  66657. * @param capacity defines the system capacity (default is 500 particles)
  66658. * @param scene defines the hosting scene
  66659. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66660. * @returns the new Particle system
  66661. */
  66662. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66663. /**
  66664. * This is the main static method (one-liner) of this helper to create different particle systems
  66665. * @param type This string represents the type to the particle system to create
  66666. * @param scene The scene where the particle system should live
  66667. * @param gpu If the system will use gpu
  66668. * @returns the ParticleSystemSet created
  66669. */
  66670. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66671. /**
  66672. * Static function used to export a particle system to a ParticleSystemSet variable.
  66673. * Please note that the emitter shape is not exported
  66674. * @param systems defines the particle systems to export
  66675. * @returns the created particle system set
  66676. */
  66677. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66678. /**
  66679. * Creates a particle system from a snippet saved in a remote file
  66680. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66681. * @param url defines the url to load from
  66682. * @param scene defines the hosting scene
  66683. * @param gpu If the system will use gpu
  66684. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66685. * @returns a promise that will resolve to the new particle system
  66686. */
  66687. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66688. /**
  66689. * Creates a particle system from a snippet saved by the particle system editor
  66690. * @param snippetId defines the snippet to load
  66691. * @param scene defines the hosting scene
  66692. * @param gpu If the system will use gpu
  66693. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66694. * @returns a promise that will resolve to the new particle system
  66695. */
  66696. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66697. }
  66698. }
  66699. declare module BABYLON {
  66700. interface Engine {
  66701. /**
  66702. * Create an effect to use with particle systems.
  66703. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66704. * the particle system for which you want to create a custom effect in the last parameter
  66705. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66706. * @param uniformsNames defines a list of attribute names
  66707. * @param samplers defines an array of string used to represent textures
  66708. * @param defines defines the string containing the defines to use to compile the shaders
  66709. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66710. * @param onCompiled defines a function to call when the effect creation is successful
  66711. * @param onError defines a function to call when the effect creation has failed
  66712. * @param particleSystem the particle system you want to create the effect for
  66713. * @returns the new Effect
  66714. */
  66715. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66716. }
  66717. interface Mesh {
  66718. /**
  66719. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66720. * @returns an array of IParticleSystem
  66721. */
  66722. getEmittedParticleSystems(): IParticleSystem[];
  66723. /**
  66724. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66725. * @returns an array of IParticleSystem
  66726. */
  66727. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66728. }
  66729. }
  66730. declare module BABYLON {
  66731. /** Defines the 4 color options */
  66732. export enum PointColor {
  66733. /** color value */
  66734. Color = 2,
  66735. /** uv value */
  66736. UV = 1,
  66737. /** random value */
  66738. Random = 0,
  66739. /** stated value */
  66740. Stated = 3
  66741. }
  66742. /**
  66743. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66744. * 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.
  66745. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66746. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66747. *
  66748. * Full documentation here : TO BE ENTERED
  66749. */
  66750. export class PointsCloudSystem implements IDisposable {
  66751. /**
  66752. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66753. * Example : var p = SPS.particles[i];
  66754. */
  66755. particles: CloudPoint[];
  66756. /**
  66757. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66758. */
  66759. nbParticles: number;
  66760. /**
  66761. * This a counter for your own usage. It's not set by any SPS functions.
  66762. */
  66763. counter: number;
  66764. /**
  66765. * The PCS name. This name is also given to the underlying mesh.
  66766. */
  66767. name: string;
  66768. /**
  66769. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66770. */
  66771. mesh: Mesh;
  66772. /**
  66773. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66774. * Please read :
  66775. */
  66776. vars: any;
  66777. /**
  66778. * @hidden
  66779. */
  66780. _size: number;
  66781. private _scene;
  66782. private _promises;
  66783. private _positions;
  66784. private _indices;
  66785. private _normals;
  66786. private _colors;
  66787. private _uvs;
  66788. private _indices32;
  66789. private _positions32;
  66790. private _colors32;
  66791. private _uvs32;
  66792. private _updatable;
  66793. private _isVisibilityBoxLocked;
  66794. private _alwaysVisible;
  66795. private _groups;
  66796. private _groupCounter;
  66797. private _computeParticleColor;
  66798. private _computeParticleTexture;
  66799. private _computeParticleRotation;
  66800. private _computeBoundingBox;
  66801. private _isReady;
  66802. /**
  66803. * Creates a PCS (Points Cloud System) object
  66804. * @param name (String) is the PCS name, this will be the underlying mesh name
  66805. * @param pointSize (number) is the size for each point
  66806. * @param scene (Scene) is the scene in which the PCS is added
  66807. * @param options defines the options of the PCS e.g.
  66808. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66809. */
  66810. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66811. updatable?: boolean;
  66812. });
  66813. /**
  66814. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66815. * If no points were added to the PCS, the returned mesh is just a single point.
  66816. * @returns a promise for the created mesh
  66817. */
  66818. buildMeshAsync(): Promise<Mesh>;
  66819. /**
  66820. * @hidden
  66821. */
  66822. private _buildMesh;
  66823. private _addParticle;
  66824. private _randomUnitVector;
  66825. private _getColorIndicesForCoord;
  66826. private _setPointsColorOrUV;
  66827. private _colorFromTexture;
  66828. private _calculateDensity;
  66829. /**
  66830. * Adds points to the PCS in random positions within a unit sphere
  66831. * @param nb (positive integer) the number of particles to be created from this model
  66832. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66833. * @returns the number of groups in the system
  66834. */
  66835. addPoints(nb: number, pointFunction?: any): number;
  66836. /**
  66837. * Adds points to the PCS from the surface of the model shape
  66838. * @param mesh is any Mesh object that will be used as a surface model for the points
  66839. * @param nb (positive integer) the number of particles to be created from this model
  66840. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66841. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66842. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66843. * @returns the number of groups in the system
  66844. */
  66845. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66846. /**
  66847. * Adds points to the PCS inside the model shape
  66848. * @param mesh is any Mesh object that will be used as a surface model for the points
  66849. * @param nb (positive integer) the number of particles to be created from this model
  66850. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66851. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66852. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66853. * @returns the number of groups in the system
  66854. */
  66855. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66856. /**
  66857. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66858. * This method calls `updateParticle()` for each particle of the SPS.
  66859. * For an animated SPS, it is usually called within the render loop.
  66860. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66861. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66862. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66863. * @returns the PCS.
  66864. */
  66865. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66866. /**
  66867. * Disposes the PCS.
  66868. */
  66869. dispose(): void;
  66870. /**
  66871. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66872. * doc :
  66873. * @returns the PCS.
  66874. */
  66875. refreshVisibleSize(): PointsCloudSystem;
  66876. /**
  66877. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66878. * @param size the size (float) of the visibility box
  66879. * note : this doesn't lock the PCS mesh bounding box.
  66880. * doc :
  66881. */
  66882. setVisibilityBox(size: number): void;
  66883. /**
  66884. * Gets whether the PCS is always visible or not
  66885. * doc :
  66886. */
  66887. get isAlwaysVisible(): boolean;
  66888. /**
  66889. * Sets the PCS as always visible or not
  66890. * doc :
  66891. */
  66892. set isAlwaysVisible(val: boolean);
  66893. /**
  66894. * Tells to `setParticles()` to compute the particle rotations or not
  66895. * Default value : false. The PCS is faster when it's set to false
  66896. * Note : particle rotations are only applied to parent particles
  66897. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66898. */
  66899. set computeParticleRotation(val: boolean);
  66900. /**
  66901. * Tells to `setParticles()` to compute the particle colors or not.
  66902. * Default value : true. The PCS is faster when it's set to false.
  66903. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66904. */
  66905. set computeParticleColor(val: boolean);
  66906. set computeParticleTexture(val: boolean);
  66907. /**
  66908. * Gets if `setParticles()` computes the particle colors or not.
  66909. * Default value : false. The PCS is faster when it's set to false.
  66910. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66911. */
  66912. get computeParticleColor(): boolean;
  66913. /**
  66914. * Gets if `setParticles()` computes the particle textures or not.
  66915. * Default value : false. The PCS is faster when it's set to false.
  66916. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66917. */
  66918. get computeParticleTexture(): boolean;
  66919. /**
  66920. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66921. */
  66922. set computeBoundingBox(val: boolean);
  66923. /**
  66924. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66925. */
  66926. get computeBoundingBox(): boolean;
  66927. /**
  66928. * This function does nothing. It may be overwritten to set all the particle first values.
  66929. * The PCS doesn't call this function, you may have to call it by your own.
  66930. * doc :
  66931. */
  66932. initParticles(): void;
  66933. /**
  66934. * This function does nothing. It may be overwritten to recycle a particle
  66935. * The PCS doesn't call this function, you can to call it
  66936. * doc :
  66937. * @param particle The particle to recycle
  66938. * @returns the recycled particle
  66939. */
  66940. recycleParticle(particle: CloudPoint): CloudPoint;
  66941. /**
  66942. * Updates a particle : this function should be overwritten by the user.
  66943. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66944. * doc :
  66945. * @example : just set a particle position or velocity and recycle conditions
  66946. * @param particle The particle to update
  66947. * @returns the updated particle
  66948. */
  66949. updateParticle(particle: CloudPoint): CloudPoint;
  66950. /**
  66951. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66952. * This does nothing and may be overwritten by the user.
  66953. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66954. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66955. * @param update the boolean update value actually passed to setParticles()
  66956. */
  66957. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66958. /**
  66959. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66960. * This will be passed three parameters.
  66961. * This does nothing and may be overwritten by the user.
  66962. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66963. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66964. * @param update the boolean update value actually passed to setParticles()
  66965. */
  66966. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66967. }
  66968. }
  66969. declare module BABYLON {
  66970. /**
  66971. * Represents one particle of a points cloud system.
  66972. */
  66973. export class CloudPoint {
  66974. /**
  66975. * particle global index
  66976. */
  66977. idx: number;
  66978. /**
  66979. * The color of the particle
  66980. */
  66981. color: Nullable<Color4>;
  66982. /**
  66983. * The world space position of the particle.
  66984. */
  66985. position: Vector3;
  66986. /**
  66987. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66988. */
  66989. rotation: Vector3;
  66990. /**
  66991. * The world space rotation quaternion of the particle.
  66992. */
  66993. rotationQuaternion: Nullable<Quaternion>;
  66994. /**
  66995. * The uv of the particle.
  66996. */
  66997. uv: Nullable<Vector2>;
  66998. /**
  66999. * The current speed of the particle.
  67000. */
  67001. velocity: Vector3;
  67002. /**
  67003. * The pivot point in the particle local space.
  67004. */
  67005. pivot: Vector3;
  67006. /**
  67007. * Must the particle be translated from its pivot point in its local space ?
  67008. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67009. * Default : false
  67010. */
  67011. translateFromPivot: boolean;
  67012. /**
  67013. * Index of this particle in the global "positions" array (Internal use)
  67014. * @hidden
  67015. */
  67016. _pos: number;
  67017. /**
  67018. * @hidden Index of this particle in the global "indices" array (Internal use)
  67019. */
  67020. _ind: number;
  67021. /**
  67022. * Group this particle belongs to
  67023. */
  67024. _group: PointsGroup;
  67025. /**
  67026. * Group id of this particle
  67027. */
  67028. groupId: number;
  67029. /**
  67030. * Index of the particle in its group id (Internal use)
  67031. */
  67032. idxInGroup: number;
  67033. /**
  67034. * @hidden Particle BoundingInfo object (Internal use)
  67035. */
  67036. _boundingInfo: BoundingInfo;
  67037. /**
  67038. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67039. */
  67040. _pcs: PointsCloudSystem;
  67041. /**
  67042. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67043. */
  67044. _stillInvisible: boolean;
  67045. /**
  67046. * @hidden Last computed particle rotation matrix
  67047. */
  67048. _rotationMatrix: number[];
  67049. /**
  67050. * Parent particle Id, if any.
  67051. * Default null.
  67052. */
  67053. parentId: Nullable<number>;
  67054. /**
  67055. * @hidden Internal global position in the PCS.
  67056. */
  67057. _globalPosition: Vector3;
  67058. /**
  67059. * Creates a Point Cloud object.
  67060. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67061. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67062. * @param group (PointsGroup) is the group the particle belongs to
  67063. * @param groupId (integer) is the group identifier in the PCS.
  67064. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67065. * @param pcs defines the PCS it is associated to
  67066. */
  67067. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67068. /**
  67069. * get point size
  67070. */
  67071. get size(): Vector3;
  67072. /**
  67073. * Set point size
  67074. */
  67075. set size(scale: Vector3);
  67076. /**
  67077. * Legacy support, changed quaternion to rotationQuaternion
  67078. */
  67079. get quaternion(): Nullable<Quaternion>;
  67080. /**
  67081. * Legacy support, changed quaternion to rotationQuaternion
  67082. */
  67083. set quaternion(q: Nullable<Quaternion>);
  67084. /**
  67085. * Returns a boolean. True if the particle intersects a mesh, else false
  67086. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67087. * @param target is the object (point or mesh) what the intersection is computed against
  67088. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67089. * @returns true if it intersects
  67090. */
  67091. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67092. /**
  67093. * get the rotation matrix of the particle
  67094. * @hidden
  67095. */
  67096. getRotationMatrix(m: Matrix): void;
  67097. }
  67098. /**
  67099. * Represents a group of points in a points cloud system
  67100. * * PCS internal tool, don't use it manually.
  67101. */
  67102. export class PointsGroup {
  67103. /**
  67104. * The group id
  67105. * @hidden
  67106. */
  67107. groupID: number;
  67108. /**
  67109. * image data for group (internal use)
  67110. * @hidden
  67111. */
  67112. _groupImageData: Nullable<ArrayBufferView>;
  67113. /**
  67114. * Image Width (internal use)
  67115. * @hidden
  67116. */
  67117. _groupImgWidth: number;
  67118. /**
  67119. * Image Height (internal use)
  67120. * @hidden
  67121. */
  67122. _groupImgHeight: number;
  67123. /**
  67124. * Custom position function (internal use)
  67125. * @hidden
  67126. */
  67127. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67128. /**
  67129. * density per facet for surface points
  67130. * @hidden
  67131. */
  67132. _groupDensity: number[];
  67133. /**
  67134. * Only when points are colored by texture carries pointer to texture list array
  67135. * @hidden
  67136. */
  67137. _textureNb: number;
  67138. /**
  67139. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67140. * PCS internal tool, don't use it manually.
  67141. * @hidden
  67142. */
  67143. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67144. }
  67145. }
  67146. declare module BABYLON {
  67147. interface Scene {
  67148. /** @hidden (Backing field) */
  67149. _physicsEngine: Nullable<IPhysicsEngine>;
  67150. /** @hidden */
  67151. _physicsTimeAccumulator: number;
  67152. /**
  67153. * Gets the current physics engine
  67154. * @returns a IPhysicsEngine or null if none attached
  67155. */
  67156. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67157. /**
  67158. * Enables physics to the current scene
  67159. * @param gravity defines the scene's gravity for the physics engine
  67160. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67161. * @return a boolean indicating if the physics engine was initialized
  67162. */
  67163. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67164. /**
  67165. * Disables and disposes the physics engine associated with the scene
  67166. */
  67167. disablePhysicsEngine(): void;
  67168. /**
  67169. * Gets a boolean indicating if there is an active physics engine
  67170. * @returns a boolean indicating if there is an active physics engine
  67171. */
  67172. isPhysicsEnabled(): boolean;
  67173. /**
  67174. * Deletes a physics compound impostor
  67175. * @param compound defines the compound to delete
  67176. */
  67177. deleteCompoundImpostor(compound: any): void;
  67178. /**
  67179. * An event triggered when physic simulation is about to be run
  67180. */
  67181. onBeforePhysicsObservable: Observable<Scene>;
  67182. /**
  67183. * An event triggered when physic simulation has been done
  67184. */
  67185. onAfterPhysicsObservable: Observable<Scene>;
  67186. }
  67187. interface AbstractMesh {
  67188. /** @hidden */
  67189. _physicsImpostor: Nullable<PhysicsImpostor>;
  67190. /**
  67191. * Gets or sets impostor used for physic simulation
  67192. * @see http://doc.babylonjs.com/features/physics_engine
  67193. */
  67194. physicsImpostor: Nullable<PhysicsImpostor>;
  67195. /**
  67196. * Gets the current physics impostor
  67197. * @see http://doc.babylonjs.com/features/physics_engine
  67198. * @returns a physics impostor or null
  67199. */
  67200. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67201. /** Apply a physic impulse to the mesh
  67202. * @param force defines the force to apply
  67203. * @param contactPoint defines where to apply the force
  67204. * @returns the current mesh
  67205. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67206. */
  67207. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67208. /**
  67209. * Creates a physic joint between two meshes
  67210. * @param otherMesh defines the other mesh to use
  67211. * @param pivot1 defines the pivot to use on this mesh
  67212. * @param pivot2 defines the pivot to use on the other mesh
  67213. * @param options defines additional options (can be plugin dependent)
  67214. * @returns the current mesh
  67215. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67216. */
  67217. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67218. /** @hidden */
  67219. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67220. }
  67221. /**
  67222. * Defines the physics engine scene component responsible to manage a physics engine
  67223. */
  67224. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67225. /**
  67226. * The component name helpful to identify the component in the list of scene components.
  67227. */
  67228. readonly name: string;
  67229. /**
  67230. * The scene the component belongs to.
  67231. */
  67232. scene: Scene;
  67233. /**
  67234. * Creates a new instance of the component for the given scene
  67235. * @param scene Defines the scene to register the component in
  67236. */
  67237. constructor(scene: Scene);
  67238. /**
  67239. * Registers the component in a given scene
  67240. */
  67241. register(): void;
  67242. /**
  67243. * Rebuilds the elements related to this component in case of
  67244. * context lost for instance.
  67245. */
  67246. rebuild(): void;
  67247. /**
  67248. * Disposes the component and the associated ressources
  67249. */
  67250. dispose(): void;
  67251. }
  67252. }
  67253. declare module BABYLON {
  67254. /**
  67255. * A helper for physics simulations
  67256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67257. */
  67258. export class PhysicsHelper {
  67259. private _scene;
  67260. private _physicsEngine;
  67261. /**
  67262. * Initializes the Physics helper
  67263. * @param scene Babylon.js scene
  67264. */
  67265. constructor(scene: Scene);
  67266. /**
  67267. * Applies a radial explosion impulse
  67268. * @param origin the origin of the explosion
  67269. * @param radiusOrEventOptions the radius or the options of radial explosion
  67270. * @param strength the explosion strength
  67271. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67272. * @returns A physics radial explosion event, or null
  67273. */
  67274. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67275. /**
  67276. * Applies a radial explosion force
  67277. * @param origin the origin of the explosion
  67278. * @param radiusOrEventOptions the radius or the options of radial explosion
  67279. * @param strength the explosion strength
  67280. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67281. * @returns A physics radial explosion event, or null
  67282. */
  67283. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67284. /**
  67285. * Creates a gravitational field
  67286. * @param origin the origin of the explosion
  67287. * @param radiusOrEventOptions the radius or the options of radial explosion
  67288. * @param strength the explosion strength
  67289. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67290. * @returns A physics gravitational field event, or null
  67291. */
  67292. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67293. /**
  67294. * Creates a physics updraft event
  67295. * @param origin the origin of the updraft
  67296. * @param radiusOrEventOptions the radius or the options of the updraft
  67297. * @param strength the strength of the updraft
  67298. * @param height the height of the updraft
  67299. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67300. * @returns A physics updraft event, or null
  67301. */
  67302. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67303. /**
  67304. * Creates a physics vortex event
  67305. * @param origin the of the vortex
  67306. * @param radiusOrEventOptions the radius or the options of the vortex
  67307. * @param strength the strength of the vortex
  67308. * @param height the height of the vortex
  67309. * @returns a Physics vortex event, or null
  67310. * A physics vortex event or null
  67311. */
  67312. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67313. }
  67314. /**
  67315. * Represents a physics radial explosion event
  67316. */
  67317. class PhysicsRadialExplosionEvent {
  67318. private _scene;
  67319. private _options;
  67320. private _sphere;
  67321. private _dataFetched;
  67322. /**
  67323. * Initializes a radial explosioin event
  67324. * @param _scene BabylonJS scene
  67325. * @param _options The options for the vortex event
  67326. */
  67327. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67328. /**
  67329. * Returns the data related to the radial explosion event (sphere).
  67330. * @returns The radial explosion event data
  67331. */
  67332. getData(): PhysicsRadialExplosionEventData;
  67333. /**
  67334. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67335. * @param impostor A physics imposter
  67336. * @param origin the origin of the explosion
  67337. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67338. */
  67339. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67340. /**
  67341. * Triggers affecterd impostors callbacks
  67342. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67343. */
  67344. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67345. /**
  67346. * Disposes the sphere.
  67347. * @param force Specifies if the sphere should be disposed by force
  67348. */
  67349. dispose(force?: boolean): void;
  67350. /*** Helpers ***/
  67351. private _prepareSphere;
  67352. private _intersectsWithSphere;
  67353. }
  67354. /**
  67355. * Represents a gravitational field event
  67356. */
  67357. class PhysicsGravitationalFieldEvent {
  67358. private _physicsHelper;
  67359. private _scene;
  67360. private _origin;
  67361. private _options;
  67362. private _tickCallback;
  67363. private _sphere;
  67364. private _dataFetched;
  67365. /**
  67366. * Initializes the physics gravitational field event
  67367. * @param _physicsHelper A physics helper
  67368. * @param _scene BabylonJS scene
  67369. * @param _origin The origin position of the gravitational field event
  67370. * @param _options The options for the vortex event
  67371. */
  67372. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67373. /**
  67374. * Returns the data related to the gravitational field event (sphere).
  67375. * @returns A gravitational field event
  67376. */
  67377. getData(): PhysicsGravitationalFieldEventData;
  67378. /**
  67379. * Enables the gravitational field.
  67380. */
  67381. enable(): void;
  67382. /**
  67383. * Disables the gravitational field.
  67384. */
  67385. disable(): void;
  67386. /**
  67387. * Disposes the sphere.
  67388. * @param force The force to dispose from the gravitational field event
  67389. */
  67390. dispose(force?: boolean): void;
  67391. private _tick;
  67392. }
  67393. /**
  67394. * Represents a physics updraft event
  67395. */
  67396. class PhysicsUpdraftEvent {
  67397. private _scene;
  67398. private _origin;
  67399. private _options;
  67400. private _physicsEngine;
  67401. private _originTop;
  67402. private _originDirection;
  67403. private _tickCallback;
  67404. private _cylinder;
  67405. private _cylinderPosition;
  67406. private _dataFetched;
  67407. /**
  67408. * Initializes the physics updraft event
  67409. * @param _scene BabylonJS scene
  67410. * @param _origin The origin position of the updraft
  67411. * @param _options The options for the updraft event
  67412. */
  67413. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67414. /**
  67415. * Returns the data related to the updraft event (cylinder).
  67416. * @returns A physics updraft event
  67417. */
  67418. getData(): PhysicsUpdraftEventData;
  67419. /**
  67420. * Enables the updraft.
  67421. */
  67422. enable(): void;
  67423. /**
  67424. * Disables the updraft.
  67425. */
  67426. disable(): void;
  67427. /**
  67428. * Disposes the cylinder.
  67429. * @param force Specifies if the updraft should be disposed by force
  67430. */
  67431. dispose(force?: boolean): void;
  67432. private getImpostorHitData;
  67433. private _tick;
  67434. /*** Helpers ***/
  67435. private _prepareCylinder;
  67436. private _intersectsWithCylinder;
  67437. }
  67438. /**
  67439. * Represents a physics vortex event
  67440. */
  67441. class PhysicsVortexEvent {
  67442. private _scene;
  67443. private _origin;
  67444. private _options;
  67445. private _physicsEngine;
  67446. private _originTop;
  67447. private _tickCallback;
  67448. private _cylinder;
  67449. private _cylinderPosition;
  67450. private _dataFetched;
  67451. /**
  67452. * Initializes the physics vortex event
  67453. * @param _scene The BabylonJS scene
  67454. * @param _origin The origin position of the vortex
  67455. * @param _options The options for the vortex event
  67456. */
  67457. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67458. /**
  67459. * Returns the data related to the vortex event (cylinder).
  67460. * @returns The physics vortex event data
  67461. */
  67462. getData(): PhysicsVortexEventData;
  67463. /**
  67464. * Enables the vortex.
  67465. */
  67466. enable(): void;
  67467. /**
  67468. * Disables the cortex.
  67469. */
  67470. disable(): void;
  67471. /**
  67472. * Disposes the sphere.
  67473. * @param force
  67474. */
  67475. dispose(force?: boolean): void;
  67476. private getImpostorHitData;
  67477. private _tick;
  67478. /*** Helpers ***/
  67479. private _prepareCylinder;
  67480. private _intersectsWithCylinder;
  67481. }
  67482. /**
  67483. * Options fot the radial explosion event
  67484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67485. */
  67486. export class PhysicsRadialExplosionEventOptions {
  67487. /**
  67488. * The radius of the sphere for the radial explosion.
  67489. */
  67490. radius: number;
  67491. /**
  67492. * The strenth of the explosion.
  67493. */
  67494. strength: number;
  67495. /**
  67496. * The strenght of the force in correspondence to the distance of the affected object
  67497. */
  67498. falloff: PhysicsRadialImpulseFalloff;
  67499. /**
  67500. * Sphere options for the radial explosion.
  67501. */
  67502. sphere: {
  67503. segments: number;
  67504. diameter: number;
  67505. };
  67506. /**
  67507. * Sphere options for the radial explosion.
  67508. */
  67509. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67510. }
  67511. /**
  67512. * Options fot the updraft event
  67513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67514. */
  67515. export class PhysicsUpdraftEventOptions {
  67516. /**
  67517. * The radius of the cylinder for the vortex
  67518. */
  67519. radius: number;
  67520. /**
  67521. * The strenth of the updraft.
  67522. */
  67523. strength: number;
  67524. /**
  67525. * The height of the cylinder for the updraft.
  67526. */
  67527. height: number;
  67528. /**
  67529. * The mode for the the updraft.
  67530. */
  67531. updraftMode: PhysicsUpdraftMode;
  67532. }
  67533. /**
  67534. * Options fot the vortex event
  67535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67536. */
  67537. export class PhysicsVortexEventOptions {
  67538. /**
  67539. * The radius of the cylinder for the vortex
  67540. */
  67541. radius: number;
  67542. /**
  67543. * The strenth of the vortex.
  67544. */
  67545. strength: number;
  67546. /**
  67547. * The height of the cylinder for the vortex.
  67548. */
  67549. height: number;
  67550. /**
  67551. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67552. */
  67553. centripetalForceThreshold: number;
  67554. /**
  67555. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67556. */
  67557. centripetalForceMultiplier: number;
  67558. /**
  67559. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67560. */
  67561. centrifugalForceMultiplier: number;
  67562. /**
  67563. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67564. */
  67565. updraftForceMultiplier: number;
  67566. }
  67567. /**
  67568. * The strenght of the force in correspondence to the distance of the affected object
  67569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67570. */
  67571. export enum PhysicsRadialImpulseFalloff {
  67572. /** Defines that impulse is constant in strength across it's whole radius */
  67573. Constant = 0,
  67574. /** Defines that impulse gets weaker if it's further from the origin */
  67575. Linear = 1
  67576. }
  67577. /**
  67578. * The strength of the force in correspondence to the distance of the affected object
  67579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67580. */
  67581. export enum PhysicsUpdraftMode {
  67582. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67583. Center = 0,
  67584. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67585. Perpendicular = 1
  67586. }
  67587. /**
  67588. * Interface for a physics hit data
  67589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67590. */
  67591. export interface PhysicsHitData {
  67592. /**
  67593. * The force applied at the contact point
  67594. */
  67595. force: Vector3;
  67596. /**
  67597. * The contact point
  67598. */
  67599. contactPoint: Vector3;
  67600. /**
  67601. * The distance from the origin to the contact point
  67602. */
  67603. distanceFromOrigin: number;
  67604. }
  67605. /**
  67606. * Interface for radial explosion event data
  67607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67608. */
  67609. export interface PhysicsRadialExplosionEventData {
  67610. /**
  67611. * A sphere used for the radial explosion event
  67612. */
  67613. sphere: Mesh;
  67614. }
  67615. /**
  67616. * Interface for gravitational field event data
  67617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67618. */
  67619. export interface PhysicsGravitationalFieldEventData {
  67620. /**
  67621. * A sphere mesh used for the gravitational field event
  67622. */
  67623. sphere: Mesh;
  67624. }
  67625. /**
  67626. * Interface for updraft event data
  67627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67628. */
  67629. export interface PhysicsUpdraftEventData {
  67630. /**
  67631. * A cylinder used for the updraft event
  67632. */
  67633. cylinder: Mesh;
  67634. }
  67635. /**
  67636. * Interface for vortex event data
  67637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67638. */
  67639. export interface PhysicsVortexEventData {
  67640. /**
  67641. * A cylinder used for the vortex event
  67642. */
  67643. cylinder: Mesh;
  67644. }
  67645. /**
  67646. * Interface for an affected physics impostor
  67647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67648. */
  67649. export interface PhysicsAffectedImpostorWithData {
  67650. /**
  67651. * The impostor affected by the effect
  67652. */
  67653. impostor: PhysicsImpostor;
  67654. /**
  67655. * The data about the hit/horce from the explosion
  67656. */
  67657. hitData: PhysicsHitData;
  67658. }
  67659. }
  67660. declare module BABYLON {
  67661. /** @hidden */
  67662. export var blackAndWhitePixelShader: {
  67663. name: string;
  67664. shader: string;
  67665. };
  67666. }
  67667. declare module BABYLON {
  67668. /**
  67669. * Post process used to render in black and white
  67670. */
  67671. export class BlackAndWhitePostProcess extends PostProcess {
  67672. /**
  67673. * Linear about to convert he result to black and white (default: 1)
  67674. */
  67675. degree: number;
  67676. /**
  67677. * Creates a black and white post process
  67678. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67679. * @param name The name of the effect.
  67680. * @param options The required width/height ratio to downsize to before computing the render pass.
  67681. * @param camera The camera to apply the render pass to.
  67682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67683. * @param engine The engine which the post process will be applied. (default: current engine)
  67684. * @param reusable If the post process can be reused on the same frame. (default: false)
  67685. */
  67686. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67687. }
  67688. }
  67689. declare module BABYLON {
  67690. /**
  67691. * This represents a set of one or more post processes in Babylon.
  67692. * A post process can be used to apply a shader to a texture after it is rendered.
  67693. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67694. */
  67695. export class PostProcessRenderEffect {
  67696. private _postProcesses;
  67697. private _getPostProcesses;
  67698. private _singleInstance;
  67699. private _cameras;
  67700. private _indicesForCamera;
  67701. /**
  67702. * Name of the effect
  67703. * @hidden
  67704. */
  67705. _name: string;
  67706. /**
  67707. * Instantiates a post process render effect.
  67708. * A post process can be used to apply a shader to a texture after it is rendered.
  67709. * @param engine The engine the effect is tied to
  67710. * @param name The name of the effect
  67711. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67712. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67713. */
  67714. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67715. /**
  67716. * Checks if all the post processes in the effect are supported.
  67717. */
  67718. get isSupported(): boolean;
  67719. /**
  67720. * Updates the current state of the effect
  67721. * @hidden
  67722. */
  67723. _update(): void;
  67724. /**
  67725. * Attaches the effect on cameras
  67726. * @param cameras The camera to attach to.
  67727. * @hidden
  67728. */
  67729. _attachCameras(cameras: Camera): void;
  67730. /**
  67731. * Attaches the effect on cameras
  67732. * @param cameras The camera to attach to.
  67733. * @hidden
  67734. */
  67735. _attachCameras(cameras: Camera[]): void;
  67736. /**
  67737. * Detaches the effect on cameras
  67738. * @param cameras The camera to detatch from.
  67739. * @hidden
  67740. */
  67741. _detachCameras(cameras: Camera): void;
  67742. /**
  67743. * Detatches the effect on cameras
  67744. * @param cameras The camera to detatch from.
  67745. * @hidden
  67746. */
  67747. _detachCameras(cameras: Camera[]): void;
  67748. /**
  67749. * Enables the effect on given cameras
  67750. * @param cameras The camera to enable.
  67751. * @hidden
  67752. */
  67753. _enable(cameras: Camera): void;
  67754. /**
  67755. * Enables the effect on given cameras
  67756. * @param cameras The camera to enable.
  67757. * @hidden
  67758. */
  67759. _enable(cameras: Nullable<Camera[]>): void;
  67760. /**
  67761. * Disables the effect on the given cameras
  67762. * @param cameras The camera to disable.
  67763. * @hidden
  67764. */
  67765. _disable(cameras: Camera): void;
  67766. /**
  67767. * Disables the effect on the given cameras
  67768. * @param cameras The camera to disable.
  67769. * @hidden
  67770. */
  67771. _disable(cameras: Nullable<Camera[]>): void;
  67772. /**
  67773. * Gets a list of the post processes contained in the effect.
  67774. * @param camera The camera to get the post processes on.
  67775. * @returns The list of the post processes in the effect.
  67776. */
  67777. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67778. }
  67779. }
  67780. declare module BABYLON {
  67781. /** @hidden */
  67782. export var extractHighlightsPixelShader: {
  67783. name: string;
  67784. shader: string;
  67785. };
  67786. }
  67787. declare module BABYLON {
  67788. /**
  67789. * 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.
  67790. */
  67791. export class ExtractHighlightsPostProcess extends PostProcess {
  67792. /**
  67793. * The luminance threshold, pixels below this value will be set to black.
  67794. */
  67795. threshold: number;
  67796. /** @hidden */
  67797. _exposure: number;
  67798. /**
  67799. * Post process which has the input texture to be used when performing highlight extraction
  67800. * @hidden
  67801. */
  67802. _inputPostProcess: Nullable<PostProcess>;
  67803. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67804. }
  67805. }
  67806. declare module BABYLON {
  67807. /** @hidden */
  67808. export var bloomMergePixelShader: {
  67809. name: string;
  67810. shader: string;
  67811. };
  67812. }
  67813. declare module BABYLON {
  67814. /**
  67815. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67816. */
  67817. export class BloomMergePostProcess extends PostProcess {
  67818. /** Weight of the bloom to be added to the original input. */
  67819. weight: number;
  67820. /**
  67821. * Creates a new instance of @see BloomMergePostProcess
  67822. * @param name The name of the effect.
  67823. * @param originalFromInput Post process which's input will be used for the merge.
  67824. * @param blurred Blurred highlights post process which's output will be used.
  67825. * @param weight Weight of the bloom to be added to the original input.
  67826. * @param options The required width/height ratio to downsize to before computing the render pass.
  67827. * @param camera The camera to apply the render pass to.
  67828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67829. * @param engine The engine which the post process will be applied. (default: current engine)
  67830. * @param reusable If the post process can be reused on the same frame. (default: false)
  67831. * @param textureType Type of textures used when performing the post process. (default: 0)
  67832. * @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)
  67833. */
  67834. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67835. /** Weight of the bloom to be added to the original input. */
  67836. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67837. }
  67838. }
  67839. declare module BABYLON {
  67840. /**
  67841. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67842. */
  67843. export class BloomEffect extends PostProcessRenderEffect {
  67844. private bloomScale;
  67845. /**
  67846. * @hidden Internal
  67847. */
  67848. _effects: Array<PostProcess>;
  67849. /**
  67850. * @hidden Internal
  67851. */
  67852. _downscale: ExtractHighlightsPostProcess;
  67853. private _blurX;
  67854. private _blurY;
  67855. private _merge;
  67856. /**
  67857. * The luminance threshold to find bright areas of the image to bloom.
  67858. */
  67859. get threshold(): number;
  67860. set threshold(value: number);
  67861. /**
  67862. * The strength of the bloom.
  67863. */
  67864. get weight(): number;
  67865. set weight(value: number);
  67866. /**
  67867. * Specifies the size of the bloom blur kernel, relative to the final output size
  67868. */
  67869. get kernel(): number;
  67870. set kernel(value: number);
  67871. /**
  67872. * Creates a new instance of @see BloomEffect
  67873. * @param scene The scene the effect belongs to.
  67874. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67875. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67876. * @param bloomWeight The the strength of bloom.
  67877. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67878. * @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)
  67879. */
  67880. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67881. /**
  67882. * Disposes each of the internal effects for a given camera.
  67883. * @param camera The camera to dispose the effect on.
  67884. */
  67885. disposeEffects(camera: Camera): void;
  67886. /**
  67887. * @hidden Internal
  67888. */
  67889. _updateEffects(): void;
  67890. /**
  67891. * Internal
  67892. * @returns if all the contained post processes are ready.
  67893. * @hidden
  67894. */
  67895. _isReady(): boolean;
  67896. }
  67897. }
  67898. declare module BABYLON {
  67899. /** @hidden */
  67900. export var chromaticAberrationPixelShader: {
  67901. name: string;
  67902. shader: string;
  67903. };
  67904. }
  67905. declare module BABYLON {
  67906. /**
  67907. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67908. */
  67909. export class ChromaticAberrationPostProcess extends PostProcess {
  67910. /**
  67911. * The amount of seperation of rgb channels (default: 30)
  67912. */
  67913. aberrationAmount: number;
  67914. /**
  67915. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67916. */
  67917. radialIntensity: number;
  67918. /**
  67919. * 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))
  67920. */
  67921. direction: Vector2;
  67922. /**
  67923. * 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))
  67924. */
  67925. centerPosition: Vector2;
  67926. /**
  67927. * Creates a new instance ChromaticAberrationPostProcess
  67928. * @param name The name of the effect.
  67929. * @param screenWidth The width of the screen to apply the effect on.
  67930. * @param screenHeight The height of the screen to apply the effect on.
  67931. * @param options The required width/height ratio to downsize to before computing the render pass.
  67932. * @param camera The camera to apply the render pass to.
  67933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67934. * @param engine The engine which the post process will be applied. (default: current engine)
  67935. * @param reusable If the post process can be reused on the same frame. (default: false)
  67936. * @param textureType Type of textures used when performing the post process. (default: 0)
  67937. * @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)
  67938. */
  67939. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67940. }
  67941. }
  67942. declare module BABYLON {
  67943. /** @hidden */
  67944. export var circleOfConfusionPixelShader: {
  67945. name: string;
  67946. shader: string;
  67947. };
  67948. }
  67949. declare module BABYLON {
  67950. /**
  67951. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67952. */
  67953. export class CircleOfConfusionPostProcess extends PostProcess {
  67954. /**
  67955. * 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.
  67956. */
  67957. lensSize: number;
  67958. /**
  67959. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67960. */
  67961. fStop: number;
  67962. /**
  67963. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67964. */
  67965. focusDistance: number;
  67966. /**
  67967. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67968. */
  67969. focalLength: number;
  67970. private _depthTexture;
  67971. /**
  67972. * Creates a new instance CircleOfConfusionPostProcess
  67973. * @param name The name of the effect.
  67974. * @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.
  67975. * @param options The required width/height ratio to downsize to before computing the render pass.
  67976. * @param camera The camera to apply the render pass to.
  67977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67978. * @param engine The engine which the post process will be applied. (default: current engine)
  67979. * @param reusable If the post process can be reused on the same frame. (default: false)
  67980. * @param textureType Type of textures used when performing the post process. (default: 0)
  67981. * @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)
  67982. */
  67983. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67984. /**
  67985. * 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.
  67986. */
  67987. set depthTexture(value: RenderTargetTexture);
  67988. }
  67989. }
  67990. declare module BABYLON {
  67991. /** @hidden */
  67992. export var colorCorrectionPixelShader: {
  67993. name: string;
  67994. shader: string;
  67995. };
  67996. }
  67997. declare module BABYLON {
  67998. /**
  67999. *
  68000. * This post-process allows the modification of rendered colors by using
  68001. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68002. *
  68003. * The object needs to be provided an url to a texture containing the color
  68004. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68005. * Use an image editing software to tweak the LUT to match your needs.
  68006. *
  68007. * For an example of a color LUT, see here:
  68008. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68009. * For explanations on color grading, see here:
  68010. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68011. *
  68012. */
  68013. export class ColorCorrectionPostProcess extends PostProcess {
  68014. private _colorTableTexture;
  68015. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68016. }
  68017. }
  68018. declare module BABYLON {
  68019. /** @hidden */
  68020. export var convolutionPixelShader: {
  68021. name: string;
  68022. shader: string;
  68023. };
  68024. }
  68025. declare module BABYLON {
  68026. /**
  68027. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68028. * input texture to perform effects such as edge detection or sharpening
  68029. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68030. */
  68031. export class ConvolutionPostProcess extends PostProcess {
  68032. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68033. kernel: number[];
  68034. /**
  68035. * Creates a new instance ConvolutionPostProcess
  68036. * @param name The name of the effect.
  68037. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68038. * @param options The required width/height ratio to downsize to before computing the render pass.
  68039. * @param camera The camera to apply the render pass to.
  68040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68041. * @param engine The engine which the post process will be applied. (default: current engine)
  68042. * @param reusable If the post process can be reused on the same frame. (default: false)
  68043. * @param textureType Type of textures used when performing the post process. (default: 0)
  68044. */
  68045. constructor(name: string,
  68046. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68047. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68048. /**
  68049. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68050. */
  68051. static EdgeDetect0Kernel: number[];
  68052. /**
  68053. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68054. */
  68055. static EdgeDetect1Kernel: number[];
  68056. /**
  68057. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68058. */
  68059. static EdgeDetect2Kernel: number[];
  68060. /**
  68061. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68062. */
  68063. static SharpenKernel: number[];
  68064. /**
  68065. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68066. */
  68067. static EmbossKernel: number[];
  68068. /**
  68069. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68070. */
  68071. static GaussianKernel: number[];
  68072. }
  68073. }
  68074. declare module BABYLON {
  68075. /**
  68076. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68077. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68078. * based on samples that have a large difference in distance than the center pixel.
  68079. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68080. */
  68081. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68082. direction: Vector2;
  68083. /**
  68084. * Creates a new instance CircleOfConfusionPostProcess
  68085. * @param name The name of the effect.
  68086. * @param scene The scene the effect belongs to.
  68087. * @param direction The direction the blur should be applied.
  68088. * @param kernel The size of the kernel used to blur.
  68089. * @param options The required width/height ratio to downsize to before computing the render pass.
  68090. * @param camera The camera to apply the render pass to.
  68091. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68092. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68094. * @param engine The engine which the post process will be applied. (default: current engine)
  68095. * @param reusable If the post process can be reused on the same frame. (default: false)
  68096. * @param textureType Type of textures used when performing the post process. (default: 0)
  68097. * @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)
  68098. */
  68099. 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);
  68100. }
  68101. }
  68102. declare module BABYLON {
  68103. /** @hidden */
  68104. export var depthOfFieldMergePixelShader: {
  68105. name: string;
  68106. shader: string;
  68107. };
  68108. }
  68109. declare module BABYLON {
  68110. /**
  68111. * Options to be set when merging outputs from the default pipeline.
  68112. */
  68113. export class DepthOfFieldMergePostProcessOptions {
  68114. /**
  68115. * The original image to merge on top of
  68116. */
  68117. originalFromInput: PostProcess;
  68118. /**
  68119. * Parameters to perform the merge of the depth of field effect
  68120. */
  68121. depthOfField?: {
  68122. circleOfConfusion: PostProcess;
  68123. blurSteps: Array<PostProcess>;
  68124. };
  68125. /**
  68126. * Parameters to perform the merge of bloom effect
  68127. */
  68128. bloom?: {
  68129. blurred: PostProcess;
  68130. weight: number;
  68131. };
  68132. }
  68133. /**
  68134. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68135. */
  68136. export class DepthOfFieldMergePostProcess extends PostProcess {
  68137. private blurSteps;
  68138. /**
  68139. * Creates a new instance of DepthOfFieldMergePostProcess
  68140. * @param name The name of the effect.
  68141. * @param originalFromInput Post process which's input will be used for the merge.
  68142. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68143. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68144. * @param options The required width/height ratio to downsize to before computing the render pass.
  68145. * @param camera The camera to apply the render pass to.
  68146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68147. * @param engine The engine which the post process will be applied. (default: current engine)
  68148. * @param reusable If the post process can be reused on the same frame. (default: false)
  68149. * @param textureType Type of textures used when performing the post process. (default: 0)
  68150. * @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)
  68151. */
  68152. 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);
  68153. /**
  68154. * Updates the effect with the current post process compile time values and recompiles the shader.
  68155. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68156. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68157. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68158. * @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
  68159. * @param onCompiled Called when the shader has been compiled.
  68160. * @param onError Called if there is an error when compiling a shader.
  68161. */
  68162. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68163. }
  68164. }
  68165. declare module BABYLON {
  68166. /**
  68167. * Specifies the level of max blur that should be applied when using the depth of field effect
  68168. */
  68169. export enum DepthOfFieldEffectBlurLevel {
  68170. /**
  68171. * Subtle blur
  68172. */
  68173. Low = 0,
  68174. /**
  68175. * Medium blur
  68176. */
  68177. Medium = 1,
  68178. /**
  68179. * Large blur
  68180. */
  68181. High = 2
  68182. }
  68183. /**
  68184. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68185. */
  68186. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68187. private _circleOfConfusion;
  68188. /**
  68189. * @hidden Internal, blurs from high to low
  68190. */
  68191. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68192. private _depthOfFieldBlurY;
  68193. private _dofMerge;
  68194. /**
  68195. * @hidden Internal post processes in depth of field effect
  68196. */
  68197. _effects: Array<PostProcess>;
  68198. /**
  68199. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68200. */
  68201. set focalLength(value: number);
  68202. get focalLength(): number;
  68203. /**
  68204. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68205. */
  68206. set fStop(value: number);
  68207. get fStop(): number;
  68208. /**
  68209. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68210. */
  68211. set focusDistance(value: number);
  68212. get focusDistance(): number;
  68213. /**
  68214. * 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.
  68215. */
  68216. set lensSize(value: number);
  68217. get lensSize(): number;
  68218. /**
  68219. * Creates a new instance DepthOfFieldEffect
  68220. * @param scene The scene the effect belongs to.
  68221. * @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.
  68222. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68223. * @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)
  68224. */
  68225. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68226. /**
  68227. * Get the current class name of the current effet
  68228. * @returns "DepthOfFieldEffect"
  68229. */
  68230. getClassName(): string;
  68231. /**
  68232. * 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.
  68233. */
  68234. set depthTexture(value: RenderTargetTexture);
  68235. /**
  68236. * Disposes each of the internal effects for a given camera.
  68237. * @param camera The camera to dispose the effect on.
  68238. */
  68239. disposeEffects(camera: Camera): void;
  68240. /**
  68241. * @hidden Internal
  68242. */
  68243. _updateEffects(): void;
  68244. /**
  68245. * Internal
  68246. * @returns if all the contained post processes are ready.
  68247. * @hidden
  68248. */
  68249. _isReady(): boolean;
  68250. }
  68251. }
  68252. declare module BABYLON {
  68253. /** @hidden */
  68254. export var displayPassPixelShader: {
  68255. name: string;
  68256. shader: string;
  68257. };
  68258. }
  68259. declare module BABYLON {
  68260. /**
  68261. * DisplayPassPostProcess which produces an output the same as it's input
  68262. */
  68263. export class DisplayPassPostProcess extends PostProcess {
  68264. /**
  68265. * Creates the DisplayPassPostProcess
  68266. * @param name The name of the effect.
  68267. * @param options The required width/height ratio to downsize to before computing the render pass.
  68268. * @param camera The camera to apply the render pass to.
  68269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68270. * @param engine The engine which the post process will be applied. (default: current engine)
  68271. * @param reusable If the post process can be reused on the same frame. (default: false)
  68272. */
  68273. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68274. }
  68275. }
  68276. declare module BABYLON {
  68277. /** @hidden */
  68278. export var filterPixelShader: {
  68279. name: string;
  68280. shader: string;
  68281. };
  68282. }
  68283. declare module BABYLON {
  68284. /**
  68285. * Applies a kernel filter to the image
  68286. */
  68287. export class FilterPostProcess extends PostProcess {
  68288. /** The matrix to be applied to the image */
  68289. kernelMatrix: Matrix;
  68290. /**
  68291. *
  68292. * @param name The name of the effect.
  68293. * @param kernelMatrix The matrix to be applied to the image
  68294. * @param options The required width/height ratio to downsize to before computing the render pass.
  68295. * @param camera The camera to apply the render pass to.
  68296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68297. * @param engine The engine which the post process will be applied. (default: current engine)
  68298. * @param reusable If the post process can be reused on the same frame. (default: false)
  68299. */
  68300. constructor(name: string,
  68301. /** The matrix to be applied to the image */
  68302. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68303. }
  68304. }
  68305. declare module BABYLON {
  68306. /** @hidden */
  68307. export var fxaaPixelShader: {
  68308. name: string;
  68309. shader: string;
  68310. };
  68311. }
  68312. declare module BABYLON {
  68313. /** @hidden */
  68314. export var fxaaVertexShader: {
  68315. name: string;
  68316. shader: string;
  68317. };
  68318. }
  68319. declare module BABYLON {
  68320. /**
  68321. * Fxaa post process
  68322. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68323. */
  68324. export class FxaaPostProcess extends PostProcess {
  68325. /** @hidden */
  68326. texelWidth: number;
  68327. /** @hidden */
  68328. texelHeight: number;
  68329. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68330. private _getDefines;
  68331. }
  68332. }
  68333. declare module BABYLON {
  68334. /** @hidden */
  68335. export var grainPixelShader: {
  68336. name: string;
  68337. shader: string;
  68338. };
  68339. }
  68340. declare module BABYLON {
  68341. /**
  68342. * The GrainPostProcess adds noise to the image at mid luminance levels
  68343. */
  68344. export class GrainPostProcess extends PostProcess {
  68345. /**
  68346. * The intensity of the grain added (default: 30)
  68347. */
  68348. intensity: number;
  68349. /**
  68350. * If the grain should be randomized on every frame
  68351. */
  68352. animated: boolean;
  68353. /**
  68354. * Creates a new instance of @see GrainPostProcess
  68355. * @param name The name of the effect.
  68356. * @param options The required width/height ratio to downsize to before computing the render pass.
  68357. * @param camera The camera to apply the render pass to.
  68358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68359. * @param engine The engine which the post process will be applied. (default: current engine)
  68360. * @param reusable If the post process can be reused on the same frame. (default: false)
  68361. * @param textureType Type of textures used when performing the post process. (default: 0)
  68362. * @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)
  68363. */
  68364. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68365. }
  68366. }
  68367. declare module BABYLON {
  68368. /** @hidden */
  68369. export var highlightsPixelShader: {
  68370. name: string;
  68371. shader: string;
  68372. };
  68373. }
  68374. declare module BABYLON {
  68375. /**
  68376. * Extracts highlights from the image
  68377. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68378. */
  68379. export class HighlightsPostProcess extends PostProcess {
  68380. /**
  68381. * Extracts highlights from the image
  68382. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68383. * @param name The name of the effect.
  68384. * @param options The required width/height ratio to downsize to before computing the render pass.
  68385. * @param camera The camera to apply the render pass to.
  68386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68387. * @param engine The engine which the post process will be applied. (default: current engine)
  68388. * @param reusable If the post process can be reused on the same frame. (default: false)
  68389. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68390. */
  68391. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68392. }
  68393. }
  68394. declare module BABYLON {
  68395. /** @hidden */
  68396. export var mrtFragmentDeclaration: {
  68397. name: string;
  68398. shader: string;
  68399. };
  68400. }
  68401. declare module BABYLON {
  68402. /** @hidden */
  68403. export var geometryPixelShader: {
  68404. name: string;
  68405. shader: string;
  68406. };
  68407. }
  68408. declare module BABYLON {
  68409. /** @hidden */
  68410. export var geometryVertexShader: {
  68411. name: string;
  68412. shader: string;
  68413. };
  68414. }
  68415. declare module BABYLON {
  68416. /** @hidden */
  68417. interface ISavedTransformationMatrix {
  68418. world: Matrix;
  68419. viewProjection: Matrix;
  68420. }
  68421. /**
  68422. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68423. */
  68424. export class GeometryBufferRenderer {
  68425. /**
  68426. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68427. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68428. */
  68429. static readonly POSITION_TEXTURE_TYPE: number;
  68430. /**
  68431. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68432. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68433. */
  68434. static readonly VELOCITY_TEXTURE_TYPE: number;
  68435. /**
  68436. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68437. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68438. */
  68439. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68440. /**
  68441. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68442. * in order to compute objects velocities when enableVelocity is set to "true"
  68443. * @hidden
  68444. */
  68445. _previousTransformationMatrices: {
  68446. [index: number]: ISavedTransformationMatrix;
  68447. };
  68448. /**
  68449. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68450. * in order to compute objects velocities when enableVelocity is set to "true"
  68451. * @hidden
  68452. */
  68453. _previousBonesTransformationMatrices: {
  68454. [index: number]: Float32Array;
  68455. };
  68456. /**
  68457. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68458. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68459. */
  68460. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68461. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68462. renderTransparentMeshes: boolean;
  68463. private _scene;
  68464. private _multiRenderTarget;
  68465. private _ratio;
  68466. private _enablePosition;
  68467. private _enableVelocity;
  68468. private _enableReflectivity;
  68469. private _positionIndex;
  68470. private _velocityIndex;
  68471. private _reflectivityIndex;
  68472. protected _effect: Effect;
  68473. protected _cachedDefines: string;
  68474. /**
  68475. * Set the render list (meshes to be rendered) used in the G buffer.
  68476. */
  68477. set renderList(meshes: Mesh[]);
  68478. /**
  68479. * Gets wether or not G buffer are supported by the running hardware.
  68480. * This requires draw buffer supports
  68481. */
  68482. get isSupported(): boolean;
  68483. /**
  68484. * Returns the index of the given texture type in the G-Buffer textures array
  68485. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68486. * @returns the index of the given texture type in the G-Buffer textures array
  68487. */
  68488. getTextureIndex(textureType: number): number;
  68489. /**
  68490. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68491. */
  68492. get enablePosition(): boolean;
  68493. /**
  68494. * Sets whether or not objects positions are enabled for the G buffer.
  68495. */
  68496. set enablePosition(enable: boolean);
  68497. /**
  68498. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68499. */
  68500. get enableVelocity(): boolean;
  68501. /**
  68502. * Sets wether or not objects velocities are enabled for the G buffer.
  68503. */
  68504. set enableVelocity(enable: boolean);
  68505. /**
  68506. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68507. */
  68508. get enableReflectivity(): boolean;
  68509. /**
  68510. * Sets wether or not objects roughness are enabled for the G buffer.
  68511. */
  68512. set enableReflectivity(enable: boolean);
  68513. /**
  68514. * Gets the scene associated with the buffer.
  68515. */
  68516. get scene(): Scene;
  68517. /**
  68518. * Gets the ratio used by the buffer during its creation.
  68519. * How big is the buffer related to the main canvas.
  68520. */
  68521. get ratio(): number;
  68522. /** @hidden */
  68523. static _SceneComponentInitialization: (scene: Scene) => void;
  68524. /**
  68525. * Creates a new G Buffer for the scene
  68526. * @param scene The scene the buffer belongs to
  68527. * @param ratio How big is the buffer related to the main canvas.
  68528. */
  68529. constructor(scene: Scene, ratio?: number);
  68530. /**
  68531. * Checks wether everything is ready to render a submesh to the G buffer.
  68532. * @param subMesh the submesh to check readiness for
  68533. * @param useInstances is the mesh drawn using instance or not
  68534. * @returns true if ready otherwise false
  68535. */
  68536. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68537. /**
  68538. * Gets the current underlying G Buffer.
  68539. * @returns the buffer
  68540. */
  68541. getGBuffer(): MultiRenderTarget;
  68542. /**
  68543. * Gets the number of samples used to render the buffer (anti aliasing).
  68544. */
  68545. get samples(): number;
  68546. /**
  68547. * Sets the number of samples used to render the buffer (anti aliasing).
  68548. */
  68549. set samples(value: number);
  68550. /**
  68551. * Disposes the renderer and frees up associated resources.
  68552. */
  68553. dispose(): void;
  68554. protected _createRenderTargets(): void;
  68555. private _copyBonesTransformationMatrices;
  68556. }
  68557. }
  68558. declare module BABYLON {
  68559. interface Scene {
  68560. /** @hidden (Backing field) */
  68561. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68562. /**
  68563. * Gets or Sets the current geometry buffer associated to the scene.
  68564. */
  68565. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68566. /**
  68567. * Enables a GeometryBufferRender and associates it with the scene
  68568. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68569. * @returns the GeometryBufferRenderer
  68570. */
  68571. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68572. /**
  68573. * Disables the GeometryBufferRender associated with the scene
  68574. */
  68575. disableGeometryBufferRenderer(): void;
  68576. }
  68577. /**
  68578. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68579. * in several rendering techniques.
  68580. */
  68581. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68582. /**
  68583. * The component name helpful to identify the component in the list of scene components.
  68584. */
  68585. readonly name: string;
  68586. /**
  68587. * The scene the component belongs to.
  68588. */
  68589. scene: Scene;
  68590. /**
  68591. * Creates a new instance of the component for the given scene
  68592. * @param scene Defines the scene to register the component in
  68593. */
  68594. constructor(scene: Scene);
  68595. /**
  68596. * Registers the component in a given scene
  68597. */
  68598. register(): void;
  68599. /**
  68600. * Rebuilds the elements related to this component in case of
  68601. * context lost for instance.
  68602. */
  68603. rebuild(): void;
  68604. /**
  68605. * Disposes the component and the associated ressources
  68606. */
  68607. dispose(): void;
  68608. private _gatherRenderTargets;
  68609. }
  68610. }
  68611. declare module BABYLON {
  68612. /** @hidden */
  68613. export var motionBlurPixelShader: {
  68614. name: string;
  68615. shader: string;
  68616. };
  68617. }
  68618. declare module BABYLON {
  68619. /**
  68620. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68621. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68622. * As an example, all you have to do is to create the post-process:
  68623. * var mb = new BABYLON.MotionBlurPostProcess(
  68624. * 'mb', // The name of the effect.
  68625. * scene, // The scene containing the objects to blur according to their velocity.
  68626. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68627. * camera // The camera to apply the render pass to.
  68628. * );
  68629. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68630. */
  68631. export class MotionBlurPostProcess extends PostProcess {
  68632. /**
  68633. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68634. */
  68635. motionStrength: number;
  68636. /**
  68637. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68638. */
  68639. get motionBlurSamples(): number;
  68640. /**
  68641. * Sets the number of iterations to be used for motion blur quality
  68642. */
  68643. set motionBlurSamples(samples: number);
  68644. private _motionBlurSamples;
  68645. private _geometryBufferRenderer;
  68646. /**
  68647. * Creates a new instance MotionBlurPostProcess
  68648. * @param name The name of the effect.
  68649. * @param scene The scene containing the objects to blur according to their velocity.
  68650. * @param options The required width/height ratio to downsize to before computing the render pass.
  68651. * @param camera The camera to apply the render pass to.
  68652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68653. * @param engine The engine which the post process will be applied. (default: current engine)
  68654. * @param reusable If the post process can be reused on the same frame. (default: false)
  68655. * @param textureType Type of textures used when performing the post process. (default: 0)
  68656. * @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)
  68657. */
  68658. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68659. /**
  68660. * Excludes the given skinned mesh from computing bones velocities.
  68661. * 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.
  68662. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68663. */
  68664. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68665. /**
  68666. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68667. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68668. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68669. */
  68670. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68671. /**
  68672. * Disposes the post process.
  68673. * @param camera The camera to dispose the post process on.
  68674. */
  68675. dispose(camera?: Camera): void;
  68676. }
  68677. }
  68678. declare module BABYLON {
  68679. /** @hidden */
  68680. export var refractionPixelShader: {
  68681. name: string;
  68682. shader: string;
  68683. };
  68684. }
  68685. declare module BABYLON {
  68686. /**
  68687. * Post process which applies a refractin texture
  68688. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68689. */
  68690. export class RefractionPostProcess extends PostProcess {
  68691. /** the base color of the refraction (used to taint the rendering) */
  68692. color: Color3;
  68693. /** simulated refraction depth */
  68694. depth: number;
  68695. /** the coefficient of the base color (0 to remove base color tainting) */
  68696. colorLevel: number;
  68697. private _refTexture;
  68698. private _ownRefractionTexture;
  68699. /**
  68700. * Gets or sets the refraction texture
  68701. * Please note that you are responsible for disposing the texture if you set it manually
  68702. */
  68703. get refractionTexture(): Texture;
  68704. set refractionTexture(value: Texture);
  68705. /**
  68706. * Initializes the RefractionPostProcess
  68707. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68708. * @param name The name of the effect.
  68709. * @param refractionTextureUrl Url of the refraction texture to use
  68710. * @param color the base color of the refraction (used to taint the rendering)
  68711. * @param depth simulated refraction depth
  68712. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68713. * @param camera The camera to apply the render pass to.
  68714. * @param options The required width/height ratio to downsize to before computing the render pass.
  68715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68716. * @param engine The engine which the post process will be applied. (default: current engine)
  68717. * @param reusable If the post process can be reused on the same frame. (default: false)
  68718. */
  68719. constructor(name: string, refractionTextureUrl: string,
  68720. /** the base color of the refraction (used to taint the rendering) */
  68721. color: Color3,
  68722. /** simulated refraction depth */
  68723. depth: number,
  68724. /** the coefficient of the base color (0 to remove base color tainting) */
  68725. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68726. /**
  68727. * Disposes of the post process
  68728. * @param camera Camera to dispose post process on
  68729. */
  68730. dispose(camera: Camera): void;
  68731. }
  68732. }
  68733. declare module BABYLON {
  68734. /** @hidden */
  68735. export var sharpenPixelShader: {
  68736. name: string;
  68737. shader: string;
  68738. };
  68739. }
  68740. declare module BABYLON {
  68741. /**
  68742. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68743. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68744. */
  68745. export class SharpenPostProcess extends PostProcess {
  68746. /**
  68747. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68748. */
  68749. colorAmount: number;
  68750. /**
  68751. * How much sharpness should be applied (default: 0.3)
  68752. */
  68753. edgeAmount: number;
  68754. /**
  68755. * Creates a new instance ConvolutionPostProcess
  68756. * @param name The name of the effect.
  68757. * @param options The required width/height ratio to downsize to before computing the render pass.
  68758. * @param camera The camera to apply the render pass to.
  68759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68760. * @param engine The engine which the post process will be applied. (default: current engine)
  68761. * @param reusable If the post process can be reused on the same frame. (default: false)
  68762. * @param textureType Type of textures used when performing the post process. (default: 0)
  68763. * @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)
  68764. */
  68765. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68766. }
  68767. }
  68768. declare module BABYLON {
  68769. /**
  68770. * PostProcessRenderPipeline
  68771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68772. */
  68773. export class PostProcessRenderPipeline {
  68774. private engine;
  68775. private _renderEffects;
  68776. private _renderEffectsForIsolatedPass;
  68777. /**
  68778. * List of inspectable custom properties (used by the Inspector)
  68779. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68780. */
  68781. inspectableCustomProperties: IInspectable[];
  68782. /**
  68783. * @hidden
  68784. */
  68785. protected _cameras: Camera[];
  68786. /** @hidden */
  68787. _name: string;
  68788. /**
  68789. * Gets pipeline name
  68790. */
  68791. get name(): string;
  68792. /** Gets the list of attached cameras */
  68793. get cameras(): Camera[];
  68794. /**
  68795. * Initializes a PostProcessRenderPipeline
  68796. * @param engine engine to add the pipeline to
  68797. * @param name name of the pipeline
  68798. */
  68799. constructor(engine: Engine, name: string);
  68800. /**
  68801. * Gets the class name
  68802. * @returns "PostProcessRenderPipeline"
  68803. */
  68804. getClassName(): string;
  68805. /**
  68806. * If all the render effects in the pipeline are supported
  68807. */
  68808. get isSupported(): boolean;
  68809. /**
  68810. * Adds an effect to the pipeline
  68811. * @param renderEffect the effect to add
  68812. */
  68813. addEffect(renderEffect: PostProcessRenderEffect): void;
  68814. /** @hidden */
  68815. _rebuild(): void;
  68816. /** @hidden */
  68817. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68818. /** @hidden */
  68819. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68820. /** @hidden */
  68821. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68822. /** @hidden */
  68823. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68824. /** @hidden */
  68825. _attachCameras(cameras: Camera, unique: boolean): void;
  68826. /** @hidden */
  68827. _attachCameras(cameras: Camera[], unique: boolean): void;
  68828. /** @hidden */
  68829. _detachCameras(cameras: Camera): void;
  68830. /** @hidden */
  68831. _detachCameras(cameras: Nullable<Camera[]>): void;
  68832. /** @hidden */
  68833. _update(): void;
  68834. /** @hidden */
  68835. _reset(): void;
  68836. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68837. /**
  68838. * Disposes of the pipeline
  68839. */
  68840. dispose(): void;
  68841. }
  68842. }
  68843. declare module BABYLON {
  68844. /**
  68845. * PostProcessRenderPipelineManager class
  68846. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68847. */
  68848. export class PostProcessRenderPipelineManager {
  68849. private _renderPipelines;
  68850. /**
  68851. * Initializes a PostProcessRenderPipelineManager
  68852. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68853. */
  68854. constructor();
  68855. /**
  68856. * Gets the list of supported render pipelines
  68857. */
  68858. get supportedPipelines(): PostProcessRenderPipeline[];
  68859. /**
  68860. * Adds a pipeline to the manager
  68861. * @param renderPipeline The pipeline to add
  68862. */
  68863. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68864. /**
  68865. * Attaches a camera to the pipeline
  68866. * @param renderPipelineName The name of the pipeline to attach to
  68867. * @param cameras the camera to attach
  68868. * @param unique if the camera can be attached multiple times to the pipeline
  68869. */
  68870. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68871. /**
  68872. * Detaches a camera from the pipeline
  68873. * @param renderPipelineName The name of the pipeline to detach from
  68874. * @param cameras the camera to detach
  68875. */
  68876. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68877. /**
  68878. * Enables an effect by name on a pipeline
  68879. * @param renderPipelineName the name of the pipeline to enable the effect in
  68880. * @param renderEffectName the name of the effect to enable
  68881. * @param cameras the cameras that the effect should be enabled on
  68882. */
  68883. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68884. /**
  68885. * Disables an effect by name on a pipeline
  68886. * @param renderPipelineName the name of the pipeline to disable the effect in
  68887. * @param renderEffectName the name of the effect to disable
  68888. * @param cameras the cameras that the effect should be disabled on
  68889. */
  68890. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68891. /**
  68892. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68893. */
  68894. update(): void;
  68895. /** @hidden */
  68896. _rebuild(): void;
  68897. /**
  68898. * Disposes of the manager and pipelines
  68899. */
  68900. dispose(): void;
  68901. }
  68902. }
  68903. declare module BABYLON {
  68904. interface Scene {
  68905. /** @hidden (Backing field) */
  68906. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68907. /**
  68908. * Gets the postprocess render pipeline manager
  68909. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68910. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68911. */
  68912. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68913. }
  68914. /**
  68915. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68916. */
  68917. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68918. /**
  68919. * The component name helpfull to identify the component in the list of scene components.
  68920. */
  68921. readonly name: string;
  68922. /**
  68923. * The scene the component belongs to.
  68924. */
  68925. scene: Scene;
  68926. /**
  68927. * Creates a new instance of the component for the given scene
  68928. * @param scene Defines the scene to register the component in
  68929. */
  68930. constructor(scene: Scene);
  68931. /**
  68932. * Registers the component in a given scene
  68933. */
  68934. register(): void;
  68935. /**
  68936. * Rebuilds the elements related to this component in case of
  68937. * context lost for instance.
  68938. */
  68939. rebuild(): void;
  68940. /**
  68941. * Disposes the component and the associated ressources
  68942. */
  68943. dispose(): void;
  68944. private _gatherRenderTargets;
  68945. }
  68946. }
  68947. declare module BABYLON {
  68948. /**
  68949. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68950. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68951. */
  68952. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68953. private _scene;
  68954. private _camerasToBeAttached;
  68955. /**
  68956. * ID of the sharpen post process,
  68957. */
  68958. private readonly SharpenPostProcessId;
  68959. /**
  68960. * @ignore
  68961. * ID of the image processing post process;
  68962. */
  68963. readonly ImageProcessingPostProcessId: string;
  68964. /**
  68965. * @ignore
  68966. * ID of the Fast Approximate Anti-Aliasing post process;
  68967. */
  68968. readonly FxaaPostProcessId: string;
  68969. /**
  68970. * ID of the chromatic aberration post process,
  68971. */
  68972. private readonly ChromaticAberrationPostProcessId;
  68973. /**
  68974. * ID of the grain post process
  68975. */
  68976. private readonly GrainPostProcessId;
  68977. /**
  68978. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68979. */
  68980. sharpen: SharpenPostProcess;
  68981. private _sharpenEffect;
  68982. private bloom;
  68983. /**
  68984. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68985. */
  68986. depthOfField: DepthOfFieldEffect;
  68987. /**
  68988. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68989. */
  68990. fxaa: FxaaPostProcess;
  68991. /**
  68992. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68993. */
  68994. imageProcessing: ImageProcessingPostProcess;
  68995. /**
  68996. * Chromatic aberration post process which will shift rgb colors in the image
  68997. */
  68998. chromaticAberration: ChromaticAberrationPostProcess;
  68999. private _chromaticAberrationEffect;
  69000. /**
  69001. * Grain post process which add noise to the image
  69002. */
  69003. grain: GrainPostProcess;
  69004. private _grainEffect;
  69005. /**
  69006. * Glow post process which adds a glow to emissive areas of the image
  69007. */
  69008. private _glowLayer;
  69009. /**
  69010. * Animations which can be used to tweak settings over a period of time
  69011. */
  69012. animations: Animation[];
  69013. private _imageProcessingConfigurationObserver;
  69014. private _sharpenEnabled;
  69015. private _bloomEnabled;
  69016. private _depthOfFieldEnabled;
  69017. private _depthOfFieldBlurLevel;
  69018. private _fxaaEnabled;
  69019. private _imageProcessingEnabled;
  69020. private _defaultPipelineTextureType;
  69021. private _bloomScale;
  69022. private _chromaticAberrationEnabled;
  69023. private _grainEnabled;
  69024. private _buildAllowed;
  69025. /**
  69026. * Gets active scene
  69027. */
  69028. get scene(): Scene;
  69029. /**
  69030. * Enable or disable the sharpen process from the pipeline
  69031. */
  69032. set sharpenEnabled(enabled: boolean);
  69033. get sharpenEnabled(): boolean;
  69034. private _resizeObserver;
  69035. private _hardwareScaleLevel;
  69036. private _bloomKernel;
  69037. /**
  69038. * Specifies the size of the bloom blur kernel, relative to the final output size
  69039. */
  69040. get bloomKernel(): number;
  69041. set bloomKernel(value: number);
  69042. /**
  69043. * Specifies the weight of the bloom in the final rendering
  69044. */
  69045. private _bloomWeight;
  69046. /**
  69047. * Specifies the luma threshold for the area that will be blurred by the bloom
  69048. */
  69049. private _bloomThreshold;
  69050. private _hdr;
  69051. /**
  69052. * The strength of the bloom.
  69053. */
  69054. set bloomWeight(value: number);
  69055. get bloomWeight(): number;
  69056. /**
  69057. * The strength of the bloom.
  69058. */
  69059. set bloomThreshold(value: number);
  69060. get bloomThreshold(): number;
  69061. /**
  69062. * The scale of the bloom, lower value will provide better performance.
  69063. */
  69064. set bloomScale(value: number);
  69065. get bloomScale(): number;
  69066. /**
  69067. * Enable or disable the bloom from the pipeline
  69068. */
  69069. set bloomEnabled(enabled: boolean);
  69070. get bloomEnabled(): boolean;
  69071. private _rebuildBloom;
  69072. /**
  69073. * If the depth of field is enabled.
  69074. */
  69075. get depthOfFieldEnabled(): boolean;
  69076. set depthOfFieldEnabled(enabled: boolean);
  69077. /**
  69078. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69079. */
  69080. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69081. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69082. /**
  69083. * If the anti aliasing is enabled.
  69084. */
  69085. set fxaaEnabled(enabled: boolean);
  69086. get fxaaEnabled(): boolean;
  69087. private _samples;
  69088. /**
  69089. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69090. */
  69091. set samples(sampleCount: number);
  69092. get samples(): number;
  69093. /**
  69094. * If image processing is enabled.
  69095. */
  69096. set imageProcessingEnabled(enabled: boolean);
  69097. get imageProcessingEnabled(): boolean;
  69098. /**
  69099. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69100. */
  69101. set glowLayerEnabled(enabled: boolean);
  69102. get glowLayerEnabled(): boolean;
  69103. /**
  69104. * Gets the glow layer (or null if not defined)
  69105. */
  69106. get glowLayer(): Nullable<GlowLayer>;
  69107. /**
  69108. * Enable or disable the chromaticAberration process from the pipeline
  69109. */
  69110. set chromaticAberrationEnabled(enabled: boolean);
  69111. get chromaticAberrationEnabled(): boolean;
  69112. /**
  69113. * Enable or disable the grain process from the pipeline
  69114. */
  69115. set grainEnabled(enabled: boolean);
  69116. get grainEnabled(): boolean;
  69117. /**
  69118. * @constructor
  69119. * @param name - The rendering pipeline name (default: "")
  69120. * @param hdr - If high dynamic range textures should be used (default: true)
  69121. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69122. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69123. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69124. */
  69125. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69126. /**
  69127. * Get the class name
  69128. * @returns "DefaultRenderingPipeline"
  69129. */
  69130. getClassName(): string;
  69131. /**
  69132. * Force the compilation of the entire pipeline.
  69133. */
  69134. prepare(): void;
  69135. private _hasCleared;
  69136. private _prevPostProcess;
  69137. private _prevPrevPostProcess;
  69138. private _setAutoClearAndTextureSharing;
  69139. private _depthOfFieldSceneObserver;
  69140. private _buildPipeline;
  69141. private _disposePostProcesses;
  69142. /**
  69143. * Adds a camera to the pipeline
  69144. * @param camera the camera to be added
  69145. */
  69146. addCamera(camera: Camera): void;
  69147. /**
  69148. * Removes a camera from the pipeline
  69149. * @param camera the camera to remove
  69150. */
  69151. removeCamera(camera: Camera): void;
  69152. /**
  69153. * Dispose of the pipeline and stop all post processes
  69154. */
  69155. dispose(): void;
  69156. /**
  69157. * Serialize the rendering pipeline (Used when exporting)
  69158. * @returns the serialized object
  69159. */
  69160. serialize(): any;
  69161. /**
  69162. * Parse the serialized pipeline
  69163. * @param source Source pipeline.
  69164. * @param scene The scene to load the pipeline to.
  69165. * @param rootUrl The URL of the serialized pipeline.
  69166. * @returns An instantiated pipeline from the serialized object.
  69167. */
  69168. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69169. }
  69170. }
  69171. declare module BABYLON {
  69172. /** @hidden */
  69173. export var lensHighlightsPixelShader: {
  69174. name: string;
  69175. shader: string;
  69176. };
  69177. }
  69178. declare module BABYLON {
  69179. /** @hidden */
  69180. export var depthOfFieldPixelShader: {
  69181. name: string;
  69182. shader: string;
  69183. };
  69184. }
  69185. declare module BABYLON {
  69186. /**
  69187. * BABYLON.JS Chromatic Aberration GLSL Shader
  69188. * Author: Olivier Guyot
  69189. * Separates very slightly R, G and B colors on the edges of the screen
  69190. * Inspired by Francois Tarlier & Martins Upitis
  69191. */
  69192. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69193. /**
  69194. * @ignore
  69195. * The chromatic aberration PostProcess id in the pipeline
  69196. */
  69197. LensChromaticAberrationEffect: string;
  69198. /**
  69199. * @ignore
  69200. * The highlights enhancing PostProcess id in the pipeline
  69201. */
  69202. HighlightsEnhancingEffect: string;
  69203. /**
  69204. * @ignore
  69205. * The depth-of-field PostProcess id in the pipeline
  69206. */
  69207. LensDepthOfFieldEffect: string;
  69208. private _scene;
  69209. private _depthTexture;
  69210. private _grainTexture;
  69211. private _chromaticAberrationPostProcess;
  69212. private _highlightsPostProcess;
  69213. private _depthOfFieldPostProcess;
  69214. private _edgeBlur;
  69215. private _grainAmount;
  69216. private _chromaticAberration;
  69217. private _distortion;
  69218. private _highlightsGain;
  69219. private _highlightsThreshold;
  69220. private _dofDistance;
  69221. private _dofAperture;
  69222. private _dofDarken;
  69223. private _dofPentagon;
  69224. private _blurNoise;
  69225. /**
  69226. * @constructor
  69227. *
  69228. * Effect parameters are as follow:
  69229. * {
  69230. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69231. * edge_blur: number; // from 0 to x (1 for realism)
  69232. * distortion: number; // from 0 to x (1 for realism)
  69233. * grain_amount: number; // from 0 to 1
  69234. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69235. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69236. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69237. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69238. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69239. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69240. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69241. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69242. * }
  69243. * Note: if an effect parameter is unset, effect is disabled
  69244. *
  69245. * @param name The rendering pipeline name
  69246. * @param parameters - An object containing all parameters (see above)
  69247. * @param scene The scene linked to this pipeline
  69248. * @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)
  69249. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69250. */
  69251. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69252. /**
  69253. * Get the class name
  69254. * @returns "LensRenderingPipeline"
  69255. */
  69256. getClassName(): string;
  69257. /**
  69258. * Gets associated scene
  69259. */
  69260. get scene(): Scene;
  69261. /**
  69262. * Gets or sets the edge blur
  69263. */
  69264. get edgeBlur(): number;
  69265. set edgeBlur(value: number);
  69266. /**
  69267. * Gets or sets the grain amount
  69268. */
  69269. get grainAmount(): number;
  69270. set grainAmount(value: number);
  69271. /**
  69272. * Gets or sets the chromatic aberration amount
  69273. */
  69274. get chromaticAberration(): number;
  69275. set chromaticAberration(value: number);
  69276. /**
  69277. * Gets or sets the depth of field aperture
  69278. */
  69279. get dofAperture(): number;
  69280. set dofAperture(value: number);
  69281. /**
  69282. * Gets or sets the edge distortion
  69283. */
  69284. get edgeDistortion(): number;
  69285. set edgeDistortion(value: number);
  69286. /**
  69287. * Gets or sets the depth of field distortion
  69288. */
  69289. get dofDistortion(): number;
  69290. set dofDistortion(value: number);
  69291. /**
  69292. * Gets or sets the darken out of focus amount
  69293. */
  69294. get darkenOutOfFocus(): number;
  69295. set darkenOutOfFocus(value: number);
  69296. /**
  69297. * Gets or sets a boolean indicating if blur noise is enabled
  69298. */
  69299. get blurNoise(): boolean;
  69300. set blurNoise(value: boolean);
  69301. /**
  69302. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69303. */
  69304. get pentagonBokeh(): boolean;
  69305. set pentagonBokeh(value: boolean);
  69306. /**
  69307. * Gets or sets the highlight grain amount
  69308. */
  69309. get highlightsGain(): number;
  69310. set highlightsGain(value: number);
  69311. /**
  69312. * Gets or sets the highlight threshold
  69313. */
  69314. get highlightsThreshold(): number;
  69315. set highlightsThreshold(value: number);
  69316. /**
  69317. * Sets the amount of blur at the edges
  69318. * @param amount blur amount
  69319. */
  69320. setEdgeBlur(amount: number): void;
  69321. /**
  69322. * Sets edge blur to 0
  69323. */
  69324. disableEdgeBlur(): void;
  69325. /**
  69326. * Sets the amout of grain
  69327. * @param amount Amount of grain
  69328. */
  69329. setGrainAmount(amount: number): void;
  69330. /**
  69331. * Set grain amount to 0
  69332. */
  69333. disableGrain(): void;
  69334. /**
  69335. * Sets the chromatic aberration amount
  69336. * @param amount amount of chromatic aberration
  69337. */
  69338. setChromaticAberration(amount: number): void;
  69339. /**
  69340. * Sets chromatic aberration amount to 0
  69341. */
  69342. disableChromaticAberration(): void;
  69343. /**
  69344. * Sets the EdgeDistortion amount
  69345. * @param amount amount of EdgeDistortion
  69346. */
  69347. setEdgeDistortion(amount: number): void;
  69348. /**
  69349. * Sets edge distortion to 0
  69350. */
  69351. disableEdgeDistortion(): void;
  69352. /**
  69353. * Sets the FocusDistance amount
  69354. * @param amount amount of FocusDistance
  69355. */
  69356. setFocusDistance(amount: number): void;
  69357. /**
  69358. * Disables depth of field
  69359. */
  69360. disableDepthOfField(): void;
  69361. /**
  69362. * Sets the Aperture amount
  69363. * @param amount amount of Aperture
  69364. */
  69365. setAperture(amount: number): void;
  69366. /**
  69367. * Sets the DarkenOutOfFocus amount
  69368. * @param amount amount of DarkenOutOfFocus
  69369. */
  69370. setDarkenOutOfFocus(amount: number): void;
  69371. private _pentagonBokehIsEnabled;
  69372. /**
  69373. * Creates a pentagon bokeh effect
  69374. */
  69375. enablePentagonBokeh(): void;
  69376. /**
  69377. * Disables the pentagon bokeh effect
  69378. */
  69379. disablePentagonBokeh(): void;
  69380. /**
  69381. * Enables noise blur
  69382. */
  69383. enableNoiseBlur(): void;
  69384. /**
  69385. * Disables noise blur
  69386. */
  69387. disableNoiseBlur(): void;
  69388. /**
  69389. * Sets the HighlightsGain amount
  69390. * @param amount amount of HighlightsGain
  69391. */
  69392. setHighlightsGain(amount: number): void;
  69393. /**
  69394. * Sets the HighlightsThreshold amount
  69395. * @param amount amount of HighlightsThreshold
  69396. */
  69397. setHighlightsThreshold(amount: number): void;
  69398. /**
  69399. * Disables highlights
  69400. */
  69401. disableHighlights(): void;
  69402. /**
  69403. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69404. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69405. */
  69406. dispose(disableDepthRender?: boolean): void;
  69407. private _createChromaticAberrationPostProcess;
  69408. private _createHighlightsPostProcess;
  69409. private _createDepthOfFieldPostProcess;
  69410. private _createGrainTexture;
  69411. }
  69412. }
  69413. declare module BABYLON {
  69414. /** @hidden */
  69415. export var ssao2PixelShader: {
  69416. name: string;
  69417. shader: string;
  69418. };
  69419. }
  69420. declare module BABYLON {
  69421. /** @hidden */
  69422. export var ssaoCombinePixelShader: {
  69423. name: string;
  69424. shader: string;
  69425. };
  69426. }
  69427. declare module BABYLON {
  69428. /**
  69429. * Render pipeline to produce ssao effect
  69430. */
  69431. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69432. /**
  69433. * @ignore
  69434. * The PassPostProcess id in the pipeline that contains the original scene color
  69435. */
  69436. SSAOOriginalSceneColorEffect: string;
  69437. /**
  69438. * @ignore
  69439. * The SSAO PostProcess id in the pipeline
  69440. */
  69441. SSAORenderEffect: string;
  69442. /**
  69443. * @ignore
  69444. * The horizontal blur PostProcess id in the pipeline
  69445. */
  69446. SSAOBlurHRenderEffect: string;
  69447. /**
  69448. * @ignore
  69449. * The vertical blur PostProcess id in the pipeline
  69450. */
  69451. SSAOBlurVRenderEffect: string;
  69452. /**
  69453. * @ignore
  69454. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69455. */
  69456. SSAOCombineRenderEffect: string;
  69457. /**
  69458. * The output strength of the SSAO post-process. Default value is 1.0.
  69459. */
  69460. totalStrength: number;
  69461. /**
  69462. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69463. */
  69464. maxZ: number;
  69465. /**
  69466. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69467. */
  69468. minZAspect: number;
  69469. private _samples;
  69470. /**
  69471. * Number of samples used for the SSAO calculations. Default value is 8
  69472. */
  69473. set samples(n: number);
  69474. get samples(): number;
  69475. private _textureSamples;
  69476. /**
  69477. * Number of samples to use for antialiasing
  69478. */
  69479. set textureSamples(n: number);
  69480. get textureSamples(): number;
  69481. /**
  69482. * Ratio object used for SSAO ratio and blur ratio
  69483. */
  69484. private _ratio;
  69485. /**
  69486. * Dynamically generated sphere sampler.
  69487. */
  69488. private _sampleSphere;
  69489. /**
  69490. * Blur filter offsets
  69491. */
  69492. private _samplerOffsets;
  69493. private _expensiveBlur;
  69494. /**
  69495. * If bilateral blur should be used
  69496. */
  69497. set expensiveBlur(b: boolean);
  69498. get expensiveBlur(): boolean;
  69499. /**
  69500. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69501. */
  69502. radius: number;
  69503. /**
  69504. * The base color of the SSAO post-process
  69505. * The final result is "base + ssao" between [0, 1]
  69506. */
  69507. base: number;
  69508. /**
  69509. * Support test.
  69510. */
  69511. static get IsSupported(): boolean;
  69512. private _scene;
  69513. private _depthTexture;
  69514. private _normalTexture;
  69515. private _randomTexture;
  69516. private _originalColorPostProcess;
  69517. private _ssaoPostProcess;
  69518. private _blurHPostProcess;
  69519. private _blurVPostProcess;
  69520. private _ssaoCombinePostProcess;
  69521. /**
  69522. * Gets active scene
  69523. */
  69524. get scene(): Scene;
  69525. /**
  69526. * @constructor
  69527. * @param name The rendering pipeline name
  69528. * @param scene The scene linked to this pipeline
  69529. * @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 }
  69530. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69531. */
  69532. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69533. /**
  69534. * Get the class name
  69535. * @returns "SSAO2RenderingPipeline"
  69536. */
  69537. getClassName(): string;
  69538. /**
  69539. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69540. */
  69541. dispose(disableGeometryBufferRenderer?: boolean): void;
  69542. private _createBlurPostProcess;
  69543. /** @hidden */
  69544. _rebuild(): void;
  69545. private _bits;
  69546. private _radicalInverse_VdC;
  69547. private _hammersley;
  69548. private _hemisphereSample_uniform;
  69549. private _generateHemisphere;
  69550. private _createSSAOPostProcess;
  69551. private _createSSAOCombinePostProcess;
  69552. private _createRandomTexture;
  69553. /**
  69554. * Serialize the rendering pipeline (Used when exporting)
  69555. * @returns the serialized object
  69556. */
  69557. serialize(): any;
  69558. /**
  69559. * Parse the serialized pipeline
  69560. * @param source Source pipeline.
  69561. * @param scene The scene to load the pipeline to.
  69562. * @param rootUrl The URL of the serialized pipeline.
  69563. * @returns An instantiated pipeline from the serialized object.
  69564. */
  69565. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69566. }
  69567. }
  69568. declare module BABYLON {
  69569. /** @hidden */
  69570. export var ssaoPixelShader: {
  69571. name: string;
  69572. shader: string;
  69573. };
  69574. }
  69575. declare module BABYLON {
  69576. /**
  69577. * Render pipeline to produce ssao effect
  69578. */
  69579. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69580. /**
  69581. * @ignore
  69582. * The PassPostProcess id in the pipeline that contains the original scene color
  69583. */
  69584. SSAOOriginalSceneColorEffect: string;
  69585. /**
  69586. * @ignore
  69587. * The SSAO PostProcess id in the pipeline
  69588. */
  69589. SSAORenderEffect: string;
  69590. /**
  69591. * @ignore
  69592. * The horizontal blur PostProcess id in the pipeline
  69593. */
  69594. SSAOBlurHRenderEffect: string;
  69595. /**
  69596. * @ignore
  69597. * The vertical blur PostProcess id in the pipeline
  69598. */
  69599. SSAOBlurVRenderEffect: string;
  69600. /**
  69601. * @ignore
  69602. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69603. */
  69604. SSAOCombineRenderEffect: string;
  69605. /**
  69606. * The output strength of the SSAO post-process. Default value is 1.0.
  69607. */
  69608. totalStrength: number;
  69609. /**
  69610. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69611. */
  69612. radius: number;
  69613. /**
  69614. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69615. * Must not be equal to fallOff and superior to fallOff.
  69616. * Default value is 0.0075
  69617. */
  69618. area: number;
  69619. /**
  69620. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69621. * Must not be equal to area and inferior to area.
  69622. * Default value is 0.000001
  69623. */
  69624. fallOff: number;
  69625. /**
  69626. * The base color of the SSAO post-process
  69627. * The final result is "base + ssao" between [0, 1]
  69628. */
  69629. base: number;
  69630. private _scene;
  69631. private _depthTexture;
  69632. private _randomTexture;
  69633. private _originalColorPostProcess;
  69634. private _ssaoPostProcess;
  69635. private _blurHPostProcess;
  69636. private _blurVPostProcess;
  69637. private _ssaoCombinePostProcess;
  69638. private _firstUpdate;
  69639. /**
  69640. * Gets active scene
  69641. */
  69642. get scene(): Scene;
  69643. /**
  69644. * @constructor
  69645. * @param name - The rendering pipeline name
  69646. * @param scene - The scene linked to this pipeline
  69647. * @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 }
  69648. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69649. */
  69650. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69651. /**
  69652. * Get the class name
  69653. * @returns "SSAORenderingPipeline"
  69654. */
  69655. getClassName(): string;
  69656. /**
  69657. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69658. */
  69659. dispose(disableDepthRender?: boolean): void;
  69660. private _createBlurPostProcess;
  69661. /** @hidden */
  69662. _rebuild(): void;
  69663. private _createSSAOPostProcess;
  69664. private _createSSAOCombinePostProcess;
  69665. private _createRandomTexture;
  69666. }
  69667. }
  69668. declare module BABYLON {
  69669. /** @hidden */
  69670. export var screenSpaceReflectionPixelShader: {
  69671. name: string;
  69672. shader: string;
  69673. };
  69674. }
  69675. declare module BABYLON {
  69676. /**
  69677. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69678. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69679. */
  69680. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69681. /**
  69682. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69683. */
  69684. threshold: number;
  69685. /**
  69686. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69687. */
  69688. strength: number;
  69689. /**
  69690. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69691. */
  69692. reflectionSpecularFalloffExponent: number;
  69693. /**
  69694. * 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]
  69695. */
  69696. step: number;
  69697. /**
  69698. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69699. */
  69700. roughnessFactor: number;
  69701. private _geometryBufferRenderer;
  69702. private _enableSmoothReflections;
  69703. private _reflectionSamples;
  69704. private _smoothSteps;
  69705. /**
  69706. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69707. * @param name The name of the effect.
  69708. * @param scene The scene containing the objects to calculate reflections.
  69709. * @param options The required width/height ratio to downsize to before computing the render pass.
  69710. * @param camera The camera to apply the render pass to.
  69711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69712. * @param engine The engine which the post process will be applied. (default: current engine)
  69713. * @param reusable If the post process can be reused on the same frame. (default: false)
  69714. * @param textureType Type of textures used when performing the post process. (default: 0)
  69715. * @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)
  69716. */
  69717. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69718. /**
  69719. * Gets wether or not smoothing reflections is enabled.
  69720. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69721. */
  69722. get enableSmoothReflections(): boolean;
  69723. /**
  69724. * Sets wether or not smoothing reflections is enabled.
  69725. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69726. */
  69727. set enableSmoothReflections(enabled: boolean);
  69728. /**
  69729. * Gets the number of samples taken while computing reflections. More samples count is high,
  69730. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69731. */
  69732. get reflectionSamples(): number;
  69733. /**
  69734. * Sets the number of samples taken while computing reflections. More samples count is high,
  69735. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69736. */
  69737. set reflectionSamples(samples: number);
  69738. /**
  69739. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69740. * more the post-process will require GPU power and can generate a drop in FPS.
  69741. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69742. */
  69743. get smoothSteps(): number;
  69744. set smoothSteps(steps: number);
  69745. private _updateEffectDefines;
  69746. }
  69747. }
  69748. declare module BABYLON {
  69749. /** @hidden */
  69750. export var standardPixelShader: {
  69751. name: string;
  69752. shader: string;
  69753. };
  69754. }
  69755. declare module BABYLON {
  69756. /**
  69757. * Standard rendering pipeline
  69758. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69759. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69760. */
  69761. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69762. /**
  69763. * Public members
  69764. */
  69765. /**
  69766. * Post-process which contains the original scene color before the pipeline applies all the effects
  69767. */
  69768. originalPostProcess: Nullable<PostProcess>;
  69769. /**
  69770. * Post-process used to down scale an image x4
  69771. */
  69772. downSampleX4PostProcess: Nullable<PostProcess>;
  69773. /**
  69774. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69775. */
  69776. brightPassPostProcess: Nullable<PostProcess>;
  69777. /**
  69778. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69779. */
  69780. blurHPostProcesses: PostProcess[];
  69781. /**
  69782. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69783. */
  69784. blurVPostProcesses: PostProcess[];
  69785. /**
  69786. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69787. */
  69788. textureAdderPostProcess: Nullable<PostProcess>;
  69789. /**
  69790. * Post-process used to create volumetric lighting effect
  69791. */
  69792. volumetricLightPostProcess: Nullable<PostProcess>;
  69793. /**
  69794. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69795. */
  69796. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69797. /**
  69798. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69799. */
  69800. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69801. /**
  69802. * Post-process used to merge the volumetric light effect and the real scene color
  69803. */
  69804. volumetricLightMergePostProces: Nullable<PostProcess>;
  69805. /**
  69806. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69807. */
  69808. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69809. /**
  69810. * Base post-process used to calculate the average luminance of the final image for HDR
  69811. */
  69812. luminancePostProcess: Nullable<PostProcess>;
  69813. /**
  69814. * Post-processes used to create down sample post-processes in order to get
  69815. * the average luminance of the final image for HDR
  69816. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69817. */
  69818. luminanceDownSamplePostProcesses: PostProcess[];
  69819. /**
  69820. * Post-process used to create a HDR effect (light adaptation)
  69821. */
  69822. hdrPostProcess: Nullable<PostProcess>;
  69823. /**
  69824. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69825. */
  69826. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69827. /**
  69828. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69829. */
  69830. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69831. /**
  69832. * Post-process used to merge the final HDR post-process and the real scene color
  69833. */
  69834. hdrFinalPostProcess: Nullable<PostProcess>;
  69835. /**
  69836. * Post-process used to create a lens flare effect
  69837. */
  69838. lensFlarePostProcess: Nullable<PostProcess>;
  69839. /**
  69840. * Post-process that merges the result of the lens flare post-process and the real scene color
  69841. */
  69842. lensFlareComposePostProcess: Nullable<PostProcess>;
  69843. /**
  69844. * Post-process used to create a motion blur effect
  69845. */
  69846. motionBlurPostProcess: Nullable<PostProcess>;
  69847. /**
  69848. * Post-process used to create a depth of field effect
  69849. */
  69850. depthOfFieldPostProcess: Nullable<PostProcess>;
  69851. /**
  69852. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69853. */
  69854. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69855. /**
  69856. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69857. */
  69858. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69859. /**
  69860. * Represents the brightness threshold in order to configure the illuminated surfaces
  69861. */
  69862. brightThreshold: number;
  69863. /**
  69864. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69865. */
  69866. blurWidth: number;
  69867. /**
  69868. * Sets if the blur for highlighted surfaces must be only horizontal
  69869. */
  69870. horizontalBlur: boolean;
  69871. /**
  69872. * Gets the overall exposure used by the pipeline
  69873. */
  69874. get exposure(): number;
  69875. /**
  69876. * Sets the overall exposure used by the pipeline
  69877. */
  69878. set exposure(value: number);
  69879. /**
  69880. * Texture used typically to simulate "dirty" on camera lens
  69881. */
  69882. lensTexture: Nullable<Texture>;
  69883. /**
  69884. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69885. */
  69886. volumetricLightCoefficient: number;
  69887. /**
  69888. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69889. */
  69890. volumetricLightPower: number;
  69891. /**
  69892. * Used the set the blur intensity to smooth the volumetric lights
  69893. */
  69894. volumetricLightBlurScale: number;
  69895. /**
  69896. * Light (spot or directional) used to generate the volumetric lights rays
  69897. * The source light must have a shadow generate so the pipeline can get its
  69898. * depth map
  69899. */
  69900. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69901. /**
  69902. * For eye adaptation, represents the minimum luminance the eye can see
  69903. */
  69904. hdrMinimumLuminance: number;
  69905. /**
  69906. * For eye adaptation, represents the decrease luminance speed
  69907. */
  69908. hdrDecreaseRate: number;
  69909. /**
  69910. * For eye adaptation, represents the increase luminance speed
  69911. */
  69912. hdrIncreaseRate: number;
  69913. /**
  69914. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69915. */
  69916. get hdrAutoExposure(): boolean;
  69917. /**
  69918. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69919. */
  69920. set hdrAutoExposure(value: boolean);
  69921. /**
  69922. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69923. */
  69924. lensColorTexture: Nullable<Texture>;
  69925. /**
  69926. * The overall strengh for the lens flare effect
  69927. */
  69928. lensFlareStrength: number;
  69929. /**
  69930. * Dispersion coefficient for lens flare ghosts
  69931. */
  69932. lensFlareGhostDispersal: number;
  69933. /**
  69934. * Main lens flare halo width
  69935. */
  69936. lensFlareHaloWidth: number;
  69937. /**
  69938. * Based on the lens distortion effect, defines how much the lens flare result
  69939. * is distorted
  69940. */
  69941. lensFlareDistortionStrength: number;
  69942. /**
  69943. * Configures the blur intensity used for for lens flare (halo)
  69944. */
  69945. lensFlareBlurWidth: number;
  69946. /**
  69947. * Lens star texture must be used to simulate rays on the flares and is available
  69948. * in the documentation
  69949. */
  69950. lensStarTexture: Nullable<Texture>;
  69951. /**
  69952. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69953. * flare effect by taking account of the dirt texture
  69954. */
  69955. lensFlareDirtTexture: Nullable<Texture>;
  69956. /**
  69957. * Represents the focal length for the depth of field effect
  69958. */
  69959. depthOfFieldDistance: number;
  69960. /**
  69961. * Represents the blur intensity for the blurred part of the depth of field effect
  69962. */
  69963. depthOfFieldBlurWidth: number;
  69964. /**
  69965. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69966. */
  69967. get motionStrength(): number;
  69968. /**
  69969. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69970. */
  69971. set motionStrength(strength: number);
  69972. /**
  69973. * Gets wether or not the motion blur post-process is object based or screen based.
  69974. */
  69975. get objectBasedMotionBlur(): boolean;
  69976. /**
  69977. * Sets wether or not the motion blur post-process should be object based or screen based
  69978. */
  69979. set objectBasedMotionBlur(value: boolean);
  69980. /**
  69981. * List of animations for the pipeline (IAnimatable implementation)
  69982. */
  69983. animations: Animation[];
  69984. /**
  69985. * Private members
  69986. */
  69987. private _scene;
  69988. private _currentDepthOfFieldSource;
  69989. private _basePostProcess;
  69990. private _fixedExposure;
  69991. private _currentExposure;
  69992. private _hdrAutoExposure;
  69993. private _hdrCurrentLuminance;
  69994. private _motionStrength;
  69995. private _isObjectBasedMotionBlur;
  69996. private _floatTextureType;
  69997. private _camerasToBeAttached;
  69998. private _ratio;
  69999. private _bloomEnabled;
  70000. private _depthOfFieldEnabled;
  70001. private _vlsEnabled;
  70002. private _lensFlareEnabled;
  70003. private _hdrEnabled;
  70004. private _motionBlurEnabled;
  70005. private _fxaaEnabled;
  70006. private _screenSpaceReflectionsEnabled;
  70007. private _motionBlurSamples;
  70008. private _volumetricLightStepsCount;
  70009. private _samples;
  70010. /**
  70011. * @ignore
  70012. * Specifies if the bloom pipeline is enabled
  70013. */
  70014. get BloomEnabled(): boolean;
  70015. set BloomEnabled(enabled: boolean);
  70016. /**
  70017. * @ignore
  70018. * Specifies if the depth of field pipeline is enabed
  70019. */
  70020. get DepthOfFieldEnabled(): boolean;
  70021. set DepthOfFieldEnabled(enabled: boolean);
  70022. /**
  70023. * @ignore
  70024. * Specifies if the lens flare pipeline is enabed
  70025. */
  70026. get LensFlareEnabled(): boolean;
  70027. set LensFlareEnabled(enabled: boolean);
  70028. /**
  70029. * @ignore
  70030. * Specifies if the HDR pipeline is enabled
  70031. */
  70032. get HDREnabled(): boolean;
  70033. set HDREnabled(enabled: boolean);
  70034. /**
  70035. * @ignore
  70036. * Specifies if the volumetric lights scattering effect is enabled
  70037. */
  70038. get VLSEnabled(): boolean;
  70039. set VLSEnabled(enabled: boolean);
  70040. /**
  70041. * @ignore
  70042. * Specifies if the motion blur effect is enabled
  70043. */
  70044. get MotionBlurEnabled(): boolean;
  70045. set MotionBlurEnabled(enabled: boolean);
  70046. /**
  70047. * Specifies if anti-aliasing is enabled
  70048. */
  70049. get fxaaEnabled(): boolean;
  70050. set fxaaEnabled(enabled: boolean);
  70051. /**
  70052. * Specifies if screen space reflections are enabled.
  70053. */
  70054. get screenSpaceReflectionsEnabled(): boolean;
  70055. set screenSpaceReflectionsEnabled(enabled: boolean);
  70056. /**
  70057. * Specifies the number of steps used to calculate the volumetric lights
  70058. * Typically in interval [50, 200]
  70059. */
  70060. get volumetricLightStepsCount(): number;
  70061. set volumetricLightStepsCount(count: number);
  70062. /**
  70063. * Specifies the number of samples used for the motion blur effect
  70064. * Typically in interval [16, 64]
  70065. */
  70066. get motionBlurSamples(): number;
  70067. set motionBlurSamples(samples: number);
  70068. /**
  70069. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70070. */
  70071. get samples(): number;
  70072. set samples(sampleCount: number);
  70073. /**
  70074. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70075. * @constructor
  70076. * @param name The rendering pipeline name
  70077. * @param scene The scene linked to this pipeline
  70078. * @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)
  70079. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70080. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70081. */
  70082. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70083. private _buildPipeline;
  70084. private _createDownSampleX4PostProcess;
  70085. private _createBrightPassPostProcess;
  70086. private _createBlurPostProcesses;
  70087. private _createTextureAdderPostProcess;
  70088. private _createVolumetricLightPostProcess;
  70089. private _createLuminancePostProcesses;
  70090. private _createHdrPostProcess;
  70091. private _createLensFlarePostProcess;
  70092. private _createDepthOfFieldPostProcess;
  70093. private _createMotionBlurPostProcess;
  70094. private _getDepthTexture;
  70095. private _disposePostProcesses;
  70096. /**
  70097. * Dispose of the pipeline and stop all post processes
  70098. */
  70099. dispose(): void;
  70100. /**
  70101. * Serialize the rendering pipeline (Used when exporting)
  70102. * @returns the serialized object
  70103. */
  70104. serialize(): any;
  70105. /**
  70106. * Parse the serialized pipeline
  70107. * @param source Source pipeline.
  70108. * @param scene The scene to load the pipeline to.
  70109. * @param rootUrl The URL of the serialized pipeline.
  70110. * @returns An instantiated pipeline from the serialized object.
  70111. */
  70112. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70113. /**
  70114. * Luminance steps
  70115. */
  70116. static LuminanceSteps: number;
  70117. }
  70118. }
  70119. declare module BABYLON {
  70120. /** @hidden */
  70121. export var stereoscopicInterlacePixelShader: {
  70122. name: string;
  70123. shader: string;
  70124. };
  70125. }
  70126. declare module BABYLON {
  70127. /**
  70128. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70129. */
  70130. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70131. private _stepSize;
  70132. private _passedProcess;
  70133. /**
  70134. * Initializes a StereoscopicInterlacePostProcessI
  70135. * @param name The name of the effect.
  70136. * @param rigCameras The rig cameras to be appled to the post process
  70137. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70138. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70140. * @param engine The engine which the post process will be applied. (default: current engine)
  70141. * @param reusable If the post process can be reused on the same frame. (default: false)
  70142. */
  70143. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70144. }
  70145. /**
  70146. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70147. */
  70148. export class StereoscopicInterlacePostProcess extends PostProcess {
  70149. private _stepSize;
  70150. private _passedProcess;
  70151. /**
  70152. * Initializes a StereoscopicInterlacePostProcess
  70153. * @param name The name of the effect.
  70154. * @param rigCameras The rig cameras to be appled to the post process
  70155. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70157. * @param engine The engine which the post process will be applied. (default: current engine)
  70158. * @param reusable If the post process can be reused on the same frame. (default: false)
  70159. */
  70160. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70161. }
  70162. }
  70163. declare module BABYLON {
  70164. /** @hidden */
  70165. export var tonemapPixelShader: {
  70166. name: string;
  70167. shader: string;
  70168. };
  70169. }
  70170. declare module BABYLON {
  70171. /** Defines operator used for tonemapping */
  70172. export enum TonemappingOperator {
  70173. /** Hable */
  70174. Hable = 0,
  70175. /** Reinhard */
  70176. Reinhard = 1,
  70177. /** HejiDawson */
  70178. HejiDawson = 2,
  70179. /** Photographic */
  70180. Photographic = 3
  70181. }
  70182. /**
  70183. * Defines a post process to apply tone mapping
  70184. */
  70185. export class TonemapPostProcess extends PostProcess {
  70186. private _operator;
  70187. /** Defines the required exposure adjustement */
  70188. exposureAdjustment: number;
  70189. /**
  70190. * Creates a new TonemapPostProcess
  70191. * @param name defines the name of the postprocess
  70192. * @param _operator defines the operator to use
  70193. * @param exposureAdjustment defines the required exposure adjustement
  70194. * @param camera defines the camera to use (can be null)
  70195. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70196. * @param engine defines the hosting engine (can be ignore if camera is set)
  70197. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70198. */
  70199. constructor(name: string, _operator: TonemappingOperator,
  70200. /** Defines the required exposure adjustement */
  70201. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70202. }
  70203. }
  70204. declare module BABYLON {
  70205. /** @hidden */
  70206. export var volumetricLightScatteringPixelShader: {
  70207. name: string;
  70208. shader: string;
  70209. };
  70210. }
  70211. declare module BABYLON {
  70212. /** @hidden */
  70213. export var volumetricLightScatteringPassVertexShader: {
  70214. name: string;
  70215. shader: string;
  70216. };
  70217. }
  70218. declare module BABYLON {
  70219. /** @hidden */
  70220. export var volumetricLightScatteringPassPixelShader: {
  70221. name: string;
  70222. shader: string;
  70223. };
  70224. }
  70225. declare module BABYLON {
  70226. /**
  70227. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70228. */
  70229. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70230. private _volumetricLightScatteringPass;
  70231. private _volumetricLightScatteringRTT;
  70232. private _viewPort;
  70233. private _screenCoordinates;
  70234. private _cachedDefines;
  70235. /**
  70236. * If not undefined, the mesh position is computed from the attached node position
  70237. */
  70238. attachedNode: {
  70239. position: Vector3;
  70240. };
  70241. /**
  70242. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70243. */
  70244. customMeshPosition: Vector3;
  70245. /**
  70246. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70247. */
  70248. useCustomMeshPosition: boolean;
  70249. /**
  70250. * If the post-process should inverse the light scattering direction
  70251. */
  70252. invert: boolean;
  70253. /**
  70254. * The internal mesh used by the post-process
  70255. */
  70256. mesh: Mesh;
  70257. /**
  70258. * @hidden
  70259. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70260. */
  70261. get useDiffuseColor(): boolean;
  70262. set useDiffuseColor(useDiffuseColor: boolean);
  70263. /**
  70264. * Array containing the excluded meshes not rendered in the internal pass
  70265. */
  70266. excludedMeshes: AbstractMesh[];
  70267. /**
  70268. * Controls the overall intensity of the post-process
  70269. */
  70270. exposure: number;
  70271. /**
  70272. * Dissipates each sample's contribution in range [0, 1]
  70273. */
  70274. decay: number;
  70275. /**
  70276. * Controls the overall intensity of each sample
  70277. */
  70278. weight: number;
  70279. /**
  70280. * Controls the density of each sample
  70281. */
  70282. density: number;
  70283. /**
  70284. * @constructor
  70285. * @param name The post-process name
  70286. * @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)
  70287. * @param camera The camera that the post-process will be attached to
  70288. * @param mesh The mesh used to create the light scattering
  70289. * @param samples The post-process quality, default 100
  70290. * @param samplingModeThe post-process filtering mode
  70291. * @param engine The babylon engine
  70292. * @param reusable If the post-process is reusable
  70293. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70294. */
  70295. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70296. /**
  70297. * Returns the string "VolumetricLightScatteringPostProcess"
  70298. * @returns "VolumetricLightScatteringPostProcess"
  70299. */
  70300. getClassName(): string;
  70301. private _isReady;
  70302. /**
  70303. * Sets the new light position for light scattering effect
  70304. * @param position The new custom light position
  70305. */
  70306. setCustomMeshPosition(position: Vector3): void;
  70307. /**
  70308. * Returns the light position for light scattering effect
  70309. * @return Vector3 The custom light position
  70310. */
  70311. getCustomMeshPosition(): Vector3;
  70312. /**
  70313. * Disposes the internal assets and detaches the post-process from the camera
  70314. */
  70315. dispose(camera: Camera): void;
  70316. /**
  70317. * Returns the render target texture used by the post-process
  70318. * @return the render target texture used by the post-process
  70319. */
  70320. getPass(): RenderTargetTexture;
  70321. private _meshExcluded;
  70322. private _createPass;
  70323. private _updateMeshScreenCoordinates;
  70324. /**
  70325. * Creates a default mesh for the Volumeric Light Scattering post-process
  70326. * @param name The mesh name
  70327. * @param scene The scene where to create the mesh
  70328. * @return the default mesh
  70329. */
  70330. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70331. }
  70332. }
  70333. declare module BABYLON {
  70334. interface Scene {
  70335. /** @hidden (Backing field) */
  70336. _boundingBoxRenderer: BoundingBoxRenderer;
  70337. /** @hidden (Backing field) */
  70338. _forceShowBoundingBoxes: boolean;
  70339. /**
  70340. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70341. */
  70342. forceShowBoundingBoxes: boolean;
  70343. /**
  70344. * Gets the bounding box renderer associated with the scene
  70345. * @returns a BoundingBoxRenderer
  70346. */
  70347. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70348. }
  70349. interface AbstractMesh {
  70350. /** @hidden (Backing field) */
  70351. _showBoundingBox: boolean;
  70352. /**
  70353. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70354. */
  70355. showBoundingBox: boolean;
  70356. }
  70357. /**
  70358. * Component responsible of rendering the bounding box of the meshes in a scene.
  70359. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70360. */
  70361. export class BoundingBoxRenderer implements ISceneComponent {
  70362. /**
  70363. * The component name helpfull to identify the component in the list of scene components.
  70364. */
  70365. readonly name: string;
  70366. /**
  70367. * The scene the component belongs to.
  70368. */
  70369. scene: Scene;
  70370. /**
  70371. * Color of the bounding box lines placed in front of an object
  70372. */
  70373. frontColor: Color3;
  70374. /**
  70375. * Color of the bounding box lines placed behind an object
  70376. */
  70377. backColor: Color3;
  70378. /**
  70379. * Defines if the renderer should show the back lines or not
  70380. */
  70381. showBackLines: boolean;
  70382. /**
  70383. * Observable raised before rendering a bounding box
  70384. */
  70385. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70386. /**
  70387. * Observable raised after rendering a bounding box
  70388. */
  70389. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70390. /**
  70391. * @hidden
  70392. */
  70393. renderList: SmartArray<BoundingBox>;
  70394. private _colorShader;
  70395. private _vertexBuffers;
  70396. private _indexBuffer;
  70397. private _fillIndexBuffer;
  70398. private _fillIndexData;
  70399. /**
  70400. * Instantiates a new bounding box renderer in a scene.
  70401. * @param scene the scene the renderer renders in
  70402. */
  70403. constructor(scene: Scene);
  70404. /**
  70405. * Registers the component in a given scene
  70406. */
  70407. register(): void;
  70408. private _evaluateSubMesh;
  70409. private _activeMesh;
  70410. private _prepareRessources;
  70411. private _createIndexBuffer;
  70412. /**
  70413. * Rebuilds the elements related to this component in case of
  70414. * context lost for instance.
  70415. */
  70416. rebuild(): void;
  70417. /**
  70418. * @hidden
  70419. */
  70420. reset(): void;
  70421. /**
  70422. * Render the bounding boxes of a specific rendering group
  70423. * @param renderingGroupId defines the rendering group to render
  70424. */
  70425. render(renderingGroupId: number): void;
  70426. /**
  70427. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70428. * @param mesh Define the mesh to render the occlusion bounding box for
  70429. */
  70430. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70431. /**
  70432. * Dispose and release the resources attached to this renderer.
  70433. */
  70434. dispose(): void;
  70435. }
  70436. }
  70437. declare module BABYLON {
  70438. interface Scene {
  70439. /** @hidden (Backing field) */
  70440. _depthRenderer: {
  70441. [id: string]: DepthRenderer;
  70442. };
  70443. /**
  70444. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70445. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70446. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70447. * @returns the created depth renderer
  70448. */
  70449. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70450. /**
  70451. * Disables a depth renderer for a given camera
  70452. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70453. */
  70454. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70455. }
  70456. /**
  70457. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70458. * in several rendering techniques.
  70459. */
  70460. export class DepthRendererSceneComponent implements ISceneComponent {
  70461. /**
  70462. * The component name helpfull to identify the component in the list of scene components.
  70463. */
  70464. readonly name: string;
  70465. /**
  70466. * The scene the component belongs to.
  70467. */
  70468. scene: Scene;
  70469. /**
  70470. * Creates a new instance of the component for the given scene
  70471. * @param scene Defines the scene to register the component in
  70472. */
  70473. constructor(scene: Scene);
  70474. /**
  70475. * Registers the component in a given scene
  70476. */
  70477. register(): void;
  70478. /**
  70479. * Rebuilds the elements related to this component in case of
  70480. * context lost for instance.
  70481. */
  70482. rebuild(): void;
  70483. /**
  70484. * Disposes the component and the associated ressources
  70485. */
  70486. dispose(): void;
  70487. private _gatherRenderTargets;
  70488. private _gatherActiveCameraRenderTargets;
  70489. }
  70490. }
  70491. declare module BABYLON {
  70492. /** @hidden */
  70493. export var outlinePixelShader: {
  70494. name: string;
  70495. shader: string;
  70496. };
  70497. }
  70498. declare module BABYLON {
  70499. /** @hidden */
  70500. export var outlineVertexShader: {
  70501. name: string;
  70502. shader: string;
  70503. };
  70504. }
  70505. declare module BABYLON {
  70506. interface Scene {
  70507. /** @hidden */
  70508. _outlineRenderer: OutlineRenderer;
  70509. /**
  70510. * Gets the outline renderer associated with the scene
  70511. * @returns a OutlineRenderer
  70512. */
  70513. getOutlineRenderer(): OutlineRenderer;
  70514. }
  70515. interface AbstractMesh {
  70516. /** @hidden (Backing field) */
  70517. _renderOutline: boolean;
  70518. /**
  70519. * Gets or sets a boolean indicating if the outline must be rendered as well
  70520. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70521. */
  70522. renderOutline: boolean;
  70523. /** @hidden (Backing field) */
  70524. _renderOverlay: boolean;
  70525. /**
  70526. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70527. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70528. */
  70529. renderOverlay: boolean;
  70530. }
  70531. /**
  70532. * This class is responsible to draw bothe outline/overlay of meshes.
  70533. * It should not be used directly but through the available method on mesh.
  70534. */
  70535. export class OutlineRenderer implements ISceneComponent {
  70536. /**
  70537. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70538. */
  70539. private static _StencilReference;
  70540. /**
  70541. * The name of the component. Each component must have a unique name.
  70542. */
  70543. name: string;
  70544. /**
  70545. * The scene the component belongs to.
  70546. */
  70547. scene: Scene;
  70548. /**
  70549. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70550. */
  70551. zOffset: number;
  70552. private _engine;
  70553. private _effect;
  70554. private _cachedDefines;
  70555. private _savedDepthWrite;
  70556. /**
  70557. * Instantiates a new outline renderer. (There could be only one per scene).
  70558. * @param scene Defines the scene it belongs to
  70559. */
  70560. constructor(scene: Scene);
  70561. /**
  70562. * Register the component to one instance of a scene.
  70563. */
  70564. register(): void;
  70565. /**
  70566. * Rebuilds the elements related to this component in case of
  70567. * context lost for instance.
  70568. */
  70569. rebuild(): void;
  70570. /**
  70571. * Disposes the component and the associated ressources.
  70572. */
  70573. dispose(): void;
  70574. /**
  70575. * Renders the outline in the canvas.
  70576. * @param subMesh Defines the sumesh to render
  70577. * @param batch Defines the batch of meshes in case of instances
  70578. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70579. */
  70580. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70581. /**
  70582. * Returns whether or not the outline renderer is ready for a given submesh.
  70583. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70584. * @param subMesh Defines the submesh to check readyness for
  70585. * @param useInstances Defines wheter wee are trying to render instances or not
  70586. * @returns true if ready otherwise false
  70587. */
  70588. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70589. private _beforeRenderingMesh;
  70590. private _afterRenderingMesh;
  70591. }
  70592. }
  70593. declare module BABYLON {
  70594. /**
  70595. * Defines the basic options interface of a Sprite Frame Source Size.
  70596. */
  70597. export interface ISpriteJSONSpriteSourceSize {
  70598. /**
  70599. * number of the original width of the Frame
  70600. */
  70601. w: number;
  70602. /**
  70603. * number of the original height of the Frame
  70604. */
  70605. h: number;
  70606. }
  70607. /**
  70608. * Defines the basic options interface of a Sprite Frame Data.
  70609. */
  70610. export interface ISpriteJSONSpriteFrameData {
  70611. /**
  70612. * number of the x offset of the Frame
  70613. */
  70614. x: number;
  70615. /**
  70616. * number of the y offset of the Frame
  70617. */
  70618. y: number;
  70619. /**
  70620. * number of the width of the Frame
  70621. */
  70622. w: number;
  70623. /**
  70624. * number of the height of the Frame
  70625. */
  70626. h: number;
  70627. }
  70628. /**
  70629. * Defines the basic options interface of a JSON Sprite.
  70630. */
  70631. export interface ISpriteJSONSprite {
  70632. /**
  70633. * string name of the Frame
  70634. */
  70635. filename: string;
  70636. /**
  70637. * ISpriteJSONSpriteFrame basic object of the frame data
  70638. */
  70639. frame: ISpriteJSONSpriteFrameData;
  70640. /**
  70641. * boolean to flag is the frame was rotated.
  70642. */
  70643. rotated: boolean;
  70644. /**
  70645. * boolean to flag is the frame was trimmed.
  70646. */
  70647. trimmed: boolean;
  70648. /**
  70649. * ISpriteJSONSpriteFrame basic object of the source data
  70650. */
  70651. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70652. /**
  70653. * ISpriteJSONSpriteFrame basic object of the source data
  70654. */
  70655. sourceSize: ISpriteJSONSpriteSourceSize;
  70656. }
  70657. /**
  70658. * Defines the basic options interface of a JSON atlas.
  70659. */
  70660. export interface ISpriteJSONAtlas {
  70661. /**
  70662. * Array of objects that contain the frame data.
  70663. */
  70664. frames: Array<ISpriteJSONSprite>;
  70665. /**
  70666. * object basic object containing the sprite meta data.
  70667. */
  70668. meta?: object;
  70669. }
  70670. }
  70671. declare module BABYLON {
  70672. /** @hidden */
  70673. export var spriteMapPixelShader: {
  70674. name: string;
  70675. shader: string;
  70676. };
  70677. }
  70678. declare module BABYLON {
  70679. /** @hidden */
  70680. export var spriteMapVertexShader: {
  70681. name: string;
  70682. shader: string;
  70683. };
  70684. }
  70685. declare module BABYLON {
  70686. /**
  70687. * Defines the basic options interface of a SpriteMap
  70688. */
  70689. export interface ISpriteMapOptions {
  70690. /**
  70691. * Vector2 of the number of cells in the grid.
  70692. */
  70693. stageSize?: Vector2;
  70694. /**
  70695. * Vector2 of the size of the output plane in World Units.
  70696. */
  70697. outputSize?: Vector2;
  70698. /**
  70699. * Vector3 of the position of the output plane in World Units.
  70700. */
  70701. outputPosition?: Vector3;
  70702. /**
  70703. * Vector3 of the rotation of the output plane.
  70704. */
  70705. outputRotation?: Vector3;
  70706. /**
  70707. * number of layers that the system will reserve in resources.
  70708. */
  70709. layerCount?: number;
  70710. /**
  70711. * number of max animation frames a single cell will reserve in resources.
  70712. */
  70713. maxAnimationFrames?: number;
  70714. /**
  70715. * number cell index of the base tile when the system compiles.
  70716. */
  70717. baseTile?: number;
  70718. /**
  70719. * boolean flip the sprite after its been repositioned by the framing data.
  70720. */
  70721. flipU?: boolean;
  70722. /**
  70723. * Vector3 scalar of the global RGB values of the SpriteMap.
  70724. */
  70725. colorMultiply?: Vector3;
  70726. }
  70727. /**
  70728. * Defines the IDisposable interface in order to be cleanable from resources.
  70729. */
  70730. export interface ISpriteMap extends IDisposable {
  70731. /**
  70732. * String name of the SpriteMap.
  70733. */
  70734. name: string;
  70735. /**
  70736. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70737. */
  70738. atlasJSON: ISpriteJSONAtlas;
  70739. /**
  70740. * Texture of the SpriteMap.
  70741. */
  70742. spriteSheet: Texture;
  70743. /**
  70744. * The parameters to initialize the SpriteMap with.
  70745. */
  70746. options: ISpriteMapOptions;
  70747. }
  70748. /**
  70749. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70750. */
  70751. export class SpriteMap implements ISpriteMap {
  70752. /** The Name of the spriteMap */
  70753. name: string;
  70754. /** The JSON file with the frame and meta data */
  70755. atlasJSON: ISpriteJSONAtlas;
  70756. /** The systems Sprite Sheet Texture */
  70757. spriteSheet: Texture;
  70758. /** Arguments passed with the Constructor */
  70759. options: ISpriteMapOptions;
  70760. /** Public Sprite Storage array, parsed from atlasJSON */
  70761. sprites: Array<ISpriteJSONSprite>;
  70762. /** Returns the Number of Sprites in the System */
  70763. get spriteCount(): number;
  70764. /** Returns the Position of Output Plane*/
  70765. get position(): Vector3;
  70766. /** Returns the Position of Output Plane*/
  70767. set position(v: Vector3);
  70768. /** Returns the Rotation of Output Plane*/
  70769. get rotation(): Vector3;
  70770. /** Returns the Rotation of Output Plane*/
  70771. set rotation(v: Vector3);
  70772. /** Sets the AnimationMap*/
  70773. get animationMap(): RawTexture;
  70774. /** Sets the AnimationMap*/
  70775. set animationMap(v: RawTexture);
  70776. /** Scene that the SpriteMap was created in */
  70777. private _scene;
  70778. /** Texture Buffer of Float32 that holds tile frame data*/
  70779. private _frameMap;
  70780. /** Texture Buffers of Float32 that holds tileMap data*/
  70781. private _tileMaps;
  70782. /** Texture Buffer of Float32 that holds Animation Data*/
  70783. private _animationMap;
  70784. /** Custom ShaderMaterial Central to the System*/
  70785. private _material;
  70786. /** Custom ShaderMaterial Central to the System*/
  70787. private _output;
  70788. /** Systems Time Ticker*/
  70789. private _time;
  70790. /**
  70791. * Creates a new SpriteMap
  70792. * @param name defines the SpriteMaps Name
  70793. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70794. * @param spriteSheet is the Texture that the Sprites are on.
  70795. * @param options a basic deployment configuration
  70796. * @param scene The Scene that the map is deployed on
  70797. */
  70798. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70799. /**
  70800. * Returns tileID location
  70801. * @returns Vector2 the cell position ID
  70802. */
  70803. getTileID(): Vector2;
  70804. /**
  70805. * Gets the UV location of the mouse over the SpriteMap.
  70806. * @returns Vector2 the UV position of the mouse interaction
  70807. */
  70808. getMousePosition(): Vector2;
  70809. /**
  70810. * Creates the "frame" texture Buffer
  70811. * -------------------------------------
  70812. * Structure of frames
  70813. * "filename": "Falling-Water-2.png",
  70814. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70815. * "rotated": true,
  70816. * "trimmed": true,
  70817. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70818. * "sourceSize": {"w":32,"h":32}
  70819. * @returns RawTexture of the frameMap
  70820. */
  70821. private _createFrameBuffer;
  70822. /**
  70823. * Creates the tileMap texture Buffer
  70824. * @param buffer normally and array of numbers, or a false to generate from scratch
  70825. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70826. * @returns RawTexture of the tileMap
  70827. */
  70828. private _createTileBuffer;
  70829. /**
  70830. * Modifies the data of the tileMaps
  70831. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70832. * @param pos is the iVector2 Coordinates of the Tile
  70833. * @param tile The SpriteIndex of the new Tile
  70834. */
  70835. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70836. /**
  70837. * Creates the animationMap texture Buffer
  70838. * @param buffer normally and array of numbers, or a false to generate from scratch
  70839. * @returns RawTexture of the animationMap
  70840. */
  70841. private _createTileAnimationBuffer;
  70842. /**
  70843. * Modifies the data of the animationMap
  70844. * @param cellID is the Index of the Sprite
  70845. * @param _frame is the target Animation frame
  70846. * @param toCell is the Target Index of the next frame of the animation
  70847. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70848. * @param speed is a global scalar of the time variable on the map.
  70849. */
  70850. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70851. /**
  70852. * Exports the .tilemaps file
  70853. */
  70854. saveTileMaps(): void;
  70855. /**
  70856. * Imports the .tilemaps file
  70857. * @param url of the .tilemaps file
  70858. */
  70859. loadTileMaps(url: string): void;
  70860. /**
  70861. * Release associated resources
  70862. */
  70863. dispose(): void;
  70864. }
  70865. }
  70866. declare module BABYLON {
  70867. /**
  70868. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70869. * @see http://doc.babylonjs.com/babylon101/sprites
  70870. */
  70871. export class SpritePackedManager extends SpriteManager {
  70872. /** defines the packed manager's name */
  70873. name: string;
  70874. /**
  70875. * Creates a new sprite manager from a packed sprite sheet
  70876. * @param name defines the manager's name
  70877. * @param imgUrl defines the sprite sheet url
  70878. * @param capacity defines the maximum allowed number of sprites
  70879. * @param scene defines the hosting scene
  70880. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70881. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70882. * @param samplingMode defines the smapling mode to use with spritesheet
  70883. * @param fromPacked set to true; do not alter
  70884. */
  70885. constructor(
  70886. /** defines the packed manager's name */
  70887. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70888. }
  70889. }
  70890. declare module BABYLON {
  70891. /**
  70892. * Defines the list of states available for a task inside a AssetsManager
  70893. */
  70894. export enum AssetTaskState {
  70895. /**
  70896. * Initialization
  70897. */
  70898. INIT = 0,
  70899. /**
  70900. * Running
  70901. */
  70902. RUNNING = 1,
  70903. /**
  70904. * Done
  70905. */
  70906. DONE = 2,
  70907. /**
  70908. * Error
  70909. */
  70910. ERROR = 3
  70911. }
  70912. /**
  70913. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70914. */
  70915. export abstract class AbstractAssetTask {
  70916. /**
  70917. * Task name
  70918. */ name: string;
  70919. /**
  70920. * Callback called when the task is successful
  70921. */
  70922. onSuccess: (task: any) => void;
  70923. /**
  70924. * Callback called when the task is not successful
  70925. */
  70926. onError: (task: any, message?: string, exception?: any) => void;
  70927. /**
  70928. * Creates a new AssetsManager
  70929. * @param name defines the name of the task
  70930. */
  70931. constructor(
  70932. /**
  70933. * Task name
  70934. */ name: string);
  70935. private _isCompleted;
  70936. private _taskState;
  70937. private _errorObject;
  70938. /**
  70939. * Get if the task is completed
  70940. */
  70941. get isCompleted(): boolean;
  70942. /**
  70943. * Gets the current state of the task
  70944. */
  70945. get taskState(): AssetTaskState;
  70946. /**
  70947. * Gets the current error object (if task is in error)
  70948. */
  70949. get errorObject(): {
  70950. message?: string;
  70951. exception?: any;
  70952. };
  70953. /**
  70954. * Internal only
  70955. * @hidden
  70956. */
  70957. _setErrorObject(message?: string, exception?: any): void;
  70958. /**
  70959. * Execute the current task
  70960. * @param scene defines the scene where you want your assets to be loaded
  70961. * @param onSuccess is a callback called when the task is successfully executed
  70962. * @param onError is a callback called if an error occurs
  70963. */
  70964. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70965. /**
  70966. * Execute the current task
  70967. * @param scene defines the scene where you want your assets to be loaded
  70968. * @param onSuccess is a callback called when the task is successfully executed
  70969. * @param onError is a callback called if an error occurs
  70970. */
  70971. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70972. /**
  70973. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70974. * This can be used with failed tasks that have the reason for failure fixed.
  70975. */
  70976. reset(): void;
  70977. private onErrorCallback;
  70978. private onDoneCallback;
  70979. }
  70980. /**
  70981. * Define the interface used by progress events raised during assets loading
  70982. */
  70983. export interface IAssetsProgressEvent {
  70984. /**
  70985. * Defines the number of remaining tasks to process
  70986. */
  70987. remainingCount: number;
  70988. /**
  70989. * Defines the total number of tasks
  70990. */
  70991. totalCount: number;
  70992. /**
  70993. * Defines the task that was just processed
  70994. */
  70995. task: AbstractAssetTask;
  70996. }
  70997. /**
  70998. * Class used to share progress information about assets loading
  70999. */
  71000. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71001. /**
  71002. * Defines the number of remaining tasks to process
  71003. */
  71004. remainingCount: number;
  71005. /**
  71006. * Defines the total number of tasks
  71007. */
  71008. totalCount: number;
  71009. /**
  71010. * Defines the task that was just processed
  71011. */
  71012. task: AbstractAssetTask;
  71013. /**
  71014. * Creates a AssetsProgressEvent
  71015. * @param remainingCount defines the number of remaining tasks to process
  71016. * @param totalCount defines the total number of tasks
  71017. * @param task defines the task that was just processed
  71018. */
  71019. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71020. }
  71021. /**
  71022. * Define a task used by AssetsManager to load meshes
  71023. */
  71024. export class MeshAssetTask extends AbstractAssetTask {
  71025. /**
  71026. * Defines the name of the task
  71027. */
  71028. name: string;
  71029. /**
  71030. * Defines the list of mesh's names you want to load
  71031. */
  71032. meshesNames: any;
  71033. /**
  71034. * Defines the root url to use as a base to load your meshes and associated resources
  71035. */
  71036. rootUrl: string;
  71037. /**
  71038. * Defines the filename or File of the scene to load from
  71039. */
  71040. sceneFilename: string | File;
  71041. /**
  71042. * Gets the list of loaded meshes
  71043. */
  71044. loadedMeshes: Array<AbstractMesh>;
  71045. /**
  71046. * Gets the list of loaded particle systems
  71047. */
  71048. loadedParticleSystems: Array<IParticleSystem>;
  71049. /**
  71050. * Gets the list of loaded skeletons
  71051. */
  71052. loadedSkeletons: Array<Skeleton>;
  71053. /**
  71054. * Gets the list of loaded animation groups
  71055. */
  71056. loadedAnimationGroups: Array<AnimationGroup>;
  71057. /**
  71058. * Callback called when the task is successful
  71059. */
  71060. onSuccess: (task: MeshAssetTask) => void;
  71061. /**
  71062. * Callback called when the task is successful
  71063. */
  71064. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71065. /**
  71066. * Creates a new MeshAssetTask
  71067. * @param name defines the name of the task
  71068. * @param meshesNames defines the list of mesh's names you want to load
  71069. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71070. * @param sceneFilename defines the filename or File of the scene to load from
  71071. */
  71072. constructor(
  71073. /**
  71074. * Defines the name of the task
  71075. */
  71076. name: string,
  71077. /**
  71078. * Defines the list of mesh's names you want to load
  71079. */
  71080. meshesNames: any,
  71081. /**
  71082. * Defines the root url to use as a base to load your meshes and associated resources
  71083. */
  71084. rootUrl: string,
  71085. /**
  71086. * Defines the filename or File of the scene to load from
  71087. */
  71088. sceneFilename: string | File);
  71089. /**
  71090. * Execute the current task
  71091. * @param scene defines the scene where you want your assets to be loaded
  71092. * @param onSuccess is a callback called when the task is successfully executed
  71093. * @param onError is a callback called if an error occurs
  71094. */
  71095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71096. }
  71097. /**
  71098. * Define a task used by AssetsManager to load text content
  71099. */
  71100. export class TextFileAssetTask extends AbstractAssetTask {
  71101. /**
  71102. * Defines the name of the task
  71103. */
  71104. name: string;
  71105. /**
  71106. * Defines the location of the file to load
  71107. */
  71108. url: string;
  71109. /**
  71110. * Gets the loaded text string
  71111. */
  71112. text: string;
  71113. /**
  71114. * Callback called when the task is successful
  71115. */
  71116. onSuccess: (task: TextFileAssetTask) => void;
  71117. /**
  71118. * Callback called when the task is successful
  71119. */
  71120. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71121. /**
  71122. * Creates a new TextFileAssetTask object
  71123. * @param name defines the name of the task
  71124. * @param url defines the location of the file to load
  71125. */
  71126. constructor(
  71127. /**
  71128. * Defines the name of the task
  71129. */
  71130. name: string,
  71131. /**
  71132. * Defines the location of the file to load
  71133. */
  71134. url: string);
  71135. /**
  71136. * Execute the current task
  71137. * @param scene defines the scene where you want your assets to be loaded
  71138. * @param onSuccess is a callback called when the task is successfully executed
  71139. * @param onError is a callback called if an error occurs
  71140. */
  71141. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71142. }
  71143. /**
  71144. * Define a task used by AssetsManager to load binary data
  71145. */
  71146. export class BinaryFileAssetTask extends AbstractAssetTask {
  71147. /**
  71148. * Defines the name of the task
  71149. */
  71150. name: string;
  71151. /**
  71152. * Defines the location of the file to load
  71153. */
  71154. url: string;
  71155. /**
  71156. * Gets the lodaded data (as an array buffer)
  71157. */
  71158. data: ArrayBuffer;
  71159. /**
  71160. * Callback called when the task is successful
  71161. */
  71162. onSuccess: (task: BinaryFileAssetTask) => void;
  71163. /**
  71164. * Callback called when the task is successful
  71165. */
  71166. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71167. /**
  71168. * Creates a new BinaryFileAssetTask object
  71169. * @param name defines the name of the new task
  71170. * @param url defines the location of the file to load
  71171. */
  71172. constructor(
  71173. /**
  71174. * Defines the name of the task
  71175. */
  71176. name: string,
  71177. /**
  71178. * Defines the location of the file to load
  71179. */
  71180. url: string);
  71181. /**
  71182. * Execute the current task
  71183. * @param scene defines the scene where you want your assets to be loaded
  71184. * @param onSuccess is a callback called when the task is successfully executed
  71185. * @param onError is a callback called if an error occurs
  71186. */
  71187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71188. }
  71189. /**
  71190. * Define a task used by AssetsManager to load images
  71191. */
  71192. export class ImageAssetTask extends AbstractAssetTask {
  71193. /**
  71194. * Defines the name of the task
  71195. */
  71196. name: string;
  71197. /**
  71198. * Defines the location of the image to load
  71199. */
  71200. url: string;
  71201. /**
  71202. * Gets the loaded images
  71203. */
  71204. image: HTMLImageElement;
  71205. /**
  71206. * Callback called when the task is successful
  71207. */
  71208. onSuccess: (task: ImageAssetTask) => void;
  71209. /**
  71210. * Callback called when the task is successful
  71211. */
  71212. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71213. /**
  71214. * Creates a new ImageAssetTask
  71215. * @param name defines the name of the task
  71216. * @param url defines the location of the image to load
  71217. */
  71218. constructor(
  71219. /**
  71220. * Defines the name of the task
  71221. */
  71222. name: string,
  71223. /**
  71224. * Defines the location of the image to load
  71225. */
  71226. url: string);
  71227. /**
  71228. * Execute the current task
  71229. * @param scene defines the scene where you want your assets to be loaded
  71230. * @param onSuccess is a callback called when the task is successfully executed
  71231. * @param onError is a callback called if an error occurs
  71232. */
  71233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71234. }
  71235. /**
  71236. * Defines the interface used by texture loading tasks
  71237. */
  71238. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71239. /**
  71240. * Gets the loaded texture
  71241. */
  71242. texture: TEX;
  71243. }
  71244. /**
  71245. * Define a task used by AssetsManager to load 2D textures
  71246. */
  71247. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71248. /**
  71249. * Defines the name of the task
  71250. */
  71251. name: string;
  71252. /**
  71253. * Defines the location of the file to load
  71254. */
  71255. url: string;
  71256. /**
  71257. * Defines if mipmap should not be generated (default is false)
  71258. */
  71259. noMipmap?: boolean | undefined;
  71260. /**
  71261. * Defines if texture must be inverted on Y axis (default is true)
  71262. */
  71263. invertY: boolean;
  71264. /**
  71265. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71266. */
  71267. samplingMode: number;
  71268. /**
  71269. * Gets the loaded texture
  71270. */
  71271. texture: Texture;
  71272. /**
  71273. * Callback called when the task is successful
  71274. */
  71275. onSuccess: (task: TextureAssetTask) => void;
  71276. /**
  71277. * Callback called when the task is successful
  71278. */
  71279. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71280. /**
  71281. * Creates a new TextureAssetTask object
  71282. * @param name defines the name of the task
  71283. * @param url defines the location of the file to load
  71284. * @param noMipmap defines if mipmap should not be generated (default is false)
  71285. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71286. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71287. */
  71288. constructor(
  71289. /**
  71290. * Defines the name of the task
  71291. */
  71292. name: string,
  71293. /**
  71294. * Defines the location of the file to load
  71295. */
  71296. url: string,
  71297. /**
  71298. * Defines if mipmap should not be generated (default is false)
  71299. */
  71300. noMipmap?: boolean | undefined,
  71301. /**
  71302. * Defines if texture must be inverted on Y axis (default is true)
  71303. */
  71304. invertY?: boolean,
  71305. /**
  71306. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71307. */
  71308. samplingMode?: number);
  71309. /**
  71310. * Execute the current task
  71311. * @param scene defines the scene where you want your assets to be loaded
  71312. * @param onSuccess is a callback called when the task is successfully executed
  71313. * @param onError is a callback called if an error occurs
  71314. */
  71315. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71316. }
  71317. /**
  71318. * Define a task used by AssetsManager to load cube textures
  71319. */
  71320. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71321. /**
  71322. * Defines the name of the task
  71323. */
  71324. name: string;
  71325. /**
  71326. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71327. */
  71328. url: string;
  71329. /**
  71330. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71331. */
  71332. extensions?: string[] | undefined;
  71333. /**
  71334. * Defines if mipmaps should not be generated (default is false)
  71335. */
  71336. noMipmap?: boolean | undefined;
  71337. /**
  71338. * Defines the explicit list of files (undefined by default)
  71339. */
  71340. files?: string[] | undefined;
  71341. /**
  71342. * Gets the loaded texture
  71343. */
  71344. texture: CubeTexture;
  71345. /**
  71346. * Callback called when the task is successful
  71347. */
  71348. onSuccess: (task: CubeTextureAssetTask) => void;
  71349. /**
  71350. * Callback called when the task is successful
  71351. */
  71352. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71353. /**
  71354. * Creates a new CubeTextureAssetTask
  71355. * @param name defines the name of the task
  71356. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71357. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71358. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71359. * @param files defines the explicit list of files (undefined by default)
  71360. */
  71361. constructor(
  71362. /**
  71363. * Defines the name of the task
  71364. */
  71365. name: string,
  71366. /**
  71367. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71368. */
  71369. url: string,
  71370. /**
  71371. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71372. */
  71373. extensions?: string[] | undefined,
  71374. /**
  71375. * Defines if mipmaps should not be generated (default is false)
  71376. */
  71377. noMipmap?: boolean | undefined,
  71378. /**
  71379. * Defines the explicit list of files (undefined by default)
  71380. */
  71381. files?: string[] | undefined);
  71382. /**
  71383. * Execute the current task
  71384. * @param scene defines the scene where you want your assets to be loaded
  71385. * @param onSuccess is a callback called when the task is successfully executed
  71386. * @param onError is a callback called if an error occurs
  71387. */
  71388. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71389. }
  71390. /**
  71391. * Define a task used by AssetsManager to load HDR cube textures
  71392. */
  71393. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71394. /**
  71395. * Defines the name of the task
  71396. */
  71397. name: string;
  71398. /**
  71399. * Defines the location of the file to load
  71400. */
  71401. url: string;
  71402. /**
  71403. * Defines the desired size (the more it increases the longer the generation will be)
  71404. */
  71405. size: number;
  71406. /**
  71407. * Defines if mipmaps should not be generated (default is false)
  71408. */
  71409. noMipmap: boolean;
  71410. /**
  71411. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71412. */
  71413. generateHarmonics: boolean;
  71414. /**
  71415. * 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)
  71416. */
  71417. gammaSpace: boolean;
  71418. /**
  71419. * Internal Use Only
  71420. */
  71421. reserved: boolean;
  71422. /**
  71423. * Gets the loaded texture
  71424. */
  71425. texture: HDRCubeTexture;
  71426. /**
  71427. * Callback called when the task is successful
  71428. */
  71429. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71430. /**
  71431. * Callback called when the task is successful
  71432. */
  71433. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71434. /**
  71435. * Creates a new HDRCubeTextureAssetTask object
  71436. * @param name defines the name of the task
  71437. * @param url defines the location of the file to load
  71438. * @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.
  71439. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71440. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71441. * @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)
  71442. * @param reserved Internal use only
  71443. */
  71444. constructor(
  71445. /**
  71446. * Defines the name of the task
  71447. */
  71448. name: string,
  71449. /**
  71450. * Defines the location of the file to load
  71451. */
  71452. url: string,
  71453. /**
  71454. * Defines the desired size (the more it increases the longer the generation will be)
  71455. */
  71456. size: number,
  71457. /**
  71458. * Defines if mipmaps should not be generated (default is false)
  71459. */
  71460. noMipmap?: boolean,
  71461. /**
  71462. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71463. */
  71464. generateHarmonics?: boolean,
  71465. /**
  71466. * 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)
  71467. */
  71468. gammaSpace?: boolean,
  71469. /**
  71470. * Internal Use Only
  71471. */
  71472. reserved?: boolean);
  71473. /**
  71474. * Execute the current task
  71475. * @param scene defines the scene where you want your assets to be loaded
  71476. * @param onSuccess is a callback called when the task is successfully executed
  71477. * @param onError is a callback called if an error occurs
  71478. */
  71479. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71480. }
  71481. /**
  71482. * Define a task used by AssetsManager to load Equirectangular cube textures
  71483. */
  71484. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71485. /**
  71486. * Defines the name of the task
  71487. */
  71488. name: string;
  71489. /**
  71490. * Defines the location of the file to load
  71491. */
  71492. url: string;
  71493. /**
  71494. * Defines the desired size (the more it increases the longer the generation will be)
  71495. */
  71496. size: number;
  71497. /**
  71498. * Defines if mipmaps should not be generated (default is false)
  71499. */
  71500. noMipmap: boolean;
  71501. /**
  71502. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71503. * but the standard material would require them in Gamma space) (default is true)
  71504. */
  71505. gammaSpace: boolean;
  71506. /**
  71507. * Gets the loaded texture
  71508. */
  71509. texture: EquiRectangularCubeTexture;
  71510. /**
  71511. * Callback called when the task is successful
  71512. */
  71513. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71514. /**
  71515. * Callback called when the task is successful
  71516. */
  71517. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71518. /**
  71519. * Creates a new EquiRectangularCubeTextureAssetTask object
  71520. * @param name defines the name of the task
  71521. * @param url defines the location of the file to load
  71522. * @param size defines the desired size (the more it increases the longer the generation will be)
  71523. * If the size is omitted this implies you are using a preprocessed cubemap.
  71524. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71525. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71526. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71527. * (default is true)
  71528. */
  71529. constructor(
  71530. /**
  71531. * Defines the name of the task
  71532. */
  71533. name: string,
  71534. /**
  71535. * Defines the location of the file to load
  71536. */
  71537. url: string,
  71538. /**
  71539. * Defines the desired size (the more it increases the longer the generation will be)
  71540. */
  71541. size: number,
  71542. /**
  71543. * Defines if mipmaps should not be generated (default is false)
  71544. */
  71545. noMipmap?: boolean,
  71546. /**
  71547. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71548. * but the standard material would require them in Gamma space) (default is true)
  71549. */
  71550. gammaSpace?: boolean);
  71551. /**
  71552. * Execute the current task
  71553. * @param scene defines the scene where you want your assets to be loaded
  71554. * @param onSuccess is a callback called when the task is successfully executed
  71555. * @param onError is a callback called if an error occurs
  71556. */
  71557. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71558. }
  71559. /**
  71560. * This class can be used to easily import assets into a scene
  71561. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71562. */
  71563. export class AssetsManager {
  71564. private _scene;
  71565. private _isLoading;
  71566. protected _tasks: AbstractAssetTask[];
  71567. protected _waitingTasksCount: number;
  71568. protected _totalTasksCount: number;
  71569. /**
  71570. * Callback called when all tasks are processed
  71571. */
  71572. onFinish: (tasks: AbstractAssetTask[]) => void;
  71573. /**
  71574. * Callback called when a task is successful
  71575. */
  71576. onTaskSuccess: (task: AbstractAssetTask) => void;
  71577. /**
  71578. * Callback called when a task had an error
  71579. */
  71580. onTaskError: (task: AbstractAssetTask) => void;
  71581. /**
  71582. * Callback called when a task is done (whatever the result is)
  71583. */
  71584. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71585. /**
  71586. * Observable called when all tasks are processed
  71587. */
  71588. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71589. /**
  71590. * Observable called when a task had an error
  71591. */
  71592. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71593. /**
  71594. * Observable called when all tasks were executed
  71595. */
  71596. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71597. /**
  71598. * Observable called when a task is done (whatever the result is)
  71599. */
  71600. onProgressObservable: Observable<IAssetsProgressEvent>;
  71601. /**
  71602. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71603. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71604. */
  71605. useDefaultLoadingScreen: boolean;
  71606. /**
  71607. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71608. * when all assets have been downloaded.
  71609. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71610. */
  71611. autoHideLoadingUI: boolean;
  71612. /**
  71613. * Creates a new AssetsManager
  71614. * @param scene defines the scene to work on
  71615. */
  71616. constructor(scene: Scene);
  71617. /**
  71618. * Add a MeshAssetTask to the list of active tasks
  71619. * @param taskName defines the name of the new task
  71620. * @param meshesNames defines the name of meshes to load
  71621. * @param rootUrl defines the root url to use to locate files
  71622. * @param sceneFilename defines the filename of the scene file
  71623. * @returns a new MeshAssetTask object
  71624. */
  71625. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71626. /**
  71627. * Add a TextFileAssetTask to the list of active tasks
  71628. * @param taskName defines the name of the new task
  71629. * @param url defines the url of the file to load
  71630. * @returns a new TextFileAssetTask object
  71631. */
  71632. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71633. /**
  71634. * Add a BinaryFileAssetTask to the list of active tasks
  71635. * @param taskName defines the name of the new task
  71636. * @param url defines the url of the file to load
  71637. * @returns a new BinaryFileAssetTask object
  71638. */
  71639. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71640. /**
  71641. * Add a ImageAssetTask to the list of active tasks
  71642. * @param taskName defines the name of the new task
  71643. * @param url defines the url of the file to load
  71644. * @returns a new ImageAssetTask object
  71645. */
  71646. addImageTask(taskName: string, url: string): ImageAssetTask;
  71647. /**
  71648. * Add a TextureAssetTask 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. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71652. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71653. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71654. * @returns a new TextureAssetTask object
  71655. */
  71656. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71657. /**
  71658. * Add a CubeTextureAssetTask to the list of active tasks
  71659. * @param taskName defines the name of the new task
  71660. * @param url defines the url of the file to load
  71661. * @param extensions defines the extension to use to load the cube map (can be null)
  71662. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71663. * @param files defines the list of files to load (can be null)
  71664. * @returns a new CubeTextureAssetTask object
  71665. */
  71666. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71667. /**
  71668. *
  71669. * Add a HDRCubeTextureAssetTask 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 size defines the size you want for the cubemap (can be null)
  71673. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71674. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71675. * @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)
  71676. * @param reserved Internal use only
  71677. * @returns a new HDRCubeTextureAssetTask object
  71678. */
  71679. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71680. /**
  71681. *
  71682. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71683. * @param taskName defines the name of the new task
  71684. * @param url defines the url of the file to load
  71685. * @param size defines the size you want for the cubemap (can be null)
  71686. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71687. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71688. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71689. * @returns a new EquiRectangularCubeTextureAssetTask object
  71690. */
  71691. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71692. /**
  71693. * Remove a task from the assets manager.
  71694. * @param task the task to remove
  71695. */
  71696. removeTask(task: AbstractAssetTask): void;
  71697. private _decreaseWaitingTasksCount;
  71698. private _runTask;
  71699. /**
  71700. * Reset the AssetsManager and remove all tasks
  71701. * @return the current instance of the AssetsManager
  71702. */
  71703. reset(): AssetsManager;
  71704. /**
  71705. * Start the loading process
  71706. * @return the current instance of the AssetsManager
  71707. */
  71708. load(): AssetsManager;
  71709. /**
  71710. * Start the loading process as an async operation
  71711. * @return a promise returning the list of failed tasks
  71712. */
  71713. loadAsync(): Promise<void>;
  71714. }
  71715. }
  71716. declare module BABYLON {
  71717. /**
  71718. * Wrapper class for promise with external resolve and reject.
  71719. */
  71720. export class Deferred<T> {
  71721. /**
  71722. * The promise associated with this deferred object.
  71723. */
  71724. readonly promise: Promise<T>;
  71725. private _resolve;
  71726. private _reject;
  71727. /**
  71728. * The resolve method of the promise associated with this deferred object.
  71729. */
  71730. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71731. /**
  71732. * The reject method of the promise associated with this deferred object.
  71733. */
  71734. get reject(): (reason?: any) => void;
  71735. /**
  71736. * Constructor for this deferred object.
  71737. */
  71738. constructor();
  71739. }
  71740. }
  71741. declare module BABYLON {
  71742. /**
  71743. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71744. */
  71745. export class MeshExploder {
  71746. private _centerMesh;
  71747. private _meshes;
  71748. private _meshesOrigins;
  71749. private _toCenterVectors;
  71750. private _scaledDirection;
  71751. private _newPosition;
  71752. private _centerPosition;
  71753. /**
  71754. * Explodes meshes from a center mesh.
  71755. * @param meshes The meshes to explode.
  71756. * @param centerMesh The mesh to be center of explosion.
  71757. */
  71758. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71759. private _setCenterMesh;
  71760. /**
  71761. * Get class name
  71762. * @returns "MeshExploder"
  71763. */
  71764. getClassName(): string;
  71765. /**
  71766. * "Exploded meshes"
  71767. * @returns Array of meshes with the centerMesh at index 0.
  71768. */
  71769. getMeshes(): Array<Mesh>;
  71770. /**
  71771. * Explodes meshes giving a specific direction
  71772. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71773. */
  71774. explode(direction?: number): void;
  71775. }
  71776. }
  71777. declare module BABYLON {
  71778. /**
  71779. * Class used to help managing file picking and drag'n'drop
  71780. */
  71781. export class FilesInput {
  71782. /**
  71783. * List of files ready to be loaded
  71784. */
  71785. static get FilesToLoad(): {
  71786. [key: string]: File;
  71787. };
  71788. /**
  71789. * Callback called when a file is processed
  71790. */
  71791. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71792. private _engine;
  71793. private _currentScene;
  71794. private _sceneLoadedCallback;
  71795. private _progressCallback;
  71796. private _additionalRenderLoopLogicCallback;
  71797. private _textureLoadingCallback;
  71798. private _startingProcessingFilesCallback;
  71799. private _onReloadCallback;
  71800. private _errorCallback;
  71801. private _elementToMonitor;
  71802. private _sceneFileToLoad;
  71803. private _filesToLoad;
  71804. /**
  71805. * Creates a new FilesInput
  71806. * @param engine defines the rendering engine
  71807. * @param scene defines the hosting scene
  71808. * @param sceneLoadedCallback callback called when scene is loaded
  71809. * @param progressCallback callback called to track progress
  71810. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71811. * @param textureLoadingCallback callback called when a texture is loading
  71812. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71813. * @param onReloadCallback callback called when a reload is requested
  71814. * @param errorCallback callback call if an error occurs
  71815. */
  71816. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: ISceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  71817. private _dragEnterHandler;
  71818. private _dragOverHandler;
  71819. private _dropHandler;
  71820. /**
  71821. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71822. * @param elementToMonitor defines the DOM element to track
  71823. */
  71824. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71825. /**
  71826. * Release all associated resources
  71827. */
  71828. dispose(): void;
  71829. private renderFunction;
  71830. private drag;
  71831. private drop;
  71832. private _traverseFolder;
  71833. private _processFiles;
  71834. /**
  71835. * Load files from a drop event
  71836. * @param event defines the drop event to use as source
  71837. */
  71838. loadFiles(event: any): void;
  71839. private _processReload;
  71840. /**
  71841. * Reload the current scene from the loaded files
  71842. */
  71843. reload(): void;
  71844. }
  71845. }
  71846. declare module BABYLON {
  71847. /**
  71848. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71849. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71850. */
  71851. export class SceneOptimization {
  71852. /**
  71853. * Defines the priority of this optimization (0 by default which means first in the list)
  71854. */
  71855. priority: number;
  71856. /**
  71857. * Gets a string describing the action executed by the current optimization
  71858. * @returns description string
  71859. */
  71860. getDescription(): string;
  71861. /**
  71862. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71863. * @param scene defines the current scene where to apply this optimization
  71864. * @param optimizer defines the current optimizer
  71865. * @returns true if everything that can be done was applied
  71866. */
  71867. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71868. /**
  71869. * Creates the SceneOptimization object
  71870. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71871. * @param desc defines the description associated with the optimization
  71872. */
  71873. constructor(
  71874. /**
  71875. * Defines the priority of this optimization (0 by default which means first in the list)
  71876. */
  71877. priority?: number);
  71878. }
  71879. /**
  71880. * Defines an optimization used to reduce the size of render target textures
  71881. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71882. */
  71883. export class TextureOptimization extends SceneOptimization {
  71884. /**
  71885. * Defines the priority of this optimization (0 by default which means first in the list)
  71886. */
  71887. priority: number;
  71888. /**
  71889. * 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
  71890. */
  71891. maximumSize: number;
  71892. /**
  71893. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71894. */
  71895. step: number;
  71896. /**
  71897. * Gets a string describing the action executed by the current optimization
  71898. * @returns description string
  71899. */
  71900. getDescription(): string;
  71901. /**
  71902. * Creates the TextureOptimization object
  71903. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71904. * @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
  71905. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71906. */
  71907. constructor(
  71908. /**
  71909. * Defines the priority of this optimization (0 by default which means first in the list)
  71910. */
  71911. priority?: number,
  71912. /**
  71913. * 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
  71914. */
  71915. maximumSize?: number,
  71916. /**
  71917. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71918. */
  71919. step?: number);
  71920. /**
  71921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71922. * @param scene defines the current scene where to apply this optimization
  71923. * @param optimizer defines the current optimizer
  71924. * @returns true if everything that can be done was applied
  71925. */
  71926. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71927. }
  71928. /**
  71929. * Defines an optimization used to increase or decrease the rendering resolution
  71930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71931. */
  71932. export class HardwareScalingOptimization extends SceneOptimization {
  71933. /**
  71934. * Defines the priority of this optimization (0 by default which means first in the list)
  71935. */
  71936. priority: number;
  71937. /**
  71938. * Defines the maximum scale to use (2 by default)
  71939. */
  71940. maximumScale: number;
  71941. /**
  71942. * Defines the step to use between two passes (0.5 by default)
  71943. */
  71944. step: number;
  71945. private _currentScale;
  71946. private _directionOffset;
  71947. /**
  71948. * Gets a string describing the action executed by the current optimization
  71949. * @return description string
  71950. */
  71951. getDescription(): string;
  71952. /**
  71953. * Creates the HardwareScalingOptimization object
  71954. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71955. * @param maximumScale defines the maximum scale to use (2 by default)
  71956. * @param step defines the step to use between two passes (0.5 by default)
  71957. */
  71958. constructor(
  71959. /**
  71960. * Defines the priority of this optimization (0 by default which means first in the list)
  71961. */
  71962. priority?: number,
  71963. /**
  71964. * Defines the maximum scale to use (2 by default)
  71965. */
  71966. maximumScale?: number,
  71967. /**
  71968. * Defines the step to use between two passes (0.5 by default)
  71969. */
  71970. step?: number);
  71971. /**
  71972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71973. * @param scene defines the current scene where to apply this optimization
  71974. * @param optimizer defines the current optimizer
  71975. * @returns true if everything that can be done was applied
  71976. */
  71977. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71978. }
  71979. /**
  71980. * Defines an optimization used to remove shadows
  71981. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71982. */
  71983. export class ShadowsOptimization extends SceneOptimization {
  71984. /**
  71985. * Gets a string describing the action executed by the current optimization
  71986. * @return description string
  71987. */
  71988. getDescription(): string;
  71989. /**
  71990. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71991. * @param scene defines the current scene where to apply this optimization
  71992. * @param optimizer defines the current optimizer
  71993. * @returns true if everything that can be done was applied
  71994. */
  71995. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71996. }
  71997. /**
  71998. * Defines an optimization used to turn post-processes off
  71999. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72000. */
  72001. export class PostProcessesOptimization extends SceneOptimization {
  72002. /**
  72003. * Gets a string describing the action executed by the current optimization
  72004. * @return description string
  72005. */
  72006. getDescription(): string;
  72007. /**
  72008. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72009. * @param scene defines the current scene where to apply this optimization
  72010. * @param optimizer defines the current optimizer
  72011. * @returns true if everything that can be done was applied
  72012. */
  72013. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72014. }
  72015. /**
  72016. * Defines an optimization used to turn lens flares off
  72017. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72018. */
  72019. export class LensFlaresOptimization extends SceneOptimization {
  72020. /**
  72021. * Gets a string describing the action executed by the current optimization
  72022. * @return description string
  72023. */
  72024. getDescription(): string;
  72025. /**
  72026. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72027. * @param scene defines the current scene where to apply this optimization
  72028. * @param optimizer defines the current optimizer
  72029. * @returns true if everything that can be done was applied
  72030. */
  72031. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72032. }
  72033. /**
  72034. * Defines an optimization based on user defined callback.
  72035. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72036. */
  72037. export class CustomOptimization extends SceneOptimization {
  72038. /**
  72039. * Callback called to apply the custom optimization.
  72040. */
  72041. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72042. /**
  72043. * Callback called to get custom description
  72044. */
  72045. onGetDescription: () => string;
  72046. /**
  72047. * Gets a string describing the action executed by the current optimization
  72048. * @returns description string
  72049. */
  72050. getDescription(): string;
  72051. /**
  72052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72053. * @param scene defines the current scene where to apply this optimization
  72054. * @param optimizer defines the current optimizer
  72055. * @returns true if everything that can be done was applied
  72056. */
  72057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72058. }
  72059. /**
  72060. * Defines an optimization used to turn particles off
  72061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72062. */
  72063. export class ParticlesOptimization extends SceneOptimization {
  72064. /**
  72065. * Gets a string describing the action executed by the current optimization
  72066. * @return description string
  72067. */
  72068. getDescription(): string;
  72069. /**
  72070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72071. * @param scene defines the current scene where to apply this optimization
  72072. * @param optimizer defines the current optimizer
  72073. * @returns true if everything that can be done was applied
  72074. */
  72075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72076. }
  72077. /**
  72078. * Defines an optimization used to turn render targets off
  72079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72080. */
  72081. export class RenderTargetsOptimization extends SceneOptimization {
  72082. /**
  72083. * Gets a string describing the action executed by the current optimization
  72084. * @return description string
  72085. */
  72086. getDescription(): string;
  72087. /**
  72088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72089. * @param scene defines the current scene where to apply this optimization
  72090. * @param optimizer defines the current optimizer
  72091. * @returns true if everything that can be done was applied
  72092. */
  72093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72094. }
  72095. /**
  72096. * Defines an optimization used to merge meshes with compatible materials
  72097. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72098. */
  72099. export class MergeMeshesOptimization extends SceneOptimization {
  72100. private static _UpdateSelectionTree;
  72101. /**
  72102. * Gets or sets a boolean which defines if optimization octree has to be updated
  72103. */
  72104. static get UpdateSelectionTree(): boolean;
  72105. /**
  72106. * Gets or sets a boolean which defines if optimization octree has to be updated
  72107. */
  72108. static set UpdateSelectionTree(value: boolean);
  72109. /**
  72110. * Gets a string describing the action executed by the current optimization
  72111. * @return description string
  72112. */
  72113. getDescription(): string;
  72114. private _canBeMerged;
  72115. /**
  72116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72117. * @param scene defines the current scene where to apply this optimization
  72118. * @param optimizer defines the current optimizer
  72119. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72120. * @returns true if everything that can be done was applied
  72121. */
  72122. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72123. }
  72124. /**
  72125. * Defines a list of options used by SceneOptimizer
  72126. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72127. */
  72128. export class SceneOptimizerOptions {
  72129. /**
  72130. * Defines the target frame rate to reach (60 by default)
  72131. */
  72132. targetFrameRate: number;
  72133. /**
  72134. * Defines the interval between two checkes (2000ms by default)
  72135. */
  72136. trackerDuration: number;
  72137. /**
  72138. * Gets the list of optimizations to apply
  72139. */
  72140. optimizations: SceneOptimization[];
  72141. /**
  72142. * Creates a new list of options used by SceneOptimizer
  72143. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72144. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72145. */
  72146. constructor(
  72147. /**
  72148. * Defines the target frame rate to reach (60 by default)
  72149. */
  72150. targetFrameRate?: number,
  72151. /**
  72152. * Defines the interval between two checkes (2000ms by default)
  72153. */
  72154. trackerDuration?: number);
  72155. /**
  72156. * Add a new optimization
  72157. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72158. * @returns the current SceneOptimizerOptions
  72159. */
  72160. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72161. /**
  72162. * Add a new custom optimization
  72163. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72164. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72165. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72166. * @returns the current SceneOptimizerOptions
  72167. */
  72168. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72169. /**
  72170. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72171. * @param targetFrameRate defines the target frame rate (60 by default)
  72172. * @returns a SceneOptimizerOptions object
  72173. */
  72174. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72175. /**
  72176. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72177. * @param targetFrameRate defines the target frame rate (60 by default)
  72178. * @returns a SceneOptimizerOptions object
  72179. */
  72180. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72181. /**
  72182. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72183. * @param targetFrameRate defines the target frame rate (60 by default)
  72184. * @returns a SceneOptimizerOptions object
  72185. */
  72186. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72187. }
  72188. /**
  72189. * Class used to run optimizations in order to reach a target frame rate
  72190. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72191. */
  72192. export class SceneOptimizer implements IDisposable {
  72193. private _isRunning;
  72194. private _options;
  72195. private _scene;
  72196. private _currentPriorityLevel;
  72197. private _targetFrameRate;
  72198. private _trackerDuration;
  72199. private _currentFrameRate;
  72200. private _sceneDisposeObserver;
  72201. private _improvementMode;
  72202. /**
  72203. * Defines an observable called when the optimizer reaches the target frame rate
  72204. */
  72205. onSuccessObservable: Observable<SceneOptimizer>;
  72206. /**
  72207. * Defines an observable called when the optimizer enables an optimization
  72208. */
  72209. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72210. /**
  72211. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72212. */
  72213. onFailureObservable: Observable<SceneOptimizer>;
  72214. /**
  72215. * Gets a boolean indicating if the optimizer is in improvement mode
  72216. */
  72217. get isInImprovementMode(): boolean;
  72218. /**
  72219. * Gets the current priority level (0 at start)
  72220. */
  72221. get currentPriorityLevel(): number;
  72222. /**
  72223. * Gets the current frame rate checked by the SceneOptimizer
  72224. */
  72225. get currentFrameRate(): number;
  72226. /**
  72227. * Gets or sets the current target frame rate (60 by default)
  72228. */
  72229. get targetFrameRate(): number;
  72230. /**
  72231. * Gets or sets the current target frame rate (60 by default)
  72232. */
  72233. set targetFrameRate(value: number);
  72234. /**
  72235. * Gets or sets the current interval between two checks (every 2000ms by default)
  72236. */
  72237. get trackerDuration(): number;
  72238. /**
  72239. * Gets or sets the current interval between two checks (every 2000ms by default)
  72240. */
  72241. set trackerDuration(value: number);
  72242. /**
  72243. * Gets the list of active optimizations
  72244. */
  72245. get optimizations(): SceneOptimization[];
  72246. /**
  72247. * Creates a new SceneOptimizer
  72248. * @param scene defines the scene to work on
  72249. * @param options defines the options to use with the SceneOptimizer
  72250. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72251. * @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)
  72252. */
  72253. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72254. /**
  72255. * Stops the current optimizer
  72256. */
  72257. stop(): void;
  72258. /**
  72259. * Reset the optimizer to initial step (current priority level = 0)
  72260. */
  72261. reset(): void;
  72262. /**
  72263. * Start the optimizer. By default it will try to reach a specific framerate
  72264. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72265. */
  72266. start(): void;
  72267. private _checkCurrentState;
  72268. /**
  72269. * Release all resources
  72270. */
  72271. dispose(): void;
  72272. /**
  72273. * Helper function to create a SceneOptimizer with one single line of code
  72274. * @param scene defines the scene to work on
  72275. * @param options defines the options to use with the SceneOptimizer
  72276. * @param onSuccess defines a callback to call on success
  72277. * @param onFailure defines a callback to call on failure
  72278. * @returns the new SceneOptimizer object
  72279. */
  72280. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72281. }
  72282. }
  72283. declare module BABYLON {
  72284. /**
  72285. * Class used to serialize a scene into a string
  72286. */
  72287. export class SceneSerializer {
  72288. /**
  72289. * Clear cache used by a previous serialization
  72290. */
  72291. static ClearCache(): void;
  72292. /**
  72293. * Serialize a scene into a JSON compatible object
  72294. * @param scene defines the scene to serialize
  72295. * @returns a JSON compatible object
  72296. */
  72297. static Serialize(scene: Scene): any;
  72298. /**
  72299. * Serialize a mesh into a JSON compatible object
  72300. * @param toSerialize defines the mesh to serialize
  72301. * @param withParents defines if parents must be serialized as well
  72302. * @param withChildren defines if children must be serialized as well
  72303. * @returns a JSON compatible object
  72304. */
  72305. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72306. }
  72307. }
  72308. declare module BABYLON {
  72309. /**
  72310. * Class used to host texture specific utilities
  72311. */
  72312. export class TextureTools {
  72313. /**
  72314. * Uses the GPU to create a copy texture rescaled at a given size
  72315. * @param texture Texture to copy from
  72316. * @param width defines the desired width
  72317. * @param height defines the desired height
  72318. * @param useBilinearMode defines if bilinear mode has to be used
  72319. * @return the generated texture
  72320. */
  72321. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72322. }
  72323. }
  72324. declare module BABYLON {
  72325. /**
  72326. * This represents the different options available for the video capture.
  72327. */
  72328. export interface VideoRecorderOptions {
  72329. /** Defines the mime type of the video. */
  72330. mimeType: string;
  72331. /** Defines the FPS the video should be recorded at. */
  72332. fps: number;
  72333. /** Defines the chunk size for the recording data. */
  72334. recordChunckSize: number;
  72335. /** The audio tracks to attach to the recording. */
  72336. audioTracks?: MediaStreamTrack[];
  72337. }
  72338. /**
  72339. * This can help with recording videos from BabylonJS.
  72340. * This is based on the available WebRTC functionalities of the browser.
  72341. *
  72342. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72343. */
  72344. export class VideoRecorder {
  72345. private static readonly _defaultOptions;
  72346. /**
  72347. * Returns whether or not the VideoRecorder is available in your browser.
  72348. * @param engine Defines the Babylon Engine.
  72349. * @returns true if supported otherwise false.
  72350. */
  72351. static IsSupported(engine: Engine): boolean;
  72352. private readonly _options;
  72353. private _canvas;
  72354. private _mediaRecorder;
  72355. private _recordedChunks;
  72356. private _fileName;
  72357. private _resolve;
  72358. private _reject;
  72359. /**
  72360. * True when a recording is already in progress.
  72361. */
  72362. get isRecording(): boolean;
  72363. /**
  72364. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72365. * @param engine Defines the BabylonJS Engine you wish to record.
  72366. * @param options Defines options that can be used to customize the capture.
  72367. */
  72368. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72369. /**
  72370. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72371. */
  72372. stopRecording(): void;
  72373. /**
  72374. * Starts recording the canvas for a max duration specified in parameters.
  72375. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72376. * If null no automatic download will start and you can rely on the promise to get the data back.
  72377. * @param maxDuration Defines the maximum recording time in seconds.
  72378. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72379. * @return A promise callback at the end of the recording with the video data in Blob.
  72380. */
  72381. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72382. /**
  72383. * Releases internal resources used during the recording.
  72384. */
  72385. dispose(): void;
  72386. private _handleDataAvailable;
  72387. private _handleError;
  72388. private _handleStop;
  72389. }
  72390. }
  72391. declare module BABYLON {
  72392. /**
  72393. * Class containing a set of static utilities functions for screenshots
  72394. */
  72395. export class ScreenshotTools {
  72396. /**
  72397. * Captures a screenshot of the current rendering
  72398. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72399. * @param engine defines the rendering engine
  72400. * @param camera defines the source camera
  72401. * @param size This parameter can be set to a single number or to an object with the
  72402. * following (optional) properties: precision, width, height. If a single number is passed,
  72403. * it will be used for both width and height. If an object is passed, the screenshot size
  72404. * will be derived from the parameters. The precision property is a multiplier allowing
  72405. * rendering at a higher or lower resolution
  72406. * @param successCallback defines the callback receives a single parameter which contains the
  72407. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72408. * src parameter of an <img> to display it
  72409. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72410. * Check your browser for supported MIME types
  72411. */
  72412. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72413. /**
  72414. * Captures a screenshot of the current rendering
  72415. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72416. * @param engine defines the rendering engine
  72417. * @param camera defines the source camera
  72418. * @param size This parameter can be set to a single number or to an object with the
  72419. * following (optional) properties: precision, width, height. If a single number is passed,
  72420. * it will be used for both width and height. If an object is passed, the screenshot size
  72421. * will be derived from the parameters. The precision property is a multiplier allowing
  72422. * rendering at a higher or lower resolution
  72423. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72424. * Check your browser for supported MIME types
  72425. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72426. * to the src parameter of an <img> to display it
  72427. */
  72428. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72429. /**
  72430. * Generates an image screenshot from the specified camera.
  72431. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72432. * @param engine The engine to use for rendering
  72433. * @param camera The camera to use for rendering
  72434. * @param size This parameter can be set to a single number or to an object with the
  72435. * following (optional) properties: precision, width, height. If a single number is passed,
  72436. * it will be used for both width and height. If an object is passed, the screenshot size
  72437. * will be derived from the parameters. The precision property is a multiplier allowing
  72438. * rendering at a higher or lower resolution
  72439. * @param successCallback The callback receives a single parameter which contains the
  72440. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72441. * src parameter of an <img> to display it
  72442. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72443. * Check your browser for supported MIME types
  72444. * @param samples Texture samples (default: 1)
  72445. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72446. * @param fileName A name for for the downloaded file.
  72447. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72448. */
  72449. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  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 mimeType The MIME type of the screenshot image (default: image/png).
  72461. * Check your browser for supported MIME types
  72462. * @param samples Texture samples (default: 1)
  72463. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72464. * @param fileName A name for for the downloaded file.
  72465. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72466. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72467. * to the src parameter of an <img> to display it
  72468. */
  72469. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72470. /**
  72471. * Gets height and width for screenshot size
  72472. * @private
  72473. */
  72474. private static _getScreenshotSize;
  72475. }
  72476. }
  72477. declare module BABYLON {
  72478. /**
  72479. * Interface for a data buffer
  72480. */
  72481. export interface IDataBuffer {
  72482. /**
  72483. * Reads bytes from the data buffer.
  72484. * @param byteOffset The byte offset to read
  72485. * @param byteLength The byte length to read
  72486. * @returns A promise that resolves when the bytes are read
  72487. */
  72488. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72489. /**
  72490. * The byte length of the buffer.
  72491. */
  72492. readonly byteLength: number;
  72493. }
  72494. /**
  72495. * Utility class for reading from a data buffer
  72496. */
  72497. export class DataReader {
  72498. /**
  72499. * The data buffer associated with this data reader.
  72500. */
  72501. readonly buffer: IDataBuffer;
  72502. /**
  72503. * The current byte offset from the beginning of the data buffer.
  72504. */
  72505. byteOffset: number;
  72506. private _dataView;
  72507. private _dataByteOffset;
  72508. /**
  72509. * Constructor
  72510. * @param buffer The buffer to read
  72511. */
  72512. constructor(buffer: IDataBuffer);
  72513. /**
  72514. * Loads the given byte length.
  72515. * @param byteLength The byte length to load
  72516. * @returns A promise that resolves when the load is complete
  72517. */
  72518. loadAsync(byteLength: number): Promise<void>;
  72519. /**
  72520. * Read a unsigned 32-bit integer from the currently loaded data range.
  72521. * @returns The 32-bit integer read
  72522. */
  72523. readUint32(): number;
  72524. /**
  72525. * Read a byte array from the currently loaded data range.
  72526. * @param byteLength The byte length to read
  72527. * @returns The byte array read
  72528. */
  72529. readUint8Array(byteLength: number): Uint8Array;
  72530. /**
  72531. * Read a string from the currently loaded data range.
  72532. * @param byteLength The byte length to read
  72533. * @returns The string read
  72534. */
  72535. readString(byteLength: number): string;
  72536. /**
  72537. * Skips the given byte length the currently loaded data range.
  72538. * @param byteLength The byte length to skip
  72539. */
  72540. skipBytes(byteLength: number): void;
  72541. }
  72542. }
  72543. declare module BABYLON {
  72544. /**
  72545. * Class for storing data to local storage if available or in-memory storage otherwise
  72546. */
  72547. export class DataStorage {
  72548. private static _Storage;
  72549. private static _GetStorage;
  72550. /**
  72551. * Reads a string from the data storage
  72552. * @param key The key to read
  72553. * @param defaultValue The value if the key doesn't exist
  72554. * @returns The string value
  72555. */
  72556. static ReadString(key: string, defaultValue: string): string;
  72557. /**
  72558. * Writes a string to the data storage
  72559. * @param key The key to write
  72560. * @param value The value to write
  72561. */
  72562. static WriteString(key: string, value: string): void;
  72563. /**
  72564. * Reads a boolean from the data storage
  72565. * @param key The key to read
  72566. * @param defaultValue The value if the key doesn't exist
  72567. * @returns The boolean value
  72568. */
  72569. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72570. /**
  72571. * Writes a boolean to the data storage
  72572. * @param key The key to write
  72573. * @param value The value to write
  72574. */
  72575. static WriteBoolean(key: string, value: boolean): void;
  72576. /**
  72577. * Reads a number from the data storage
  72578. * @param key The key to read
  72579. * @param defaultValue The value if the key doesn't exist
  72580. * @returns The number value
  72581. */
  72582. static ReadNumber(key: string, defaultValue: number): number;
  72583. /**
  72584. * Writes a number to the data storage
  72585. * @param key The key to write
  72586. * @param value The value to write
  72587. */
  72588. static WriteNumber(key: string, value: number): void;
  72589. }
  72590. }
  72591. declare module BABYLON {
  72592. /**
  72593. * An interface for all Hit test features
  72594. */
  72595. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72596. /**
  72597. * Triggered when new babylon (transformed) hit test results are available
  72598. */
  72599. onHitTestResultObservable: Observable<T[]>;
  72600. }
  72601. /**
  72602. * Options used for hit testing
  72603. */
  72604. export interface IWebXRLegacyHitTestOptions {
  72605. /**
  72606. * Only test when user interacted with the scene. Default - hit test every frame
  72607. */
  72608. testOnPointerDownOnly?: boolean;
  72609. /**
  72610. * The node to use to transform the local results to world coordinates
  72611. */
  72612. worldParentNode?: TransformNode;
  72613. }
  72614. /**
  72615. * Interface defining the babylon result of raycasting/hit-test
  72616. */
  72617. export interface IWebXRLegacyHitResult {
  72618. /**
  72619. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72620. */
  72621. transformationMatrix: Matrix;
  72622. /**
  72623. * The native hit test result
  72624. */
  72625. xrHitResult: XRHitResult | XRHitTestResult;
  72626. }
  72627. /**
  72628. * The currently-working hit-test module.
  72629. * Hit test (or Ray-casting) is used to interact with the real world.
  72630. * For further information read here - https://github.com/immersive-web/hit-test
  72631. */
  72632. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72633. /**
  72634. * options to use when constructing this feature
  72635. */
  72636. readonly options: IWebXRLegacyHitTestOptions;
  72637. private _direction;
  72638. private _mat;
  72639. private _onSelectEnabled;
  72640. private _origin;
  72641. /**
  72642. * The module's name
  72643. */
  72644. static readonly Name: string;
  72645. /**
  72646. * The (Babylon) version of this module.
  72647. * This is an integer representing the implementation version.
  72648. * This number does not correspond to the WebXR specs version
  72649. */
  72650. static readonly Version: number;
  72651. /**
  72652. * Populated with the last native XR Hit Results
  72653. */
  72654. lastNativeXRHitResults: XRHitResult[];
  72655. /**
  72656. * Triggered when new babylon (transformed) hit test results are available
  72657. */
  72658. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72659. /**
  72660. * Creates a new instance of the (legacy version) hit test feature
  72661. * @param _xrSessionManager an instance of WebXRSessionManager
  72662. * @param options options to use when constructing this feature
  72663. */
  72664. constructor(_xrSessionManager: WebXRSessionManager,
  72665. /**
  72666. * options to use when constructing this feature
  72667. */
  72668. options?: IWebXRLegacyHitTestOptions);
  72669. /**
  72670. * execute a hit test with an XR Ray
  72671. *
  72672. * @param xrSession a native xrSession that will execute this hit test
  72673. * @param xrRay the ray (position and direction) to use for ray-casting
  72674. * @param referenceSpace native XR reference space to use for the hit-test
  72675. * @param filter filter function that will filter the results
  72676. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72677. */
  72678. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72679. /**
  72680. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72681. * @param event the (select) event to use to select with
  72682. * @param referenceSpace the reference space to use for this hit test
  72683. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72684. */
  72685. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72686. /**
  72687. * attach this feature
  72688. * Will usually be called by the features manager
  72689. *
  72690. * @returns true if successful.
  72691. */
  72692. attach(): boolean;
  72693. /**
  72694. * detach this feature.
  72695. * Will usually be called by the features manager
  72696. *
  72697. * @returns true if successful.
  72698. */
  72699. detach(): boolean;
  72700. /**
  72701. * Dispose this feature and all of the resources attached
  72702. */
  72703. dispose(): void;
  72704. protected _onXRFrame(frame: XRFrame): void;
  72705. private _onHitTestResults;
  72706. private _onSelect;
  72707. }
  72708. }
  72709. declare module BABYLON {
  72710. /**
  72711. * Options used for hit testing (version 2)
  72712. */
  72713. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72714. /**
  72715. * Do not create a permanent hit test. Will usually be used when only
  72716. * transient inputs are needed.
  72717. */
  72718. disablePermanentHitTest?: boolean;
  72719. /**
  72720. * Enable transient (for example touch-based) hit test inspections
  72721. */
  72722. enableTransientHitTest?: boolean;
  72723. /**
  72724. * Offset ray for the permanent hit test
  72725. */
  72726. offsetRay?: Vector3;
  72727. /**
  72728. * Offset ray for the transient hit test
  72729. */
  72730. transientOffsetRay?: Vector3;
  72731. /**
  72732. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72733. */
  72734. useReferenceSpace?: boolean;
  72735. }
  72736. /**
  72737. * Interface defining the babylon result of hit-test
  72738. */
  72739. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72740. /**
  72741. * The input source that generated this hit test (if transient)
  72742. */
  72743. inputSource?: XRInputSource;
  72744. /**
  72745. * Is this a transient hit test
  72746. */
  72747. isTransient?: boolean;
  72748. /**
  72749. * Position of the hit test result
  72750. */
  72751. position: Vector3;
  72752. /**
  72753. * Rotation of the hit test result
  72754. */
  72755. rotationQuaternion: Quaternion;
  72756. /**
  72757. * The native hit test result
  72758. */
  72759. xrHitResult: XRHitTestResult;
  72760. }
  72761. /**
  72762. * The currently-working hit-test module.
  72763. * Hit test (or Ray-casting) is used to interact with the real world.
  72764. * For further information read here - https://github.com/immersive-web/hit-test
  72765. *
  72766. * Tested on chrome (mobile) 80.
  72767. */
  72768. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72769. /**
  72770. * options to use when constructing this feature
  72771. */
  72772. readonly options: IWebXRHitTestOptions;
  72773. private _tmpMat;
  72774. private _tmpPos;
  72775. private _tmpQuat;
  72776. private _transientXrHitTestSource;
  72777. private _xrHitTestSource;
  72778. private initHitTestSource;
  72779. /**
  72780. * The module's name
  72781. */
  72782. static readonly Name: string;
  72783. /**
  72784. * The (Babylon) version of this module.
  72785. * This is an integer representing the implementation version.
  72786. * This number does not correspond to the WebXR specs version
  72787. */
  72788. static readonly Version: number;
  72789. /**
  72790. * When set to true, each hit test will have its own position/rotation objects
  72791. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72792. * the developers will clone them or copy them as they see fit.
  72793. */
  72794. autoCloneTransformation: boolean;
  72795. /**
  72796. * Triggered when new babylon (transformed) hit test results are available
  72797. */
  72798. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72799. /**
  72800. * Use this to temporarily pause hit test checks.
  72801. */
  72802. paused: boolean;
  72803. /**
  72804. * Creates a new instance of the hit test feature
  72805. * @param _xrSessionManager an instance of WebXRSessionManager
  72806. * @param options options to use when constructing this feature
  72807. */
  72808. constructor(_xrSessionManager: WebXRSessionManager,
  72809. /**
  72810. * options to use when constructing this feature
  72811. */
  72812. options?: IWebXRHitTestOptions);
  72813. /**
  72814. * attach this feature
  72815. * Will usually be called by the features manager
  72816. *
  72817. * @returns true if successful.
  72818. */
  72819. attach(): boolean;
  72820. /**
  72821. * detach this feature.
  72822. * Will usually be called by the features manager
  72823. *
  72824. * @returns true if successful.
  72825. */
  72826. detach(): boolean;
  72827. /**
  72828. * Dispose this feature and all of the resources attached
  72829. */
  72830. dispose(): void;
  72831. protected _onXRFrame(frame: XRFrame): void;
  72832. private _processWebXRHitTestResult;
  72833. }
  72834. }
  72835. declare module BABYLON {
  72836. /**
  72837. * Configuration options of the anchor system
  72838. */
  72839. export interface IWebXRAnchorSystemOptions {
  72840. /**
  72841. * a node that will be used to convert local to world coordinates
  72842. */
  72843. worldParentNode?: TransformNode;
  72844. /**
  72845. * If set to true a reference of the created anchors will be kept until the next session starts
  72846. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72847. */
  72848. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72849. }
  72850. /**
  72851. * A babylon container for an XR Anchor
  72852. */
  72853. export interface IWebXRAnchor {
  72854. /**
  72855. * A babylon-assigned ID for this anchor
  72856. */
  72857. id: number;
  72858. /**
  72859. * Transformation matrix to apply to an object attached to this anchor
  72860. */
  72861. transformationMatrix: Matrix;
  72862. /**
  72863. * The native anchor object
  72864. */
  72865. xrAnchor: XRAnchor;
  72866. /**
  72867. * if defined, this object will be constantly updated by the anchor's position and rotation
  72868. */
  72869. attachedNode?: TransformNode;
  72870. }
  72871. /**
  72872. * An implementation of the anchor system for WebXR.
  72873. * For further information see https://github.com/immersive-web/anchors/
  72874. */
  72875. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72876. private _options;
  72877. private _lastFrameDetected;
  72878. private _trackedAnchors;
  72879. private _referenceSpaceForFrameAnchors;
  72880. private _futureAnchors;
  72881. /**
  72882. * The module's name
  72883. */
  72884. static readonly Name: string;
  72885. /**
  72886. * The (Babylon) version of this module.
  72887. * This is an integer representing the implementation version.
  72888. * This number does not correspond to the WebXR specs version
  72889. */
  72890. static readonly Version: number;
  72891. /**
  72892. * Observers registered here will be executed when a new anchor was added to the session
  72893. */
  72894. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72895. /**
  72896. * Observers registered here will be executed when an anchor was removed from the session
  72897. */
  72898. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72899. /**
  72900. * Observers registered here will be executed when an existing anchor updates
  72901. * This can execute N times every frame
  72902. */
  72903. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72904. /**
  72905. * Set the reference space to use for anchor creation, when not using a hit test.
  72906. * Will default to the session's reference space if not defined
  72907. */
  72908. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72909. /**
  72910. * constructs a new anchor system
  72911. * @param _xrSessionManager an instance of WebXRSessionManager
  72912. * @param _options configuration object for this feature
  72913. */
  72914. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72915. private _tmpVector;
  72916. private _tmpQuaternion;
  72917. private _populateTmpTransformation;
  72918. /**
  72919. * Create a new anchor point using a hit test result at a specific point in the scene
  72920. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72921. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72922. *
  72923. * @param hitTestResult The hit test result to use for this anchor creation
  72924. * @param position an optional position offset for this anchor
  72925. * @param rotationQuaternion an optional rotation offset for this anchor
  72926. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72927. */
  72928. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72929. /**
  72930. * Add a new anchor at a specific position and rotation
  72931. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72932. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72933. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72934. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72935. *
  72936. * @param position the position in which to add an anchor
  72937. * @param rotationQuaternion an optional rotation for the anchor transformation
  72938. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72939. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72940. */
  72941. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72942. /**
  72943. * detach this feature.
  72944. * Will usually be called by the features manager
  72945. *
  72946. * @returns true if successful.
  72947. */
  72948. detach(): boolean;
  72949. /**
  72950. * Dispose this feature and all of the resources attached
  72951. */
  72952. dispose(): void;
  72953. protected _onXRFrame(frame: XRFrame): void;
  72954. /**
  72955. * avoiding using Array.find for global support.
  72956. * @param xrAnchor the plane to find in the array
  72957. */
  72958. private _findIndexInAnchorArray;
  72959. private _updateAnchorWithXRFrame;
  72960. private _createAnchorAtTransformation;
  72961. }
  72962. }
  72963. declare module BABYLON {
  72964. /**
  72965. * Options used in the plane detector module
  72966. */
  72967. export interface IWebXRPlaneDetectorOptions {
  72968. /**
  72969. * The node to use to transform the local results to world coordinates
  72970. */
  72971. worldParentNode?: TransformNode;
  72972. /**
  72973. * If set to true a reference of the created planes will be kept until the next session starts
  72974. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72975. */
  72976. doNotRemovePlanesOnSessionEnded?: boolean;
  72977. }
  72978. /**
  72979. * A babylon interface for a WebXR plane.
  72980. * A Plane is actually a polygon, built from N points in space
  72981. *
  72982. * Supported in chrome 79, not supported in canary 81 ATM
  72983. */
  72984. export interface IWebXRPlane {
  72985. /**
  72986. * a babylon-assigned ID for this polygon
  72987. */
  72988. id: number;
  72989. /**
  72990. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72991. */
  72992. polygonDefinition: Array<Vector3>;
  72993. /**
  72994. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72995. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72996. */
  72997. transformationMatrix: Matrix;
  72998. /**
  72999. * the native xr-plane object
  73000. */
  73001. xrPlane: XRPlane;
  73002. }
  73003. /**
  73004. * The plane detector is used to detect planes in the real world when in AR
  73005. * For more information see https://github.com/immersive-web/real-world-geometry/
  73006. */
  73007. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73008. private _options;
  73009. private _detectedPlanes;
  73010. private _enabled;
  73011. private _lastFrameDetected;
  73012. /**
  73013. * The module's name
  73014. */
  73015. static readonly Name: string;
  73016. /**
  73017. * The (Babylon) version of this module.
  73018. * This is an integer representing the implementation version.
  73019. * This number does not correspond to the WebXR specs version
  73020. */
  73021. static readonly Version: number;
  73022. /**
  73023. * Observers registered here will be executed when a new plane was added to the session
  73024. */
  73025. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73026. /**
  73027. * Observers registered here will be executed when a plane is no longer detected in the session
  73028. */
  73029. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73030. /**
  73031. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73032. * This can execute N times every frame
  73033. */
  73034. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73035. /**
  73036. * construct a new Plane Detector
  73037. * @param _xrSessionManager an instance of xr Session manager
  73038. * @param _options configuration to use when constructing this feature
  73039. */
  73040. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73041. /**
  73042. * detach this feature.
  73043. * Will usually be called by the features manager
  73044. *
  73045. * @returns true if successful.
  73046. */
  73047. detach(): boolean;
  73048. /**
  73049. * Dispose this feature and all of the resources attached
  73050. */
  73051. dispose(): void;
  73052. protected _onXRFrame(frame: XRFrame): void;
  73053. private _init;
  73054. private _updatePlaneWithXRPlane;
  73055. /**
  73056. * avoiding using Array.find for global support.
  73057. * @param xrPlane the plane to find in the array
  73058. */
  73059. private findIndexInPlaneArray;
  73060. }
  73061. }
  73062. declare module BABYLON {
  73063. /**
  73064. * Options interface for the background remover plugin
  73065. */
  73066. export interface IWebXRBackgroundRemoverOptions {
  73067. /**
  73068. * Further background meshes to disable when entering AR
  73069. */
  73070. backgroundMeshes?: AbstractMesh[];
  73071. /**
  73072. * flags to configure the removal of the environment helper.
  73073. * If not set, the entire background will be removed. If set, flags should be set as well.
  73074. */
  73075. environmentHelperRemovalFlags?: {
  73076. /**
  73077. * Should the skybox be removed (default false)
  73078. */
  73079. skyBox?: boolean;
  73080. /**
  73081. * Should the ground be removed (default false)
  73082. */
  73083. ground?: boolean;
  73084. };
  73085. /**
  73086. * don't disable the environment helper
  73087. */
  73088. ignoreEnvironmentHelper?: boolean;
  73089. }
  73090. /**
  73091. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73092. */
  73093. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73094. /**
  73095. * read-only options to be used in this module
  73096. */
  73097. readonly options: IWebXRBackgroundRemoverOptions;
  73098. /**
  73099. * The module's name
  73100. */
  73101. static readonly Name: string;
  73102. /**
  73103. * The (Babylon) version of this module.
  73104. * This is an integer representing the implementation version.
  73105. * This number does not correspond to the WebXR specs version
  73106. */
  73107. static readonly Version: number;
  73108. /**
  73109. * registered observers will be triggered when the background state changes
  73110. */
  73111. onBackgroundStateChangedObservable: Observable<boolean>;
  73112. /**
  73113. * constructs a new background remover module
  73114. * @param _xrSessionManager the session manager for this module
  73115. * @param options read-only options to be used in this module
  73116. */
  73117. constructor(_xrSessionManager: WebXRSessionManager,
  73118. /**
  73119. * read-only options to be used in this module
  73120. */
  73121. options?: IWebXRBackgroundRemoverOptions);
  73122. /**
  73123. * attach this feature
  73124. * Will usually be called by the features manager
  73125. *
  73126. * @returns true if successful.
  73127. */
  73128. attach(): boolean;
  73129. /**
  73130. * detach this feature.
  73131. * Will usually be called by the features manager
  73132. *
  73133. * @returns true if successful.
  73134. */
  73135. detach(): boolean;
  73136. /**
  73137. * Dispose this feature and all of the resources attached
  73138. */
  73139. dispose(): void;
  73140. protected _onXRFrame(_xrFrame: XRFrame): void;
  73141. private _setBackgroundState;
  73142. }
  73143. }
  73144. declare module BABYLON {
  73145. /**
  73146. * Options for the controller physics feature
  73147. */
  73148. export class IWebXRControllerPhysicsOptions {
  73149. /**
  73150. * Should the headset get its own impostor
  73151. */
  73152. enableHeadsetImpostor?: boolean;
  73153. /**
  73154. * Optional parameters for the headset impostor
  73155. */
  73156. headsetImpostorParams?: {
  73157. /**
  73158. * The type of impostor to create. Default is sphere
  73159. */
  73160. impostorType: number;
  73161. /**
  73162. * the size of the impostor. Defaults to 10cm
  73163. */
  73164. impostorSize?: number | {
  73165. width: number;
  73166. height: number;
  73167. depth: number;
  73168. };
  73169. /**
  73170. * Friction definitions
  73171. */
  73172. friction?: number;
  73173. /**
  73174. * Restitution
  73175. */
  73176. restitution?: number;
  73177. };
  73178. /**
  73179. * The physics properties of the future impostors
  73180. */
  73181. physicsProperties?: {
  73182. /**
  73183. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73184. * Note that this requires a physics engine that supports mesh impostors!
  73185. */
  73186. useControllerMesh?: boolean;
  73187. /**
  73188. * The type of impostor to create. Default is sphere
  73189. */
  73190. impostorType?: number;
  73191. /**
  73192. * the size of the impostor. Defaults to 10cm
  73193. */
  73194. impostorSize?: number | {
  73195. width: number;
  73196. height: number;
  73197. depth: number;
  73198. };
  73199. /**
  73200. * Friction definitions
  73201. */
  73202. friction?: number;
  73203. /**
  73204. * Restitution
  73205. */
  73206. restitution?: number;
  73207. };
  73208. /**
  73209. * the xr input to use with this pointer selection
  73210. */
  73211. xrInput: WebXRInput;
  73212. }
  73213. /**
  73214. * Add physics impostor to your webxr controllers,
  73215. * including naive calculation of their linear and angular velocity
  73216. */
  73217. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73218. private readonly _options;
  73219. private _attachController;
  73220. private _controllers;
  73221. private _debugMode;
  73222. private _delta;
  73223. private _headsetImpostor?;
  73224. private _headsetMesh?;
  73225. private _lastTimestamp;
  73226. private _tmpQuaternion;
  73227. private _tmpVector;
  73228. /**
  73229. * The module's name
  73230. */
  73231. static readonly Name: string;
  73232. /**
  73233. * The (Babylon) version of this module.
  73234. * This is an integer representing the implementation version.
  73235. * This number does not correspond to the webxr specs version
  73236. */
  73237. static readonly Version: number;
  73238. /**
  73239. * Construct a new Controller Physics Feature
  73240. * @param _xrSessionManager the corresponding xr session manager
  73241. * @param _options options to create this feature with
  73242. */
  73243. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73244. /**
  73245. * @hidden
  73246. * enable debugging - will show console outputs and the impostor mesh
  73247. */
  73248. _enablePhysicsDebug(): void;
  73249. /**
  73250. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73251. * @param xrController the controller to add
  73252. */
  73253. addController(xrController: WebXRInputSource): void;
  73254. /**
  73255. * attach this feature
  73256. * Will usually be called by the features manager
  73257. *
  73258. * @returns true if successful.
  73259. */
  73260. attach(): boolean;
  73261. /**
  73262. * detach this feature.
  73263. * Will usually be called by the features manager
  73264. *
  73265. * @returns true if successful.
  73266. */
  73267. detach(): boolean;
  73268. /**
  73269. * Get the headset impostor, if enabled
  73270. * @returns the impostor
  73271. */
  73272. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73273. /**
  73274. * Get the physics impostor of a specific controller.
  73275. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73276. * @param controller the controller or the controller id of which to get the impostor
  73277. * @returns the impostor or null
  73278. */
  73279. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73280. /**
  73281. * Update the physics properties provided in the constructor
  73282. * @param newProperties the new properties object
  73283. */
  73284. setPhysicsProperties(newProperties: {
  73285. impostorType?: number;
  73286. impostorSize?: number | {
  73287. width: number;
  73288. height: number;
  73289. depth: number;
  73290. };
  73291. friction?: number;
  73292. restitution?: number;
  73293. }): void;
  73294. protected _onXRFrame(_xrFrame: any): void;
  73295. private _detachController;
  73296. }
  73297. }
  73298. declare module BABYLON {
  73299. /**
  73300. * The motion controller class for all microsoft mixed reality controllers
  73301. */
  73302. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73303. protected readonly _mapping: {
  73304. defaultButton: {
  73305. valueNodeName: string;
  73306. unpressedNodeName: string;
  73307. pressedNodeName: string;
  73308. };
  73309. defaultAxis: {
  73310. valueNodeName: string;
  73311. minNodeName: string;
  73312. maxNodeName: string;
  73313. };
  73314. buttons: {
  73315. "xr-standard-trigger": {
  73316. rootNodeName: string;
  73317. componentProperty: string;
  73318. states: string[];
  73319. };
  73320. "xr-standard-squeeze": {
  73321. rootNodeName: string;
  73322. componentProperty: string;
  73323. states: string[];
  73324. };
  73325. "xr-standard-touchpad": {
  73326. rootNodeName: string;
  73327. labelAnchorNodeName: string;
  73328. touchPointNodeName: string;
  73329. };
  73330. "xr-standard-thumbstick": {
  73331. rootNodeName: string;
  73332. componentProperty: string;
  73333. states: string[];
  73334. };
  73335. };
  73336. axes: {
  73337. "xr-standard-touchpad": {
  73338. "x-axis": {
  73339. rootNodeName: string;
  73340. };
  73341. "y-axis": {
  73342. rootNodeName: string;
  73343. };
  73344. };
  73345. "xr-standard-thumbstick": {
  73346. "x-axis": {
  73347. rootNodeName: string;
  73348. };
  73349. "y-axis": {
  73350. rootNodeName: string;
  73351. };
  73352. };
  73353. };
  73354. };
  73355. /**
  73356. * The base url used to load the left and right controller models
  73357. */
  73358. static MODEL_BASE_URL: string;
  73359. /**
  73360. * The name of the left controller model file
  73361. */
  73362. static MODEL_LEFT_FILENAME: string;
  73363. /**
  73364. * The name of the right controller model file
  73365. */
  73366. static MODEL_RIGHT_FILENAME: string;
  73367. profileId: string;
  73368. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73369. protected _getFilenameAndPath(): {
  73370. filename: string;
  73371. path: string;
  73372. };
  73373. protected _getModelLoadingConstraints(): boolean;
  73374. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73375. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73376. protected _updateModel(): void;
  73377. }
  73378. }
  73379. declare module BABYLON {
  73380. /**
  73381. * The motion controller class for oculus touch (quest, rift).
  73382. * This class supports legacy mapping as well the standard xr mapping
  73383. */
  73384. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73385. private _forceLegacyControllers;
  73386. private _modelRootNode;
  73387. /**
  73388. * The base url used to load the left and right controller models
  73389. */
  73390. static MODEL_BASE_URL: string;
  73391. /**
  73392. * The name of the left controller model file
  73393. */
  73394. static MODEL_LEFT_FILENAME: string;
  73395. /**
  73396. * The name of the right controller model file
  73397. */
  73398. static MODEL_RIGHT_FILENAME: string;
  73399. /**
  73400. * Base Url for the Quest controller model.
  73401. */
  73402. static QUEST_MODEL_BASE_URL: string;
  73403. profileId: string;
  73404. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73405. protected _getFilenameAndPath(): {
  73406. filename: string;
  73407. path: string;
  73408. };
  73409. protected _getModelLoadingConstraints(): boolean;
  73410. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73411. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73412. protected _updateModel(): void;
  73413. /**
  73414. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73415. * between the touch and touch 2.
  73416. */
  73417. private _isQuest;
  73418. }
  73419. }
  73420. declare module BABYLON {
  73421. /**
  73422. * The motion controller class for the standard HTC-Vive controllers
  73423. */
  73424. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73425. private _modelRootNode;
  73426. /**
  73427. * The base url used to load the left and right controller models
  73428. */
  73429. static MODEL_BASE_URL: string;
  73430. /**
  73431. * File name for the controller model.
  73432. */
  73433. static MODEL_FILENAME: string;
  73434. profileId: string;
  73435. /**
  73436. * Create a new Vive motion controller object
  73437. * @param scene the scene to use to create this controller
  73438. * @param gamepadObject the corresponding gamepad object
  73439. * @param handedness the handedness of the controller
  73440. */
  73441. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73442. protected _getFilenameAndPath(): {
  73443. filename: string;
  73444. path: string;
  73445. };
  73446. protected _getModelLoadingConstraints(): boolean;
  73447. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73448. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73449. protected _updateModel(): void;
  73450. }
  73451. }
  73452. declare module BABYLON {
  73453. /**
  73454. * A cursor which tracks a point on a path
  73455. */
  73456. export class PathCursor {
  73457. private path;
  73458. /**
  73459. * Stores path cursor callbacks for when an onchange event is triggered
  73460. */
  73461. private _onchange;
  73462. /**
  73463. * The value of the path cursor
  73464. */
  73465. value: number;
  73466. /**
  73467. * The animation array of the path cursor
  73468. */
  73469. animations: Animation[];
  73470. /**
  73471. * Initializes the path cursor
  73472. * @param path The path to track
  73473. */
  73474. constructor(path: Path2);
  73475. /**
  73476. * Gets the cursor point on the path
  73477. * @returns A point on the path cursor at the cursor location
  73478. */
  73479. getPoint(): Vector3;
  73480. /**
  73481. * Moves the cursor ahead by the step amount
  73482. * @param step The amount to move the cursor forward
  73483. * @returns This path cursor
  73484. */
  73485. moveAhead(step?: number): PathCursor;
  73486. /**
  73487. * Moves the cursor behind by the step amount
  73488. * @param step The amount to move the cursor back
  73489. * @returns This path cursor
  73490. */
  73491. moveBack(step?: number): PathCursor;
  73492. /**
  73493. * Moves the cursor by the step amount
  73494. * If the step amount is greater than one, an exception is thrown
  73495. * @param step The amount to move the cursor
  73496. * @returns This path cursor
  73497. */
  73498. move(step: number): PathCursor;
  73499. /**
  73500. * Ensures that the value is limited between zero and one
  73501. * @returns This path cursor
  73502. */
  73503. private ensureLimits;
  73504. /**
  73505. * Runs onchange callbacks on change (used by the animation engine)
  73506. * @returns This path cursor
  73507. */
  73508. private raiseOnChange;
  73509. /**
  73510. * Executes a function on change
  73511. * @param f A path cursor onchange callback
  73512. * @returns This path cursor
  73513. */
  73514. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73515. }
  73516. }
  73517. declare module BABYLON {
  73518. /** @hidden */
  73519. export var blurPixelShader: {
  73520. name: string;
  73521. shader: string;
  73522. };
  73523. }
  73524. declare module BABYLON {
  73525. /** @hidden */
  73526. export var pointCloudVertexDeclaration: {
  73527. name: string;
  73528. shader: string;
  73529. };
  73530. }
  73531. // Mixins
  73532. interface Window {
  73533. mozIndexedDB: IDBFactory;
  73534. webkitIndexedDB: IDBFactory;
  73535. msIndexedDB: IDBFactory;
  73536. webkitURL: typeof URL;
  73537. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73538. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73539. WebGLRenderingContext: WebGLRenderingContext;
  73540. MSGesture: MSGesture;
  73541. CANNON: any;
  73542. AudioContext: AudioContext;
  73543. webkitAudioContext: AudioContext;
  73544. PointerEvent: any;
  73545. Math: Math;
  73546. Uint8Array: Uint8ArrayConstructor;
  73547. Float32Array: Float32ArrayConstructor;
  73548. mozURL: typeof URL;
  73549. msURL: typeof URL;
  73550. VRFrameData: any; // WebVR, from specs 1.1
  73551. DracoDecoderModule: any;
  73552. setImmediate(handler: (...args: any[]) => void): number;
  73553. }
  73554. interface HTMLCanvasElement {
  73555. requestPointerLock(): void;
  73556. msRequestPointerLock?(): void;
  73557. mozRequestPointerLock?(): void;
  73558. webkitRequestPointerLock?(): void;
  73559. /** Track wether a record is in progress */
  73560. isRecording: boolean;
  73561. /** Capture Stream method defined by some browsers */
  73562. captureStream(fps?: number): MediaStream;
  73563. }
  73564. interface CanvasRenderingContext2D {
  73565. msImageSmoothingEnabled: boolean;
  73566. }
  73567. interface MouseEvent {
  73568. mozMovementX: number;
  73569. mozMovementY: number;
  73570. webkitMovementX: number;
  73571. webkitMovementY: number;
  73572. msMovementX: number;
  73573. msMovementY: number;
  73574. }
  73575. interface Navigator {
  73576. mozGetVRDevices: (any: any) => any;
  73577. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73578. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73579. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73580. webkitGetGamepads(): Gamepad[];
  73581. msGetGamepads(): Gamepad[];
  73582. webkitGamepads(): Gamepad[];
  73583. }
  73584. interface HTMLVideoElement {
  73585. mozSrcObject: any;
  73586. }
  73587. interface Math {
  73588. fround(x: number): number;
  73589. imul(a: number, b: number): number;
  73590. }
  73591. interface WebGLRenderingContext {
  73592. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73593. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73594. vertexAttribDivisor(index: number, divisor: number): void;
  73595. createVertexArray(): any;
  73596. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73597. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73598. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73599. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73600. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73601. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73602. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73603. // Queries
  73604. createQuery(): WebGLQuery;
  73605. deleteQuery(query: WebGLQuery): void;
  73606. beginQuery(target: number, query: WebGLQuery): void;
  73607. endQuery(target: number): void;
  73608. getQueryParameter(query: WebGLQuery, pname: number): any;
  73609. getQuery(target: number, pname: number): any;
  73610. MAX_SAMPLES: number;
  73611. RGBA8: number;
  73612. READ_FRAMEBUFFER: number;
  73613. DRAW_FRAMEBUFFER: number;
  73614. UNIFORM_BUFFER: number;
  73615. HALF_FLOAT_OES: number;
  73616. RGBA16F: number;
  73617. RGBA32F: number;
  73618. R32F: number;
  73619. RG32F: number;
  73620. RGB32F: number;
  73621. R16F: number;
  73622. RG16F: number;
  73623. RGB16F: number;
  73624. RED: number;
  73625. RG: number;
  73626. R8: number;
  73627. RG8: number;
  73628. UNSIGNED_INT_24_8: number;
  73629. DEPTH24_STENCIL8: number;
  73630. MIN: number;
  73631. MAX: number;
  73632. /* Multiple Render Targets */
  73633. drawBuffers(buffers: number[]): void;
  73634. readBuffer(src: number): void;
  73635. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73636. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73637. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73638. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73639. // Occlusion Query
  73640. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73641. ANY_SAMPLES_PASSED: number;
  73642. QUERY_RESULT_AVAILABLE: number;
  73643. QUERY_RESULT: number;
  73644. }
  73645. interface WebGLProgram {
  73646. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73647. }
  73648. interface EXT_disjoint_timer_query {
  73649. QUERY_COUNTER_BITS_EXT: number;
  73650. TIME_ELAPSED_EXT: number;
  73651. TIMESTAMP_EXT: number;
  73652. GPU_DISJOINT_EXT: number;
  73653. QUERY_RESULT_EXT: number;
  73654. QUERY_RESULT_AVAILABLE_EXT: number;
  73655. queryCounterEXT(query: WebGLQuery, target: number): void;
  73656. createQueryEXT(): WebGLQuery;
  73657. beginQueryEXT(target: number, query: WebGLQuery): void;
  73658. endQueryEXT(target: number): void;
  73659. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73660. deleteQueryEXT(query: WebGLQuery): void;
  73661. }
  73662. interface WebGLUniformLocation {
  73663. _currentState: any;
  73664. }
  73665. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73666. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73667. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73668. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73669. interface WebGLRenderingContext {
  73670. readonly RASTERIZER_DISCARD: number;
  73671. readonly DEPTH_COMPONENT24: number;
  73672. readonly TEXTURE_3D: number;
  73673. readonly TEXTURE_2D_ARRAY: number;
  73674. readonly TEXTURE_COMPARE_FUNC: number;
  73675. readonly TEXTURE_COMPARE_MODE: number;
  73676. readonly COMPARE_REF_TO_TEXTURE: number;
  73677. readonly TEXTURE_WRAP_R: number;
  73678. readonly HALF_FLOAT: number;
  73679. readonly RGB8: number;
  73680. readonly RED_INTEGER: number;
  73681. readonly RG_INTEGER: number;
  73682. readonly RGB_INTEGER: number;
  73683. readonly RGBA_INTEGER: number;
  73684. readonly R8_SNORM: number;
  73685. readonly RG8_SNORM: number;
  73686. readonly RGB8_SNORM: number;
  73687. readonly RGBA8_SNORM: number;
  73688. readonly R8I: number;
  73689. readonly RG8I: number;
  73690. readonly RGB8I: number;
  73691. readonly RGBA8I: number;
  73692. readonly R8UI: number;
  73693. readonly RG8UI: number;
  73694. readonly RGB8UI: number;
  73695. readonly RGBA8UI: number;
  73696. readonly R16I: number;
  73697. readonly RG16I: number;
  73698. readonly RGB16I: number;
  73699. readonly RGBA16I: number;
  73700. readonly R16UI: number;
  73701. readonly RG16UI: number;
  73702. readonly RGB16UI: number;
  73703. readonly RGBA16UI: number;
  73704. readonly R32I: number;
  73705. readonly RG32I: number;
  73706. readonly RGB32I: number;
  73707. readonly RGBA32I: number;
  73708. readonly R32UI: number;
  73709. readonly RG32UI: number;
  73710. readonly RGB32UI: number;
  73711. readonly RGBA32UI: number;
  73712. readonly RGB10_A2UI: number;
  73713. readonly R11F_G11F_B10F: number;
  73714. readonly RGB9_E5: number;
  73715. readonly RGB10_A2: number;
  73716. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73717. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73718. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73719. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73720. readonly DEPTH_COMPONENT32F: number;
  73721. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73722. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73723. 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;
  73724. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73725. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73726. readonly TRANSFORM_FEEDBACK: number;
  73727. readonly INTERLEAVED_ATTRIBS: number;
  73728. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73729. createTransformFeedback(): WebGLTransformFeedback;
  73730. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73731. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73732. beginTransformFeedback(primitiveMode: number): void;
  73733. endTransformFeedback(): void;
  73734. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73735. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73736. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73737. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73738. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73739. }
  73740. interface ImageBitmap {
  73741. readonly width: number;
  73742. readonly height: number;
  73743. close(): void;
  73744. }
  73745. interface WebGLQuery extends WebGLObject {
  73746. }
  73747. declare var WebGLQuery: {
  73748. prototype: WebGLQuery;
  73749. new(): WebGLQuery;
  73750. };
  73751. interface WebGLSampler extends WebGLObject {
  73752. }
  73753. declare var WebGLSampler: {
  73754. prototype: WebGLSampler;
  73755. new(): WebGLSampler;
  73756. };
  73757. interface WebGLSync extends WebGLObject {
  73758. }
  73759. declare var WebGLSync: {
  73760. prototype: WebGLSync;
  73761. new(): WebGLSync;
  73762. };
  73763. interface WebGLTransformFeedback extends WebGLObject {
  73764. }
  73765. declare var WebGLTransformFeedback: {
  73766. prototype: WebGLTransformFeedback;
  73767. new(): WebGLTransformFeedback;
  73768. };
  73769. interface WebGLVertexArrayObject extends WebGLObject {
  73770. }
  73771. declare var WebGLVertexArrayObject: {
  73772. prototype: WebGLVertexArrayObject;
  73773. new(): WebGLVertexArrayObject;
  73774. };
  73775. // Type definitions for WebVR API
  73776. // Project: https://w3c.github.io/webvr/
  73777. // Definitions by: six a <https://github.com/lostfictions>
  73778. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73779. interface VRDisplay extends EventTarget {
  73780. /**
  73781. * Dictionary of capabilities describing the VRDisplay.
  73782. */
  73783. readonly capabilities: VRDisplayCapabilities;
  73784. /**
  73785. * z-depth defining the far plane of the eye view frustum
  73786. * enables mapping of values in the render target depth
  73787. * attachment to scene coordinates. Initially set to 10000.0.
  73788. */
  73789. depthFar: number;
  73790. /**
  73791. * z-depth defining the near plane of the eye view frustum
  73792. * enables mapping of values in the render target depth
  73793. * attachment to scene coordinates. Initially set to 0.01.
  73794. */
  73795. depthNear: number;
  73796. /**
  73797. * An identifier for this distinct VRDisplay. Used as an
  73798. * association point in the Gamepad API.
  73799. */
  73800. readonly displayId: number;
  73801. /**
  73802. * A display name, a user-readable name identifying it.
  73803. */
  73804. readonly displayName: string;
  73805. readonly isConnected: boolean;
  73806. readonly isPresenting: boolean;
  73807. /**
  73808. * If this VRDisplay supports room-scale experiences, the optional
  73809. * stage attribute contains details on the room-scale parameters.
  73810. */
  73811. readonly stageParameters: VRStageParameters | null;
  73812. /**
  73813. * Passing the value returned by `requestAnimationFrame` to
  73814. * `cancelAnimationFrame` will unregister the callback.
  73815. * @param handle Define the hanle of the request to cancel
  73816. */
  73817. cancelAnimationFrame(handle: number): void;
  73818. /**
  73819. * Stops presenting to the VRDisplay.
  73820. * @returns a promise to know when it stopped
  73821. */
  73822. exitPresent(): Promise<void>;
  73823. /**
  73824. * Return the current VREyeParameters for the given eye.
  73825. * @param whichEye Define the eye we want the parameter for
  73826. * @returns the eye parameters
  73827. */
  73828. getEyeParameters(whichEye: string): VREyeParameters;
  73829. /**
  73830. * Populates the passed VRFrameData with the information required to render
  73831. * the current frame.
  73832. * @param frameData Define the data structure to populate
  73833. * @returns true if ok otherwise false
  73834. */
  73835. getFrameData(frameData: VRFrameData): boolean;
  73836. /**
  73837. * Get the layers currently being presented.
  73838. * @returns the list of VR layers
  73839. */
  73840. getLayers(): VRLayer[];
  73841. /**
  73842. * Return a VRPose containing the future predicted pose of the VRDisplay
  73843. * when the current frame will be presented. The value returned will not
  73844. * change until JavaScript has returned control to the browser.
  73845. *
  73846. * The VRPose will contain the position, orientation, velocity,
  73847. * and acceleration of each of these properties.
  73848. * @returns the pose object
  73849. */
  73850. getPose(): VRPose;
  73851. /**
  73852. * Return the current instantaneous pose of the VRDisplay, with no
  73853. * prediction applied.
  73854. * @returns the current instantaneous pose
  73855. */
  73856. getImmediatePose(): VRPose;
  73857. /**
  73858. * The callback passed to `requestAnimationFrame` will be called
  73859. * any time a new frame should be rendered. When the VRDisplay is
  73860. * presenting the callback will be called at the native refresh
  73861. * rate of the HMD. When not presenting this function acts
  73862. * identically to how window.requestAnimationFrame acts. Content should
  73863. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73864. * asynchronously from other displays and at differing refresh rates.
  73865. * @param callback Define the eaction to run next frame
  73866. * @returns the request handle it
  73867. */
  73868. requestAnimationFrame(callback: FrameRequestCallback): number;
  73869. /**
  73870. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73871. * Repeat calls while already presenting will update the VRLayers being displayed.
  73872. * @param layers Define the list of layer to present
  73873. * @returns a promise to know when the request has been fulfilled
  73874. */
  73875. requestPresent(layers: VRLayer[]): Promise<void>;
  73876. /**
  73877. * Reset the pose for this display, treating its current position and
  73878. * orientation as the "origin/zero" values. VRPose.position,
  73879. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73880. * updated when calling resetPose(). This should be called in only
  73881. * sitting-space experiences.
  73882. */
  73883. resetPose(): void;
  73884. /**
  73885. * The VRLayer provided to the VRDisplay will be captured and presented
  73886. * in the HMD. Calling this function has the same effect on the source
  73887. * canvas as any other operation that uses its source image, and canvases
  73888. * created without preserveDrawingBuffer set to true will be cleared.
  73889. * @param pose Define the pose to submit
  73890. */
  73891. submitFrame(pose?: VRPose): void;
  73892. }
  73893. declare var VRDisplay: {
  73894. prototype: VRDisplay;
  73895. new(): VRDisplay;
  73896. };
  73897. interface VRLayer {
  73898. leftBounds?: number[] | Float32Array | null;
  73899. rightBounds?: number[] | Float32Array | null;
  73900. source?: HTMLCanvasElement | null;
  73901. }
  73902. interface VRDisplayCapabilities {
  73903. readonly canPresent: boolean;
  73904. readonly hasExternalDisplay: boolean;
  73905. readonly hasOrientation: boolean;
  73906. readonly hasPosition: boolean;
  73907. readonly maxLayers: number;
  73908. }
  73909. interface VREyeParameters {
  73910. /** @deprecated */
  73911. readonly fieldOfView: VRFieldOfView;
  73912. readonly offset: Float32Array;
  73913. readonly renderHeight: number;
  73914. readonly renderWidth: number;
  73915. }
  73916. interface VRFieldOfView {
  73917. readonly downDegrees: number;
  73918. readonly leftDegrees: number;
  73919. readonly rightDegrees: number;
  73920. readonly upDegrees: number;
  73921. }
  73922. interface VRFrameData {
  73923. readonly leftProjectionMatrix: Float32Array;
  73924. readonly leftViewMatrix: Float32Array;
  73925. readonly pose: VRPose;
  73926. readonly rightProjectionMatrix: Float32Array;
  73927. readonly rightViewMatrix: Float32Array;
  73928. readonly timestamp: number;
  73929. }
  73930. interface VRPose {
  73931. readonly angularAcceleration: Float32Array | null;
  73932. readonly angularVelocity: Float32Array | null;
  73933. readonly linearAcceleration: Float32Array | null;
  73934. readonly linearVelocity: Float32Array | null;
  73935. readonly orientation: Float32Array | null;
  73936. readonly position: Float32Array | null;
  73937. readonly timestamp: number;
  73938. }
  73939. interface VRStageParameters {
  73940. sittingToStandingTransform?: Float32Array;
  73941. sizeX?: number;
  73942. sizeY?: number;
  73943. }
  73944. interface Navigator {
  73945. getVRDisplays(): Promise<VRDisplay[]>;
  73946. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73947. }
  73948. interface Window {
  73949. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73950. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73951. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73952. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73953. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73954. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73955. }
  73956. interface Gamepad {
  73957. readonly displayId: number;
  73958. }
  73959. type XRSessionMode =
  73960. | "inline"
  73961. | "immersive-vr"
  73962. | "immersive-ar";
  73963. type XRReferenceSpaceType =
  73964. | "viewer"
  73965. | "local"
  73966. | "local-floor"
  73967. | "bounded-floor"
  73968. | "unbounded";
  73969. type XREnvironmentBlendMode =
  73970. | "opaque"
  73971. | "additive"
  73972. | "alpha-blend";
  73973. type XRVisibilityState =
  73974. | "visible"
  73975. | "visible-blurred"
  73976. | "hidden";
  73977. type XRHandedness =
  73978. | "none"
  73979. | "left"
  73980. | "right";
  73981. type XRTargetRayMode =
  73982. | "gaze"
  73983. | "tracked-pointer"
  73984. | "screen";
  73985. type XREye =
  73986. | "none"
  73987. | "left"
  73988. | "right";
  73989. type XREventType =
  73990. | "devicechange"
  73991. | "visibilitychange"
  73992. | "end"
  73993. | "inputsourceschange"
  73994. | "select"
  73995. | "selectstart"
  73996. | "selectend"
  73997. | "squeeze"
  73998. | "squeezestart"
  73999. | "squeezeend"
  74000. | "reset";
  74001. interface XRSpace extends EventTarget {
  74002. }
  74003. interface XRRenderState {
  74004. depthNear?: number;
  74005. depthFar?: number;
  74006. inlineVerticalFieldOfView?: number;
  74007. baseLayer?: XRWebGLLayer;
  74008. }
  74009. interface XRInputSource {
  74010. handedness: XRHandedness;
  74011. targetRayMode: XRTargetRayMode;
  74012. targetRaySpace: XRSpace;
  74013. gripSpace: XRSpace | undefined;
  74014. gamepad: Gamepad | undefined;
  74015. profiles: Array<string>;
  74016. }
  74017. interface XRSessionInit {
  74018. optionalFeatures?: string[];
  74019. requiredFeatures?: string[];
  74020. }
  74021. interface XRSession {
  74022. addEventListener: Function;
  74023. removeEventListener: Function;
  74024. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74025. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74026. requestAnimationFrame: Function;
  74027. end(): Promise<void>;
  74028. renderState: XRRenderState;
  74029. inputSources: Array<XRInputSource>;
  74030. // hit test
  74031. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74032. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74033. // legacy AR hit test
  74034. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74035. // legacy plane detection
  74036. updateWorldTrackingState(options: {
  74037. planeDetectionState?: { enabled: boolean; }
  74038. }): void;
  74039. }
  74040. interface XRReferenceSpace extends XRSpace {
  74041. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74042. onreset: any;
  74043. }
  74044. type XRPlaneSet = Set<XRPlane>;
  74045. type XRAnchorSet = Set<XRAnchor>;
  74046. interface XRFrame {
  74047. session: XRSession;
  74048. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74049. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74050. // AR
  74051. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74052. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74053. // Anchors
  74054. trackedAnchors?: XRAnchorSet;
  74055. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74056. // Planes
  74057. worldInformation: {
  74058. detectedPlanes?: XRPlaneSet;
  74059. };
  74060. }
  74061. interface XRViewerPose extends XRPose {
  74062. views: Array<XRView>;
  74063. }
  74064. interface XRPose {
  74065. transform: XRRigidTransform;
  74066. emulatedPosition: boolean;
  74067. }
  74068. interface XRWebGLLayerOptions {
  74069. antialias?: boolean;
  74070. depth?: boolean;
  74071. stencil?: boolean;
  74072. alpha?: boolean;
  74073. multiview?: boolean;
  74074. framebufferScaleFactor?: number;
  74075. }
  74076. declare var XRWebGLLayer: {
  74077. prototype: XRWebGLLayer;
  74078. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74079. };
  74080. interface XRWebGLLayer {
  74081. framebuffer: WebGLFramebuffer;
  74082. framebufferWidth: number;
  74083. framebufferHeight: number;
  74084. getViewport: Function;
  74085. }
  74086. declare class XRRigidTransform {
  74087. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74088. position: DOMPointReadOnly;
  74089. orientation: DOMPointReadOnly;
  74090. matrix: Float32Array;
  74091. inverse: XRRigidTransform;
  74092. }
  74093. interface XRView {
  74094. eye: XREye;
  74095. projectionMatrix: Float32Array;
  74096. transform: XRRigidTransform;
  74097. }
  74098. interface XRInputSourceChangeEvent {
  74099. session: XRSession;
  74100. removed: Array<XRInputSource>;
  74101. added: Array<XRInputSource>;
  74102. }
  74103. interface XRInputSourceEvent extends Event {
  74104. readonly frame: XRFrame;
  74105. readonly inputSource: XRInputSource;
  74106. }
  74107. // Experimental(er) features
  74108. declare class XRRay {
  74109. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74110. origin: DOMPointReadOnly;
  74111. direction: DOMPointReadOnly;
  74112. matrix: Float32Array;
  74113. }
  74114. declare enum XRHitTestTrackableType {
  74115. "point",
  74116. "plane"
  74117. }
  74118. interface XRHitResult {
  74119. hitMatrix: Float32Array;
  74120. }
  74121. interface XRTransientInputHitTestResult {
  74122. readonly inputSource: XRInputSource;
  74123. readonly results: Array<XRHitTestResult>;
  74124. }
  74125. interface XRHitTestResult {
  74126. getPose(baseSpace: XRSpace): XRPose | undefined;
  74127. // When anchor system is enabled
  74128. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74129. }
  74130. interface XRHitTestSource {
  74131. cancel(): void;
  74132. }
  74133. interface XRTransientInputHitTestSource {
  74134. cancel(): void;
  74135. }
  74136. interface XRHitTestOptionsInit {
  74137. space: XRSpace;
  74138. entityTypes?: Array<XRHitTestTrackableType>;
  74139. offsetRay?: XRRay;
  74140. }
  74141. interface XRTransientInputHitTestOptionsInit {
  74142. profile: string;
  74143. entityTypes?: Array<XRHitTestTrackableType>;
  74144. offsetRay?: XRRay;
  74145. }
  74146. interface XRAnchor {
  74147. anchorSpace: XRSpace;
  74148. delete(): void;
  74149. }
  74150. interface XRPlane {
  74151. orientation: "Horizontal" | "Vertical";
  74152. planeSpace: XRSpace;
  74153. polygon: Array<DOMPointReadOnly>;
  74154. lastChangedTime: number;
  74155. }
  74156. /**
  74157. * @ignore
  74158. */
  74159. declare module BABYLON.GLTF2.Exporter {
  74160. }
  74161. /**
  74162. * @ignore
  74163. */
  74164. declare module BABYLON.GLTF1 {
  74165. }
  74166. declare module BABYLON.GUI {
  74167. /**
  74168. * Class used to specific a value and its associated unit
  74169. */
  74170. export class ValueAndUnit {
  74171. /** defines the unit to store */
  74172. unit: number;
  74173. /** defines a boolean indicating if the value can be negative */
  74174. negativeValueAllowed: boolean;
  74175. private _value;
  74176. private _originalUnit;
  74177. /**
  74178. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74179. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74180. */
  74181. ignoreAdaptiveScaling: boolean;
  74182. /**
  74183. * Creates a new ValueAndUnit
  74184. * @param value defines the value to store
  74185. * @param unit defines the unit to store
  74186. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74187. */
  74188. constructor(value: number,
  74189. /** defines the unit to store */
  74190. unit?: number,
  74191. /** defines a boolean indicating if the value can be negative */
  74192. negativeValueAllowed?: boolean);
  74193. /** Gets a boolean indicating if the value is a percentage */
  74194. get isPercentage(): boolean;
  74195. /** Gets a boolean indicating if the value is store as pixel */
  74196. get isPixel(): boolean;
  74197. /** Gets direct internal value */
  74198. get internalValue(): number;
  74199. /**
  74200. * Gets value as pixel
  74201. * @param host defines the root host
  74202. * @param refValue defines the reference value for percentages
  74203. * @returns the value as pixel
  74204. */
  74205. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74206. /**
  74207. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74208. * @param value defines the value to store
  74209. * @param unit defines the unit to store
  74210. * @returns the current ValueAndUnit
  74211. */
  74212. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74213. /**
  74214. * Gets the value accordingly to its unit
  74215. * @param host defines the root host
  74216. * @returns the value
  74217. */
  74218. getValue(host: AdvancedDynamicTexture): number;
  74219. /**
  74220. * Gets a string representation of the value
  74221. * @param host defines the root host
  74222. * @param decimals defines an optional number of decimals to display
  74223. * @returns a string
  74224. */
  74225. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74226. /**
  74227. * Store a value parsed from a string
  74228. * @param source defines the source string
  74229. * @returns true if the value was successfully parsed
  74230. */
  74231. fromString(source: string | number): boolean;
  74232. private static _Regex;
  74233. private static _UNITMODE_PERCENTAGE;
  74234. private static _UNITMODE_PIXEL;
  74235. /** UNITMODE_PERCENTAGE */
  74236. static get UNITMODE_PERCENTAGE(): number;
  74237. /** UNITMODE_PIXEL */
  74238. static get UNITMODE_PIXEL(): number;
  74239. }
  74240. }
  74241. declare module BABYLON.GUI {
  74242. /**
  74243. * Define a style used by control to automatically setup properties based on a template.
  74244. * Only support font related properties so far
  74245. */
  74246. export class Style implements BABYLON.IDisposable {
  74247. private _fontFamily;
  74248. private _fontStyle;
  74249. private _fontWeight;
  74250. /** @hidden */
  74251. _host: AdvancedDynamicTexture;
  74252. /** @hidden */
  74253. _fontSize: ValueAndUnit;
  74254. /**
  74255. * BABYLON.Observable raised when the style values are changed
  74256. */
  74257. onChangedObservable: BABYLON.Observable<Style>;
  74258. /**
  74259. * Creates a new style object
  74260. * @param host defines the AdvancedDynamicTexture which hosts this style
  74261. */
  74262. constructor(host: AdvancedDynamicTexture);
  74263. /**
  74264. * Gets or sets the font size
  74265. */
  74266. get fontSize(): string | number;
  74267. set fontSize(value: string | number);
  74268. /**
  74269. * Gets or sets the font family
  74270. */
  74271. get fontFamily(): string;
  74272. set fontFamily(value: string);
  74273. /**
  74274. * Gets or sets the font style
  74275. */
  74276. get fontStyle(): string;
  74277. set fontStyle(value: string);
  74278. /** Gets or sets font weight */
  74279. get fontWeight(): string;
  74280. set fontWeight(value: string);
  74281. /** Dispose all associated resources */
  74282. dispose(): void;
  74283. }
  74284. }
  74285. declare module BABYLON.GUI {
  74286. /**
  74287. * Class used to transport BABYLON.Vector2 information for pointer events
  74288. */
  74289. export class Vector2WithInfo extends BABYLON.Vector2 {
  74290. /** defines the current mouse button index */
  74291. buttonIndex: number;
  74292. /**
  74293. * Creates a new Vector2WithInfo
  74294. * @param source defines the vector2 data to transport
  74295. * @param buttonIndex defines the current mouse button index
  74296. */
  74297. constructor(source: BABYLON.Vector2,
  74298. /** defines the current mouse button index */
  74299. buttonIndex?: number);
  74300. }
  74301. /** Class used to provide 2D matrix features */
  74302. export class Matrix2D {
  74303. /** Gets the internal array of 6 floats used to store matrix data */
  74304. m: Float32Array;
  74305. /**
  74306. * Creates a new matrix
  74307. * @param m00 defines value for (0, 0)
  74308. * @param m01 defines value for (0, 1)
  74309. * @param m10 defines value for (1, 0)
  74310. * @param m11 defines value for (1, 1)
  74311. * @param m20 defines value for (2, 0)
  74312. * @param m21 defines value for (2, 1)
  74313. */
  74314. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74315. /**
  74316. * Fills the matrix from direct values
  74317. * @param m00 defines value for (0, 0)
  74318. * @param m01 defines value for (0, 1)
  74319. * @param m10 defines value for (1, 0)
  74320. * @param m11 defines value for (1, 1)
  74321. * @param m20 defines value for (2, 0)
  74322. * @param m21 defines value for (2, 1)
  74323. * @returns the current modified matrix
  74324. */
  74325. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74326. /**
  74327. * Gets matrix determinant
  74328. * @returns the determinant
  74329. */
  74330. determinant(): number;
  74331. /**
  74332. * Inverses the matrix and stores it in a target matrix
  74333. * @param result defines the target matrix
  74334. * @returns the current matrix
  74335. */
  74336. invertToRef(result: Matrix2D): Matrix2D;
  74337. /**
  74338. * Multiplies the current matrix with another one
  74339. * @param other defines the second operand
  74340. * @param result defines the target matrix
  74341. * @returns the current matrix
  74342. */
  74343. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74344. /**
  74345. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74346. * @param x defines the x coordinate to transform
  74347. * @param y defines the x coordinate to transform
  74348. * @param result defines the target vector2
  74349. * @returns the current matrix
  74350. */
  74351. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74352. /**
  74353. * Creates an identity matrix
  74354. * @returns a new matrix
  74355. */
  74356. static Identity(): Matrix2D;
  74357. /**
  74358. * Creates a translation matrix and stores it in a target matrix
  74359. * @param x defines the x coordinate of the translation
  74360. * @param y defines the y coordinate of the translation
  74361. * @param result defines the target matrix
  74362. */
  74363. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74364. /**
  74365. * Creates a scaling matrix and stores it in a target matrix
  74366. * @param x defines the x coordinate of the scaling
  74367. * @param y defines the y coordinate of the scaling
  74368. * @param result defines the target matrix
  74369. */
  74370. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74371. /**
  74372. * Creates a rotation matrix and stores it in a target matrix
  74373. * @param angle defines the rotation angle
  74374. * @param result defines the target matrix
  74375. */
  74376. static RotationToRef(angle: number, result: Matrix2D): void;
  74377. private static _TempPreTranslationMatrix;
  74378. private static _TempPostTranslationMatrix;
  74379. private static _TempRotationMatrix;
  74380. private static _TempScalingMatrix;
  74381. private static _TempCompose0;
  74382. private static _TempCompose1;
  74383. private static _TempCompose2;
  74384. /**
  74385. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74386. * @param tx defines the x coordinate of the translation
  74387. * @param ty defines the y coordinate of the translation
  74388. * @param angle defines the rotation angle
  74389. * @param scaleX defines the x coordinate of the scaling
  74390. * @param scaleY defines the y coordinate of the scaling
  74391. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74392. * @param result defines the target matrix
  74393. */
  74394. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74395. }
  74396. }
  74397. declare module BABYLON.GUI {
  74398. /**
  74399. * Class used to store 2D control sizes
  74400. */
  74401. export class Measure {
  74402. /** defines left coordinate */
  74403. left: number;
  74404. /** defines top coordinate */
  74405. top: number;
  74406. /** defines width dimension */
  74407. width: number;
  74408. /** defines height dimension */
  74409. height: number;
  74410. /**
  74411. * Creates a new measure
  74412. * @param left defines left coordinate
  74413. * @param top defines top coordinate
  74414. * @param width defines width dimension
  74415. * @param height defines height dimension
  74416. */
  74417. constructor(
  74418. /** defines left coordinate */
  74419. left: number,
  74420. /** defines top coordinate */
  74421. top: number,
  74422. /** defines width dimension */
  74423. width: number,
  74424. /** defines height dimension */
  74425. height: number);
  74426. /**
  74427. * Copy from another measure
  74428. * @param other defines the other measure to copy from
  74429. */
  74430. copyFrom(other: Measure): void;
  74431. /**
  74432. * Copy from a group of 4 floats
  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. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74439. /**
  74440. * Computes the axis aligned bounding box measure for two given measures
  74441. * @param a Input measure
  74442. * @param b Input measure
  74443. * @param result the resulting bounding measure
  74444. */
  74445. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74446. /**
  74447. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74448. * @param transform the matrix to transform the measure before computing the AABB
  74449. * @param result the resulting AABB
  74450. */
  74451. transformToRef(transform: Matrix2D, result: Measure): void;
  74452. /**
  74453. * Check equality between this measure and another one
  74454. * @param other defines the other measures
  74455. * @returns true if both measures are equals
  74456. */
  74457. isEqualsTo(other: Measure): boolean;
  74458. /**
  74459. * Creates an empty measure
  74460. * @returns a new measure
  74461. */
  74462. static Empty(): Measure;
  74463. }
  74464. }
  74465. declare module BABYLON.GUI {
  74466. /**
  74467. * Interface used to define a control that can receive focus
  74468. */
  74469. export interface IFocusableControl {
  74470. /**
  74471. * Function called when the control receives the focus
  74472. */
  74473. onFocus(): void;
  74474. /**
  74475. * Function called when the control loses the focus
  74476. */
  74477. onBlur(): void;
  74478. /**
  74479. * Function called to let the control handle keyboard events
  74480. * @param evt defines the current keyboard event
  74481. */
  74482. processKeyboard(evt: KeyboardEvent): void;
  74483. /**
  74484. * Function called to get the list of controls that should not steal the focus from this control
  74485. * @returns an array of controls
  74486. */
  74487. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74488. }
  74489. /**
  74490. * Class used to create texture to support 2D GUI elements
  74491. * @see http://doc.babylonjs.com/how_to/gui
  74492. */
  74493. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74494. private _isDirty;
  74495. private _renderObserver;
  74496. private _resizeObserver;
  74497. private _preKeyboardObserver;
  74498. private _pointerMoveObserver;
  74499. private _pointerObserver;
  74500. private _canvasPointerOutObserver;
  74501. private _background;
  74502. /** @hidden */
  74503. _rootContainer: Container;
  74504. /** @hidden */
  74505. _lastPickedControl: Control;
  74506. /** @hidden */
  74507. _lastControlOver: {
  74508. [pointerId: number]: Control;
  74509. };
  74510. /** @hidden */
  74511. _lastControlDown: {
  74512. [pointerId: number]: Control;
  74513. };
  74514. /** @hidden */
  74515. _capturingControl: {
  74516. [pointerId: number]: Control;
  74517. };
  74518. /** @hidden */
  74519. _shouldBlockPointer: boolean;
  74520. /** @hidden */
  74521. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74522. /** @hidden */
  74523. _linkedControls: Control[];
  74524. private _isFullscreen;
  74525. private _fullscreenViewport;
  74526. private _idealWidth;
  74527. private _idealHeight;
  74528. private _useSmallestIdeal;
  74529. private _renderAtIdealSize;
  74530. private _focusedControl;
  74531. private _blockNextFocusCheck;
  74532. private _renderScale;
  74533. private _rootElement;
  74534. private _cursorChanged;
  74535. private _defaultMousePointerId;
  74536. /** @hidden */
  74537. _numLayoutCalls: number;
  74538. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74539. get numLayoutCalls(): number;
  74540. /** @hidden */
  74541. _numRenderCalls: number;
  74542. /** Gets the number of render calls made the last time the ADT has been rendered */
  74543. get numRenderCalls(): number;
  74544. /**
  74545. * Define type to string to ensure compatibility across browsers
  74546. * Safari doesn't support DataTransfer constructor
  74547. */
  74548. private _clipboardData;
  74549. /**
  74550. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74551. */
  74552. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74553. /**
  74554. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74555. */
  74556. onControlPickedObservable: BABYLON.Observable<Control>;
  74557. /**
  74558. * BABYLON.Observable event triggered before layout is evaluated
  74559. */
  74560. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74561. /**
  74562. * BABYLON.Observable event triggered after the layout was evaluated
  74563. */
  74564. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74565. /**
  74566. * BABYLON.Observable event triggered before the texture is rendered
  74567. */
  74568. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74569. /**
  74570. * BABYLON.Observable event triggered after the texture was rendered
  74571. */
  74572. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74573. /**
  74574. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74575. */
  74576. premulAlpha: boolean;
  74577. /**
  74578. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74579. * Useful when you want more antialiasing
  74580. */
  74581. get renderScale(): number;
  74582. set renderScale(value: number);
  74583. /** Gets or sets the background color */
  74584. get background(): string;
  74585. set background(value: string);
  74586. /**
  74587. * Gets or sets the ideal width used to design controls.
  74588. * The GUI will then rescale everything accordingly
  74589. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74590. */
  74591. get idealWidth(): number;
  74592. set idealWidth(value: number);
  74593. /**
  74594. * Gets or sets the ideal height used to design controls.
  74595. * The GUI will then rescale everything accordingly
  74596. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74597. */
  74598. get idealHeight(): number;
  74599. set idealHeight(value: number);
  74600. /**
  74601. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74602. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74603. */
  74604. get useSmallestIdeal(): boolean;
  74605. set useSmallestIdeal(value: boolean);
  74606. /**
  74607. * Gets or sets a boolean indicating if adaptive scaling must be used
  74608. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74609. */
  74610. get renderAtIdealSize(): boolean;
  74611. set renderAtIdealSize(value: boolean);
  74612. /**
  74613. * Gets the ratio used when in "ideal mode"
  74614. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74615. * */
  74616. get idealRatio(): number;
  74617. /**
  74618. * Gets the underlying layer used to render the texture when in fullscreen mode
  74619. */
  74620. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74621. /**
  74622. * Gets the root container control
  74623. */
  74624. get rootContainer(): Container;
  74625. /**
  74626. * Returns an array containing the root container.
  74627. * This is mostly used to let the Inspector introspects the ADT
  74628. * @returns an array containing the rootContainer
  74629. */
  74630. getChildren(): Array<Container>;
  74631. /**
  74632. * Will return all controls that are inside this texture
  74633. * @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
  74634. * @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
  74635. * @return all child controls
  74636. */
  74637. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74638. /**
  74639. * Gets or sets the current focused control
  74640. */
  74641. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74642. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74643. /**
  74644. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74645. */
  74646. get isForeground(): boolean;
  74647. set isForeground(value: boolean);
  74648. /**
  74649. * Gets or set information about clipboardData
  74650. */
  74651. get clipboardData(): string;
  74652. set clipboardData(value: string);
  74653. /**
  74654. * Creates a new AdvancedDynamicTexture
  74655. * @param name defines the name of the texture
  74656. * @param width defines the width of the texture
  74657. * @param height defines the height of the texture
  74658. * @param scene defines the hosting scene
  74659. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74660. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74661. */
  74662. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74663. /**
  74664. * Get the current class name of the texture useful for serialization or dynamic coding.
  74665. * @returns "AdvancedDynamicTexture"
  74666. */
  74667. getClassName(): string;
  74668. /**
  74669. * Function used to execute a function on all controls
  74670. * @param func defines the function to execute
  74671. * @param container defines the container where controls belong. If null the root container will be used
  74672. */
  74673. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74674. private _useInvalidateRectOptimization;
  74675. /**
  74676. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74677. */
  74678. get useInvalidateRectOptimization(): boolean;
  74679. set useInvalidateRectOptimization(value: boolean);
  74680. private _invalidatedRectangle;
  74681. /**
  74682. * Invalidates a rectangle area on the gui texture
  74683. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74684. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74685. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74686. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74687. */
  74688. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74689. /**
  74690. * Marks the texture as dirty forcing a complete update
  74691. */
  74692. markAsDirty(): void;
  74693. /**
  74694. * Helper function used to create a new style
  74695. * @returns a new style
  74696. * @see http://doc.babylonjs.com/how_to/gui#styles
  74697. */
  74698. createStyle(): Style;
  74699. /**
  74700. * Adds a new control to the root container
  74701. * @param control defines the control to add
  74702. * @returns the current texture
  74703. */
  74704. addControl(control: Control): AdvancedDynamicTexture;
  74705. /**
  74706. * Removes a control from the root container
  74707. * @param control defines the control to remove
  74708. * @returns the current texture
  74709. */
  74710. removeControl(control: Control): AdvancedDynamicTexture;
  74711. /**
  74712. * Release all resources
  74713. */
  74714. dispose(): void;
  74715. private _onResize;
  74716. /** @hidden */
  74717. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74718. /**
  74719. * Get screen coordinates for a vector3
  74720. * @param position defines the position to project
  74721. * @param worldMatrix defines the world matrix to use
  74722. * @returns the projected position
  74723. */
  74724. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74725. private _checkUpdate;
  74726. private _clearMeasure;
  74727. private _render;
  74728. /** @hidden */
  74729. _changeCursor(cursor: string): void;
  74730. /** @hidden */
  74731. _registerLastControlDown(control: Control, pointerId: number): void;
  74732. private _doPicking;
  74733. /** @hidden */
  74734. _cleanControlAfterRemovalFromList(list: {
  74735. [pointerId: number]: Control;
  74736. }, control: Control): void;
  74737. /** @hidden */
  74738. _cleanControlAfterRemoval(control: Control): void;
  74739. /** Attach to all scene events required to support pointer events */
  74740. attach(): void;
  74741. /** @hidden */
  74742. private onClipboardCopy;
  74743. /** @hidden */
  74744. private onClipboardCut;
  74745. /** @hidden */
  74746. private onClipboardPaste;
  74747. /**
  74748. * Register the clipboard Events onto the canvas
  74749. */
  74750. registerClipboardEvents(): void;
  74751. /**
  74752. * Unregister the clipboard Events from the canvas
  74753. */
  74754. unRegisterClipboardEvents(): void;
  74755. /**
  74756. * Connect the texture to a hosting mesh to enable interactions
  74757. * @param mesh defines the mesh to attach to
  74758. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74759. */
  74760. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74761. /**
  74762. * Move the focus to a specific control
  74763. * @param control defines the control which will receive the focus
  74764. */
  74765. moveFocusToControl(control: IFocusableControl): void;
  74766. private _manageFocus;
  74767. private _attachToOnPointerOut;
  74768. /**
  74769. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74770. * @param mesh defines the mesh which will receive the texture
  74771. * @param width defines the texture width (1024 by default)
  74772. * @param height defines the texture height (1024 by default)
  74773. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74774. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74775. * @returns a new AdvancedDynamicTexture
  74776. */
  74777. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74778. /**
  74779. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74780. * In this mode the texture will rely on a layer for its rendering.
  74781. * This allows it to be treated like any other layer.
  74782. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74783. * LayerMask is set through advancedTexture.layer.layerMask
  74784. * @param name defines name for the texture
  74785. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74786. * @param scene defines the hsoting scene
  74787. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74788. * @returns a new AdvancedDynamicTexture
  74789. */
  74790. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74791. }
  74792. }
  74793. declare module BABYLON.GUI {
  74794. /**
  74795. * Root class used for all 2D controls
  74796. * @see http://doc.babylonjs.com/how_to/gui#controls
  74797. */
  74798. export class Control {
  74799. /** defines the name of the control */
  74800. name?: string | undefined;
  74801. /**
  74802. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74803. */
  74804. static AllowAlphaInheritance: boolean;
  74805. private _alpha;
  74806. private _alphaSet;
  74807. private _zIndex;
  74808. /** @hidden */
  74809. _host: AdvancedDynamicTexture;
  74810. /** Gets or sets the control parent */
  74811. parent: BABYLON.Nullable<Container>;
  74812. /** @hidden */
  74813. _currentMeasure: Measure;
  74814. private _fontFamily;
  74815. private _fontStyle;
  74816. private _fontWeight;
  74817. private _fontSize;
  74818. private _font;
  74819. /** @hidden */
  74820. _width: ValueAndUnit;
  74821. /** @hidden */
  74822. _height: ValueAndUnit;
  74823. /** @hidden */
  74824. protected _fontOffset: {
  74825. ascent: number;
  74826. height: number;
  74827. descent: number;
  74828. };
  74829. private _color;
  74830. private _style;
  74831. private _styleObserver;
  74832. /** @hidden */
  74833. protected _horizontalAlignment: number;
  74834. /** @hidden */
  74835. protected _verticalAlignment: number;
  74836. /** @hidden */
  74837. protected _isDirty: boolean;
  74838. /** @hidden */
  74839. protected _wasDirty: boolean;
  74840. /** @hidden */
  74841. _tempParentMeasure: Measure;
  74842. /** @hidden */
  74843. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74844. /** @hidden */
  74845. protected _cachedParentMeasure: Measure;
  74846. private _paddingLeft;
  74847. private _paddingRight;
  74848. private _paddingTop;
  74849. private _paddingBottom;
  74850. /** @hidden */
  74851. _left: ValueAndUnit;
  74852. /** @hidden */
  74853. _top: ValueAndUnit;
  74854. private _scaleX;
  74855. private _scaleY;
  74856. private _rotation;
  74857. private _transformCenterX;
  74858. private _transformCenterY;
  74859. /** @hidden */
  74860. _transformMatrix: Matrix2D;
  74861. /** @hidden */
  74862. protected _invertTransformMatrix: Matrix2D;
  74863. /** @hidden */
  74864. protected _transformedPosition: BABYLON.Vector2;
  74865. private _isMatrixDirty;
  74866. private _cachedOffsetX;
  74867. private _cachedOffsetY;
  74868. private _isVisible;
  74869. private _isHighlighted;
  74870. /** @hidden */
  74871. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74872. private _fontSet;
  74873. private _dummyVector2;
  74874. private _downCount;
  74875. private _enterCount;
  74876. private _doNotRender;
  74877. private _downPointerIds;
  74878. protected _isEnabled: boolean;
  74879. protected _disabledColor: string;
  74880. protected _disabledColorItem: string;
  74881. /** @hidden */
  74882. protected _rebuildLayout: boolean;
  74883. /** @hidden */
  74884. _customData: any;
  74885. /** @hidden */
  74886. _isClipped: boolean;
  74887. /** @hidden */
  74888. _automaticSize: boolean;
  74889. /** @hidden */
  74890. _tag: any;
  74891. /**
  74892. * 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
  74893. */
  74894. uniqueId: number;
  74895. /**
  74896. * Gets or sets an object used to store user defined information for the node
  74897. */
  74898. metadata: any;
  74899. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74900. isHitTestVisible: boolean;
  74901. /** Gets or sets a boolean indicating if the control can block pointer events */
  74902. isPointerBlocker: boolean;
  74903. /** Gets or sets a boolean indicating if the control can be focusable */
  74904. isFocusInvisible: boolean;
  74905. /**
  74906. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74907. * 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
  74908. */
  74909. clipChildren: boolean;
  74910. /**
  74911. * Gets or sets a boolean indicating that control content must be clipped
  74912. * 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
  74913. */
  74914. clipContent: boolean;
  74915. /**
  74916. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74917. */
  74918. useBitmapCache: boolean;
  74919. private _cacheData;
  74920. private _shadowOffsetX;
  74921. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74922. get shadowOffsetX(): number;
  74923. set shadowOffsetX(value: number);
  74924. private _shadowOffsetY;
  74925. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74926. get shadowOffsetY(): number;
  74927. set shadowOffsetY(value: number);
  74928. private _shadowBlur;
  74929. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74930. get shadowBlur(): number;
  74931. set shadowBlur(value: number);
  74932. private _shadowColor;
  74933. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74934. get shadowColor(): string;
  74935. set shadowColor(value: string);
  74936. /** Gets or sets the cursor to use when the control is hovered */
  74937. hoverCursor: string;
  74938. /** @hidden */
  74939. protected _linkOffsetX: ValueAndUnit;
  74940. /** @hidden */
  74941. protected _linkOffsetY: ValueAndUnit;
  74942. /** Gets the control type name */
  74943. get typeName(): string;
  74944. /**
  74945. * Get the current class name of the control.
  74946. * @returns current class name
  74947. */
  74948. getClassName(): string;
  74949. /**
  74950. * An event triggered when pointer wheel is scrolled
  74951. */
  74952. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74953. /**
  74954. * An event triggered when the pointer move over the control.
  74955. */
  74956. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74957. /**
  74958. * An event triggered when the pointer move out of the control.
  74959. */
  74960. onPointerOutObservable: BABYLON.Observable<Control>;
  74961. /**
  74962. * An event triggered when the pointer taps the control
  74963. */
  74964. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74965. /**
  74966. * An event triggered when pointer up
  74967. */
  74968. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74969. /**
  74970. * An event triggered when a control is clicked on
  74971. */
  74972. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74973. /**
  74974. * An event triggered when pointer enters the control
  74975. */
  74976. onPointerEnterObservable: BABYLON.Observable<Control>;
  74977. /**
  74978. * An event triggered when the control is marked as dirty
  74979. */
  74980. onDirtyObservable: BABYLON.Observable<Control>;
  74981. /**
  74982. * An event triggered before drawing the control
  74983. */
  74984. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74985. /**
  74986. * An event triggered after the control was drawn
  74987. */
  74988. onAfterDrawObservable: BABYLON.Observable<Control>;
  74989. /**
  74990. * An event triggered when the control has been disposed
  74991. */
  74992. onDisposeObservable: BABYLON.Observable<Control>;
  74993. /**
  74994. * Get the hosting AdvancedDynamicTexture
  74995. */
  74996. get host(): AdvancedDynamicTexture;
  74997. /** Gets or set information about font offsets (used to render and align text) */
  74998. get fontOffset(): {
  74999. ascent: number;
  75000. height: number;
  75001. descent: number;
  75002. };
  75003. set fontOffset(offset: {
  75004. ascent: number;
  75005. height: number;
  75006. descent: number;
  75007. });
  75008. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75009. get alpha(): number;
  75010. set alpha(value: number);
  75011. /**
  75012. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75013. */
  75014. get isHighlighted(): boolean;
  75015. set isHighlighted(value: boolean);
  75016. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75017. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75018. */
  75019. get scaleX(): number;
  75020. set scaleX(value: number);
  75021. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75022. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75023. */
  75024. get scaleY(): number;
  75025. set scaleY(value: number);
  75026. /** Gets or sets the rotation angle (0 by default)
  75027. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75028. */
  75029. get rotation(): number;
  75030. set rotation(value: number);
  75031. /** Gets or sets the transformation center on Y axis (0 by default)
  75032. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75033. */
  75034. get transformCenterY(): number;
  75035. set transformCenterY(value: number);
  75036. /** Gets or sets the transformation center on X axis (0 by default)
  75037. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75038. */
  75039. get transformCenterX(): number;
  75040. set transformCenterX(value: number);
  75041. /**
  75042. * Gets or sets the horizontal alignment
  75043. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75044. */
  75045. get horizontalAlignment(): number;
  75046. set horizontalAlignment(value: number);
  75047. /**
  75048. * Gets or sets the vertical alignment
  75049. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75050. */
  75051. get verticalAlignment(): number;
  75052. set verticalAlignment(value: number);
  75053. /**
  75054. * Gets or sets control width
  75055. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75056. */
  75057. get width(): string | number;
  75058. set width(value: string | number);
  75059. /**
  75060. * Gets or sets the control width in pixel
  75061. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75062. */
  75063. get widthInPixels(): number;
  75064. set widthInPixels(value: number);
  75065. /**
  75066. * Gets or sets control height
  75067. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75068. */
  75069. get height(): string | number;
  75070. set height(value: string | number);
  75071. /**
  75072. * Gets or sets control height in pixel
  75073. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75074. */
  75075. get heightInPixels(): number;
  75076. set heightInPixels(value: number);
  75077. /** Gets or set font family */
  75078. get fontFamily(): string;
  75079. set fontFamily(value: string);
  75080. /** Gets or sets font style */
  75081. get fontStyle(): string;
  75082. set fontStyle(value: string);
  75083. /** Gets or sets font weight */
  75084. get fontWeight(): string;
  75085. set fontWeight(value: string);
  75086. /**
  75087. * Gets or sets style
  75088. * @see http://doc.babylonjs.com/how_to/gui#styles
  75089. */
  75090. get style(): BABYLON.Nullable<Style>;
  75091. set style(value: BABYLON.Nullable<Style>);
  75092. /** @hidden */
  75093. get _isFontSizeInPercentage(): boolean;
  75094. /** Gets or sets font size in pixels */
  75095. get fontSizeInPixels(): number;
  75096. set fontSizeInPixels(value: number);
  75097. /** Gets or sets font size */
  75098. get fontSize(): string | number;
  75099. set fontSize(value: string | number);
  75100. /** Gets or sets foreground color */
  75101. get color(): string;
  75102. set color(value: string);
  75103. /** Gets or sets z index which is used to reorder controls on the z axis */
  75104. get zIndex(): number;
  75105. set zIndex(value: number);
  75106. /** Gets or sets a boolean indicating if the control can be rendered */
  75107. get notRenderable(): boolean;
  75108. set notRenderable(value: boolean);
  75109. /** Gets or sets a boolean indicating if the control is visible */
  75110. get isVisible(): boolean;
  75111. set isVisible(value: boolean);
  75112. /** Gets a boolean indicating that the control needs to update its rendering */
  75113. get isDirty(): boolean;
  75114. /**
  75115. * Gets the current linked mesh (or null if none)
  75116. */
  75117. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75118. /**
  75119. * Gets or sets a value indicating the padding to use on the left of the control
  75120. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75121. */
  75122. get paddingLeft(): string | number;
  75123. set paddingLeft(value: string | number);
  75124. /**
  75125. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75126. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75127. */
  75128. get paddingLeftInPixels(): number;
  75129. set paddingLeftInPixels(value: number);
  75130. /**
  75131. * Gets or sets a value indicating the padding to use on the right of the control
  75132. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75133. */
  75134. get paddingRight(): string | number;
  75135. set paddingRight(value: string | number);
  75136. /**
  75137. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75138. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75139. */
  75140. get paddingRightInPixels(): number;
  75141. set paddingRightInPixels(value: number);
  75142. /**
  75143. * Gets or sets a value indicating the padding to use on the top of the control
  75144. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75145. */
  75146. get paddingTop(): string | number;
  75147. set paddingTop(value: string | number);
  75148. /**
  75149. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75150. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75151. */
  75152. get paddingTopInPixels(): number;
  75153. set paddingTopInPixels(value: number);
  75154. /**
  75155. * Gets or sets a value indicating the padding to use on the bottom of the control
  75156. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75157. */
  75158. get paddingBottom(): string | number;
  75159. set paddingBottom(value: string | number);
  75160. /**
  75161. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75162. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75163. */
  75164. get paddingBottomInPixels(): number;
  75165. set paddingBottomInPixels(value: number);
  75166. /**
  75167. * Gets or sets a value indicating the left coordinate of the control
  75168. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75169. */
  75170. get left(): string | number;
  75171. set left(value: string | number);
  75172. /**
  75173. * Gets or sets a value indicating the left coordinate in pixels of the control
  75174. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75175. */
  75176. get leftInPixels(): number;
  75177. set leftInPixels(value: number);
  75178. /**
  75179. * Gets or sets a value indicating the top coordinate of the control
  75180. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75181. */
  75182. get top(): string | number;
  75183. set top(value: string | number);
  75184. /**
  75185. * Gets or sets a value indicating the top coordinate in pixels of the control
  75186. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75187. */
  75188. get topInPixels(): number;
  75189. set topInPixels(value: number);
  75190. /**
  75191. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75192. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75193. */
  75194. get linkOffsetX(): string | number;
  75195. set linkOffsetX(value: string | number);
  75196. /**
  75197. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75198. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75199. */
  75200. get linkOffsetXInPixels(): number;
  75201. set linkOffsetXInPixels(value: number);
  75202. /**
  75203. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75204. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75205. */
  75206. get linkOffsetY(): string | number;
  75207. set linkOffsetY(value: string | number);
  75208. /**
  75209. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75210. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75211. */
  75212. get linkOffsetYInPixels(): number;
  75213. set linkOffsetYInPixels(value: number);
  75214. /** Gets the center coordinate on X axis */
  75215. get centerX(): number;
  75216. /** Gets the center coordinate on Y axis */
  75217. get centerY(): number;
  75218. /** Gets or sets if control is Enabled*/
  75219. get isEnabled(): boolean;
  75220. set isEnabled(value: boolean);
  75221. /** Gets or sets background color of control if it's disabled*/
  75222. get disabledColor(): string;
  75223. set disabledColor(value: string);
  75224. /** Gets or sets front color of control if it's disabled*/
  75225. get disabledColorItem(): string;
  75226. set disabledColorItem(value: string);
  75227. /**
  75228. * Creates a new control
  75229. * @param name defines the name of the control
  75230. */
  75231. constructor(
  75232. /** defines the name of the control */
  75233. name?: string | undefined);
  75234. /** @hidden */
  75235. protected _getTypeName(): string;
  75236. /**
  75237. * Gets the first ascendant in the hierarchy of the given type
  75238. * @param className defines the required type
  75239. * @returns the ascendant or null if not found
  75240. */
  75241. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75242. /** @hidden */
  75243. _resetFontCache(): void;
  75244. /**
  75245. * Determines if a container is an ascendant of the current control
  75246. * @param container defines the container to look for
  75247. * @returns true if the container is one of the ascendant of the control
  75248. */
  75249. isAscendant(container: Control): boolean;
  75250. /**
  75251. * Gets coordinates in local control space
  75252. * @param globalCoordinates defines the coordinates to transform
  75253. * @returns the new coordinates in local space
  75254. */
  75255. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75256. /**
  75257. * Gets coordinates in local control space
  75258. * @param globalCoordinates defines the coordinates to transform
  75259. * @param result defines the target vector2 where to store the result
  75260. * @returns the current control
  75261. */
  75262. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75263. /**
  75264. * Gets coordinates in parent local control space
  75265. * @param globalCoordinates defines the coordinates to transform
  75266. * @returns the new coordinates in parent local space
  75267. */
  75268. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75269. /**
  75270. * Move the current control to a vector3 position projected onto the screen.
  75271. * @param position defines the target position
  75272. * @param scene defines the hosting scene
  75273. */
  75274. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75275. /**
  75276. * Will store all controls that have this control as ascendant in a given array
  75277. * @param results defines the array where to store the descendants
  75278. * @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
  75279. * @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
  75280. */
  75281. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75282. /**
  75283. * Will return all controls that have this control as ascendant
  75284. * @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
  75285. * @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
  75286. * @return all child controls
  75287. */
  75288. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75289. /**
  75290. * Link current control with a target mesh
  75291. * @param mesh defines the mesh to link with
  75292. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75293. */
  75294. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75295. /** @hidden */
  75296. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75297. /** @hidden */
  75298. _offsetLeft(offset: number): void;
  75299. /** @hidden */
  75300. _offsetTop(offset: number): void;
  75301. /** @hidden */
  75302. _markMatrixAsDirty(): void;
  75303. /** @hidden */
  75304. _flagDescendantsAsMatrixDirty(): void;
  75305. /** @hidden */
  75306. _intersectsRect(rect: Measure): boolean;
  75307. /** @hidden */
  75308. protected invalidateRect(): void;
  75309. /** @hidden */
  75310. _markAsDirty(force?: boolean): void;
  75311. /** @hidden */
  75312. _markAllAsDirty(): void;
  75313. /** @hidden */
  75314. _link(host: AdvancedDynamicTexture): void;
  75315. /** @hidden */
  75316. protected _transform(context?: CanvasRenderingContext2D): void;
  75317. /** @hidden */
  75318. _renderHighlight(context: CanvasRenderingContext2D): void;
  75319. /** @hidden */
  75320. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75321. /** @hidden */
  75322. protected _applyStates(context: CanvasRenderingContext2D): void;
  75323. /** @hidden */
  75324. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75325. /** @hidden */
  75326. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75327. protected _evaluateClippingState(parentMeasure: Measure): void;
  75328. /** @hidden */
  75329. _measure(): void;
  75330. /** @hidden */
  75331. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75332. /** @hidden */
  75333. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75334. /** @hidden */
  75335. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75336. /** @hidden */
  75337. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75338. private static _ClipMeasure;
  75339. private _tmpMeasureA;
  75340. private _clip;
  75341. /** @hidden */
  75342. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75343. /** @hidden */
  75344. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75345. /**
  75346. * Tests if a given coordinates belong to the current control
  75347. * @param x defines x coordinate to test
  75348. * @param y defines y coordinate to test
  75349. * @returns true if the coordinates are inside the control
  75350. */
  75351. contains(x: number, y: number): boolean;
  75352. /** @hidden */
  75353. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75354. /** @hidden */
  75355. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75356. /** @hidden */
  75357. _onPointerEnter(target: Control): boolean;
  75358. /** @hidden */
  75359. _onPointerOut(target: Control, force?: boolean): void;
  75360. /** @hidden */
  75361. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75362. /** @hidden */
  75363. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75364. /** @hidden */
  75365. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75366. /** @hidden */
  75367. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75368. /** @hidden */
  75369. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75370. private _prepareFont;
  75371. /** Releases associated resources */
  75372. dispose(): void;
  75373. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75374. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75375. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75376. private static _VERTICAL_ALIGNMENT_TOP;
  75377. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75378. private static _VERTICAL_ALIGNMENT_CENTER;
  75379. /** HORIZONTAL_ALIGNMENT_LEFT */
  75380. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75381. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75382. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75383. /** HORIZONTAL_ALIGNMENT_CENTER */
  75384. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75385. /** VERTICAL_ALIGNMENT_TOP */
  75386. static get VERTICAL_ALIGNMENT_TOP(): number;
  75387. /** VERTICAL_ALIGNMENT_BOTTOM */
  75388. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75389. /** VERTICAL_ALIGNMENT_CENTER */
  75390. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75391. private static _FontHeightSizes;
  75392. /** @hidden */
  75393. static _GetFontOffset(font: string): {
  75394. ascent: number;
  75395. height: number;
  75396. descent: number;
  75397. };
  75398. /**
  75399. * Creates a stack panel that can be used to render headers
  75400. * @param control defines the control to associate with the header
  75401. * @param text defines the text of the header
  75402. * @param size defines the size of the header
  75403. * @param options defines options used to configure the header
  75404. * @returns a new StackPanel
  75405. * @ignore
  75406. * @hidden
  75407. */
  75408. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75409. isHorizontal: boolean;
  75410. controlFirst: boolean;
  75411. }) => any;
  75412. /** @hidden */
  75413. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75414. }
  75415. }
  75416. declare module BABYLON.GUI {
  75417. /**
  75418. * Root class for 2D containers
  75419. * @see http://doc.babylonjs.com/how_to/gui#containers
  75420. */
  75421. export class Container extends Control {
  75422. name?: string | undefined;
  75423. /** @hidden */
  75424. _children: Control[];
  75425. /** @hidden */
  75426. protected _measureForChildren: Measure;
  75427. /** @hidden */
  75428. protected _background: string;
  75429. /** @hidden */
  75430. protected _adaptWidthToChildren: boolean;
  75431. /** @hidden */
  75432. protected _adaptHeightToChildren: boolean;
  75433. /**
  75434. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75435. */
  75436. logLayoutCycleErrors: boolean;
  75437. /**
  75438. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75439. */
  75440. maxLayoutCycle: number;
  75441. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75442. get adaptHeightToChildren(): boolean;
  75443. set adaptHeightToChildren(value: boolean);
  75444. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75445. get adaptWidthToChildren(): boolean;
  75446. set adaptWidthToChildren(value: boolean);
  75447. /** Gets or sets background color */
  75448. get background(): string;
  75449. set background(value: string);
  75450. /** Gets the list of children */
  75451. get children(): Control[];
  75452. /**
  75453. * Creates a new Container
  75454. * @param name defines the name of the container
  75455. */
  75456. constructor(name?: string | undefined);
  75457. protected _getTypeName(): string;
  75458. _flagDescendantsAsMatrixDirty(): void;
  75459. /**
  75460. * Gets a child using its name
  75461. * @param name defines the child name to look for
  75462. * @returns the child control if found
  75463. */
  75464. getChildByName(name: string): BABYLON.Nullable<Control>;
  75465. /**
  75466. * Gets a child using its type and its name
  75467. * @param name defines the child name to look for
  75468. * @param type defines the child type to look for
  75469. * @returns the child control if found
  75470. */
  75471. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75472. /**
  75473. * Search for a specific control in children
  75474. * @param control defines the control to look for
  75475. * @returns true if the control is in child list
  75476. */
  75477. containsControl(control: Control): boolean;
  75478. /**
  75479. * Adds a new control to the current container
  75480. * @param control defines the control to add
  75481. * @returns the current container
  75482. */
  75483. addControl(control: BABYLON.Nullable<Control>): Container;
  75484. /**
  75485. * Removes all controls from the current container
  75486. * @returns the current container
  75487. */
  75488. clearControls(): Container;
  75489. /**
  75490. * Removes a control from the current container
  75491. * @param control defines the control to remove
  75492. * @returns the current container
  75493. */
  75494. removeControl(control: Control): Container;
  75495. /** @hidden */
  75496. _reOrderControl(control: Control): void;
  75497. /** @hidden */
  75498. _offsetLeft(offset: number): void;
  75499. /** @hidden */
  75500. _offsetTop(offset: number): void;
  75501. /** @hidden */
  75502. _markAllAsDirty(): void;
  75503. /** @hidden */
  75504. protected _localDraw(context: CanvasRenderingContext2D): void;
  75505. /** @hidden */
  75506. _link(host: AdvancedDynamicTexture): void;
  75507. /** @hidden */
  75508. protected _beforeLayout(): void;
  75509. /** @hidden */
  75510. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75511. /** @hidden */
  75512. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75513. protected _postMeasure(): void;
  75514. /** @hidden */
  75515. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75516. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75517. /** @hidden */
  75518. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75519. /** @hidden */
  75520. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75521. /** Releases associated resources */
  75522. dispose(): void;
  75523. }
  75524. }
  75525. declare module BABYLON.GUI {
  75526. /** Class used to create rectangle container */
  75527. export class Rectangle extends Container {
  75528. name?: string | undefined;
  75529. private _thickness;
  75530. private _cornerRadius;
  75531. /** Gets or sets border thickness */
  75532. get thickness(): number;
  75533. set thickness(value: number);
  75534. /** Gets or sets the corner radius angle */
  75535. get cornerRadius(): number;
  75536. set cornerRadius(value: number);
  75537. /**
  75538. * Creates a new Rectangle
  75539. * @param name defines the control name
  75540. */
  75541. constructor(name?: string | undefined);
  75542. protected _getTypeName(): string;
  75543. protected _localDraw(context: CanvasRenderingContext2D): void;
  75544. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75545. private _drawRoundedRect;
  75546. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75547. }
  75548. }
  75549. declare module BABYLON.GUI {
  75550. /**
  75551. * Enum that determines the text-wrapping mode to use.
  75552. */
  75553. export enum TextWrapping {
  75554. /**
  75555. * Clip the text when it's larger than Control.width; this is the default mode.
  75556. */
  75557. Clip = 0,
  75558. /**
  75559. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75560. */
  75561. WordWrap = 1,
  75562. /**
  75563. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75564. */
  75565. Ellipsis = 2
  75566. }
  75567. /**
  75568. * Class used to create text block control
  75569. */
  75570. export class TextBlock extends Control {
  75571. /**
  75572. * Defines the name of the control
  75573. */
  75574. name?: string | undefined;
  75575. private _text;
  75576. private _textWrapping;
  75577. private _textHorizontalAlignment;
  75578. private _textVerticalAlignment;
  75579. private _lines;
  75580. private _resizeToFit;
  75581. private _lineSpacing;
  75582. private _outlineWidth;
  75583. private _outlineColor;
  75584. /**
  75585. * An event triggered after the text is changed
  75586. */
  75587. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75588. /**
  75589. * An event triggered after the text was broken up into lines
  75590. */
  75591. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75592. /**
  75593. * Function used to split a string into words. By default, a string is split at each space character found
  75594. */
  75595. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75596. /**
  75597. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75598. */
  75599. get lines(): any[];
  75600. /**
  75601. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75602. */
  75603. get resizeToFit(): boolean;
  75604. /**
  75605. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75606. */
  75607. set resizeToFit(value: boolean);
  75608. /**
  75609. * Gets or sets a boolean indicating if text must be wrapped
  75610. */
  75611. get textWrapping(): TextWrapping | boolean;
  75612. /**
  75613. * Gets or sets a boolean indicating if text must be wrapped
  75614. */
  75615. set textWrapping(value: TextWrapping | boolean);
  75616. /**
  75617. * Gets or sets text to display
  75618. */
  75619. get text(): string;
  75620. /**
  75621. * Gets or sets text to display
  75622. */
  75623. set text(value: string);
  75624. /**
  75625. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75626. */
  75627. get textHorizontalAlignment(): number;
  75628. /**
  75629. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75630. */
  75631. set textHorizontalAlignment(value: number);
  75632. /**
  75633. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75634. */
  75635. get textVerticalAlignment(): number;
  75636. /**
  75637. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75638. */
  75639. set textVerticalAlignment(value: number);
  75640. /**
  75641. * Gets or sets line spacing value
  75642. */
  75643. set lineSpacing(value: string | number);
  75644. /**
  75645. * Gets or sets line spacing value
  75646. */
  75647. get lineSpacing(): string | number;
  75648. /**
  75649. * Gets or sets outlineWidth of the text to display
  75650. */
  75651. get outlineWidth(): number;
  75652. /**
  75653. * Gets or sets outlineWidth of the text to display
  75654. */
  75655. set outlineWidth(value: number);
  75656. /**
  75657. * Gets or sets outlineColor of the text to display
  75658. */
  75659. get outlineColor(): string;
  75660. /**
  75661. * Gets or sets outlineColor of the text to display
  75662. */
  75663. set outlineColor(value: string);
  75664. /**
  75665. * Creates a new TextBlock object
  75666. * @param name defines the name of the control
  75667. * @param text defines the text to display (emptry string by default)
  75668. */
  75669. constructor(
  75670. /**
  75671. * Defines the name of the control
  75672. */
  75673. name?: string | undefined, text?: string);
  75674. protected _getTypeName(): string;
  75675. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75676. private _drawText;
  75677. /** @hidden */
  75678. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75679. protected _applyStates(context: CanvasRenderingContext2D): void;
  75680. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75681. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75682. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75683. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75684. protected _renderLines(context: CanvasRenderingContext2D): void;
  75685. /**
  75686. * Given a width constraint applied on the text block, find the expected height
  75687. * @returns expected height
  75688. */
  75689. computeExpectedHeight(): number;
  75690. dispose(): void;
  75691. }
  75692. }
  75693. declare module BABYLON.GUI {
  75694. /**
  75695. * Class used to create 2D images
  75696. */
  75697. export class Image extends Control {
  75698. name?: string | undefined;
  75699. private _workingCanvas;
  75700. private _domImage;
  75701. private _imageWidth;
  75702. private _imageHeight;
  75703. private _loaded;
  75704. private _stretch;
  75705. private _source;
  75706. private _autoScale;
  75707. private _sourceLeft;
  75708. private _sourceTop;
  75709. private _sourceWidth;
  75710. private _sourceHeight;
  75711. private _svgAttributesComputationCompleted;
  75712. private _isSVG;
  75713. private _cellWidth;
  75714. private _cellHeight;
  75715. private _cellId;
  75716. private _populateNinePatchSlicesFromImage;
  75717. private _sliceLeft;
  75718. private _sliceRight;
  75719. private _sliceTop;
  75720. private _sliceBottom;
  75721. private _detectPointerOnOpaqueOnly;
  75722. /**
  75723. * BABYLON.Observable notified when the content is loaded
  75724. */
  75725. onImageLoadedObservable: BABYLON.Observable<Image>;
  75726. /**
  75727. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75728. */
  75729. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75730. /**
  75731. * Gets a boolean indicating that the content is loaded
  75732. */
  75733. get isLoaded(): boolean;
  75734. /**
  75735. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75736. */
  75737. get populateNinePatchSlicesFromImage(): boolean;
  75738. set populateNinePatchSlicesFromImage(value: boolean);
  75739. /**
  75740. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75741. * Beware using this as this will comsume more memory as the image has to be stored twice
  75742. */
  75743. get detectPointerOnOpaqueOnly(): boolean;
  75744. set detectPointerOnOpaqueOnly(value: boolean);
  75745. /**
  75746. * Gets or sets the left value for slicing (9-patch)
  75747. */
  75748. get sliceLeft(): number;
  75749. set sliceLeft(value: number);
  75750. /**
  75751. * Gets or sets the right value for slicing (9-patch)
  75752. */
  75753. get sliceRight(): number;
  75754. set sliceRight(value: number);
  75755. /**
  75756. * Gets or sets the top value for slicing (9-patch)
  75757. */
  75758. get sliceTop(): number;
  75759. set sliceTop(value: number);
  75760. /**
  75761. * Gets or sets the bottom value for slicing (9-patch)
  75762. */
  75763. get sliceBottom(): number;
  75764. set sliceBottom(value: number);
  75765. /**
  75766. * Gets or sets the left coordinate in the source image
  75767. */
  75768. get sourceLeft(): number;
  75769. set sourceLeft(value: number);
  75770. /**
  75771. * Gets or sets the top coordinate in the source image
  75772. */
  75773. get sourceTop(): number;
  75774. set sourceTop(value: number);
  75775. /**
  75776. * Gets or sets the width to capture in the source image
  75777. */
  75778. get sourceWidth(): number;
  75779. set sourceWidth(value: number);
  75780. /**
  75781. * Gets or sets the height to capture in the source image
  75782. */
  75783. get sourceHeight(): number;
  75784. set sourceHeight(value: number);
  75785. /** Indicates if the format of the image is SVG */
  75786. get isSVG(): boolean;
  75787. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75788. get svgAttributesComputationCompleted(): boolean;
  75789. /**
  75790. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75791. * @see http://doc.babylonjs.com/how_to/gui#image
  75792. */
  75793. get autoScale(): boolean;
  75794. set autoScale(value: boolean);
  75795. /** Gets or sets the streching mode used by the image */
  75796. get stretch(): number;
  75797. set stretch(value: number);
  75798. /** @hidden */
  75799. _rotate90(n: number, preserveProperties?: boolean): Image;
  75800. private _handleRotationForSVGImage;
  75801. private _rotate90SourceProperties;
  75802. /**
  75803. * Gets or sets the internal DOM image used to render the control
  75804. */
  75805. set domImage(value: HTMLImageElement);
  75806. get domImage(): HTMLImageElement;
  75807. private _onImageLoaded;
  75808. private _extractNinePatchSliceDataFromImage;
  75809. /**
  75810. * Gets or sets image source url
  75811. */
  75812. set source(value: BABYLON.Nullable<string>);
  75813. /**
  75814. * Checks for svg document with icon id present
  75815. */
  75816. private _svgCheck;
  75817. /**
  75818. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75819. * given external svg file and icon id
  75820. */
  75821. private _getSVGAttribs;
  75822. /**
  75823. * Gets or sets the cell width to use when animation sheet is enabled
  75824. * @see http://doc.babylonjs.com/how_to/gui#image
  75825. */
  75826. get cellWidth(): number;
  75827. set cellWidth(value: number);
  75828. /**
  75829. * Gets or sets the cell height to use when animation sheet is enabled
  75830. * @see http://doc.babylonjs.com/how_to/gui#image
  75831. */
  75832. get cellHeight(): number;
  75833. set cellHeight(value: number);
  75834. /**
  75835. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75836. * @see http://doc.babylonjs.com/how_to/gui#image
  75837. */
  75838. get cellId(): number;
  75839. set cellId(value: number);
  75840. /**
  75841. * Creates a new Image
  75842. * @param name defines the control name
  75843. * @param url defines the image url
  75844. */
  75845. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75846. /**
  75847. * Tests if a given coordinates belong to the current control
  75848. * @param x defines x coordinate to test
  75849. * @param y defines y coordinate to test
  75850. * @returns true if the coordinates are inside the control
  75851. */
  75852. contains(x: number, y: number): boolean;
  75853. protected _getTypeName(): string;
  75854. /** Force the control to synchronize with its content */
  75855. synchronizeSizeWithContent(): void;
  75856. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75857. private _prepareWorkingCanvasForOpaqueDetection;
  75858. private _drawImage;
  75859. _draw(context: CanvasRenderingContext2D): void;
  75860. private _renderCornerPatch;
  75861. private _renderNinePatch;
  75862. dispose(): void;
  75863. /** STRETCH_NONE */
  75864. static readonly STRETCH_NONE: number;
  75865. /** STRETCH_FILL */
  75866. static readonly STRETCH_FILL: number;
  75867. /** STRETCH_UNIFORM */
  75868. static readonly STRETCH_UNIFORM: number;
  75869. /** STRETCH_EXTEND */
  75870. static readonly STRETCH_EXTEND: number;
  75871. /** NINE_PATCH */
  75872. static readonly STRETCH_NINE_PATCH: number;
  75873. }
  75874. }
  75875. declare module BABYLON.GUI {
  75876. /**
  75877. * Class used to create 2D buttons
  75878. */
  75879. export class Button extends Rectangle {
  75880. name?: string | undefined;
  75881. /**
  75882. * Function called to generate a pointer enter animation
  75883. */
  75884. pointerEnterAnimation: () => void;
  75885. /**
  75886. * Function called to generate a pointer out animation
  75887. */
  75888. pointerOutAnimation: () => void;
  75889. /**
  75890. * Function called to generate a pointer down animation
  75891. */
  75892. pointerDownAnimation: () => void;
  75893. /**
  75894. * Function called to generate a pointer up animation
  75895. */
  75896. pointerUpAnimation: () => void;
  75897. /**
  75898. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75899. */
  75900. delegatePickingToChildren: boolean;
  75901. private _image;
  75902. /**
  75903. * Returns the image part of the button (if any)
  75904. */
  75905. get image(): BABYLON.Nullable<Image>;
  75906. private _textBlock;
  75907. /**
  75908. * Returns the image part of the button (if any)
  75909. */
  75910. get textBlock(): BABYLON.Nullable<TextBlock>;
  75911. /**
  75912. * Creates a new Button
  75913. * @param name defines the name of the button
  75914. */
  75915. constructor(name?: string | undefined);
  75916. protected _getTypeName(): string;
  75917. /** @hidden */
  75918. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75919. /** @hidden */
  75920. _onPointerEnter(target: Control): boolean;
  75921. /** @hidden */
  75922. _onPointerOut(target: Control, force?: boolean): void;
  75923. /** @hidden */
  75924. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75925. /** @hidden */
  75926. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75927. /**
  75928. * Creates a new button made with an image and a text
  75929. * @param name defines the name of the button
  75930. * @param text defines the text of the button
  75931. * @param imageUrl defines the url of the image
  75932. * @returns a new Button
  75933. */
  75934. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75935. /**
  75936. * Creates a new button made with an image
  75937. * @param name defines the name of the button
  75938. * @param imageUrl defines the url of the image
  75939. * @returns a new Button
  75940. */
  75941. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75942. /**
  75943. * Creates a new button made with a text
  75944. * @param name defines the name of the button
  75945. * @param text defines the text of the button
  75946. * @returns a new Button
  75947. */
  75948. static CreateSimpleButton(name: string, text: string): Button;
  75949. /**
  75950. * Creates a new button made with an image and a centered text
  75951. * @param name defines the name of the button
  75952. * @param text defines the text of the button
  75953. * @param imageUrl defines the url of the image
  75954. * @returns a new Button
  75955. */
  75956. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75957. }
  75958. }
  75959. declare module BABYLON.GUI {
  75960. /**
  75961. * Class used to create a 2D stack panel container
  75962. */
  75963. export class StackPanel extends Container {
  75964. name?: string | undefined;
  75965. private _isVertical;
  75966. private _manualWidth;
  75967. private _manualHeight;
  75968. private _doNotTrackManualChanges;
  75969. /**
  75970. * Gets or sets a boolean indicating that layou warnings should be ignored
  75971. */
  75972. ignoreLayoutWarnings: boolean;
  75973. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75974. get isVertical(): boolean;
  75975. set isVertical(value: boolean);
  75976. /**
  75977. * Gets or sets panel width.
  75978. * This value should not be set when in horizontal mode as it will be computed automatically
  75979. */
  75980. set width(value: string | number);
  75981. get width(): string | number;
  75982. /**
  75983. * Gets or sets panel height.
  75984. * This value should not be set when in vertical mode as it will be computed automatically
  75985. */
  75986. set height(value: string | number);
  75987. get height(): string | number;
  75988. /**
  75989. * Creates a new StackPanel
  75990. * @param name defines control name
  75991. */
  75992. constructor(name?: string | undefined);
  75993. protected _getTypeName(): string;
  75994. /** @hidden */
  75995. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75996. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75997. protected _postMeasure(): void;
  75998. }
  75999. }
  76000. declare module BABYLON.GUI {
  76001. /**
  76002. * Class used to represent a 2D checkbox
  76003. */
  76004. export class Checkbox extends Control {
  76005. name?: string | undefined;
  76006. private _isChecked;
  76007. private _background;
  76008. private _checkSizeRatio;
  76009. private _thickness;
  76010. /** Gets or sets border thickness */
  76011. get thickness(): number;
  76012. set thickness(value: number);
  76013. /**
  76014. * BABYLON.Observable raised when isChecked property changes
  76015. */
  76016. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76017. /** Gets or sets a value indicating the ratio between overall size and check size */
  76018. get checkSizeRatio(): number;
  76019. set checkSizeRatio(value: number);
  76020. /** Gets or sets background color */
  76021. get background(): string;
  76022. set background(value: string);
  76023. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76024. get isChecked(): boolean;
  76025. set isChecked(value: boolean);
  76026. /**
  76027. * Creates a new CheckBox
  76028. * @param name defines the control name
  76029. */
  76030. constructor(name?: string | undefined);
  76031. protected _getTypeName(): string;
  76032. /** @hidden */
  76033. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76034. /** @hidden */
  76035. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76036. /**
  76037. * Utility function to easily create a checkbox with a header
  76038. * @param title defines the label to use for the header
  76039. * @param onValueChanged defines the callback to call when value changes
  76040. * @returns a StackPanel containing the checkbox and a textBlock
  76041. */
  76042. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76043. }
  76044. }
  76045. declare module BABYLON.GUI {
  76046. /**
  76047. * Class used to store key control properties
  76048. */
  76049. export class KeyPropertySet {
  76050. /** Width */
  76051. width?: string;
  76052. /** Height */
  76053. height?: string;
  76054. /** Left padding */
  76055. paddingLeft?: string;
  76056. /** Right padding */
  76057. paddingRight?: string;
  76058. /** Top padding */
  76059. paddingTop?: string;
  76060. /** Bottom padding */
  76061. paddingBottom?: string;
  76062. /** Foreground color */
  76063. color?: string;
  76064. /** Background color */
  76065. background?: string;
  76066. }
  76067. /**
  76068. * Class used to create virtual keyboard
  76069. */
  76070. export class VirtualKeyboard extends StackPanel {
  76071. /** BABYLON.Observable raised when a key is pressed */
  76072. onKeyPressObservable: BABYLON.Observable<string>;
  76073. /** Gets or sets default key button width */
  76074. defaultButtonWidth: string;
  76075. /** Gets or sets default key button height */
  76076. defaultButtonHeight: string;
  76077. /** Gets or sets default key button left padding */
  76078. defaultButtonPaddingLeft: string;
  76079. /** Gets or sets default key button right padding */
  76080. defaultButtonPaddingRight: string;
  76081. /** Gets or sets default key button top padding */
  76082. defaultButtonPaddingTop: string;
  76083. /** Gets or sets default key button bottom padding */
  76084. defaultButtonPaddingBottom: string;
  76085. /** Gets or sets default key button foreground color */
  76086. defaultButtonColor: string;
  76087. /** Gets or sets default key button background color */
  76088. defaultButtonBackground: string;
  76089. /** Gets or sets shift button foreground color */
  76090. shiftButtonColor: string;
  76091. /** Gets or sets shift button thickness*/
  76092. selectedShiftThickness: number;
  76093. /** Gets shift key state */
  76094. shiftState: number;
  76095. protected _getTypeName(): string;
  76096. private _createKey;
  76097. /**
  76098. * Adds a new row of keys
  76099. * @param keys defines the list of keys to add
  76100. * @param propertySets defines the associated property sets
  76101. */
  76102. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76103. /**
  76104. * Set the shift key to a specific state
  76105. * @param shiftState defines the new shift state
  76106. */
  76107. applyShiftState(shiftState: number): void;
  76108. private _currentlyConnectedInputText;
  76109. private _connectedInputTexts;
  76110. private _onKeyPressObserver;
  76111. /** Gets the input text control currently attached to the keyboard */
  76112. get connectedInputText(): BABYLON.Nullable<InputText>;
  76113. /**
  76114. * Connects the keyboard with an input text control
  76115. *
  76116. * @param input defines the target control
  76117. */
  76118. connect(input: InputText): void;
  76119. /**
  76120. * Disconnects the keyboard from connected InputText controls
  76121. *
  76122. * @param input optionally defines a target control, otherwise all are disconnected
  76123. */
  76124. disconnect(input?: InputText): void;
  76125. private _removeConnectedInputObservables;
  76126. /**
  76127. * Release all resources
  76128. */
  76129. dispose(): void;
  76130. /**
  76131. * Creates a new keyboard using a default layout
  76132. *
  76133. * @param name defines control name
  76134. * @returns a new VirtualKeyboard
  76135. */
  76136. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76137. }
  76138. }
  76139. declare module BABYLON.GUI {
  76140. /**
  76141. * Class used to create input text control
  76142. */
  76143. export class InputText extends Control implements IFocusableControl {
  76144. name?: string | undefined;
  76145. private _text;
  76146. private _placeholderText;
  76147. private _background;
  76148. private _focusedBackground;
  76149. private _focusedColor;
  76150. private _placeholderColor;
  76151. private _thickness;
  76152. private _margin;
  76153. private _autoStretchWidth;
  76154. private _maxWidth;
  76155. private _isFocused;
  76156. private _blinkTimeout;
  76157. private _blinkIsEven;
  76158. private _cursorOffset;
  76159. private _scrollLeft;
  76160. private _textWidth;
  76161. private _clickedCoordinate;
  76162. private _deadKey;
  76163. private _addKey;
  76164. private _currentKey;
  76165. private _isTextHighlightOn;
  76166. private _textHighlightColor;
  76167. private _highligherOpacity;
  76168. private _highlightedText;
  76169. private _startHighlightIndex;
  76170. private _endHighlightIndex;
  76171. private _cursorIndex;
  76172. private _onFocusSelectAll;
  76173. private _isPointerDown;
  76174. private _onClipboardObserver;
  76175. private _onPointerDblTapObserver;
  76176. /** @hidden */
  76177. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76178. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76179. promptMessage: string;
  76180. /** Force disable prompt on mobile device */
  76181. disableMobilePrompt: boolean;
  76182. /** BABYLON.Observable raised when the text changes */
  76183. onTextChangedObservable: BABYLON.Observable<InputText>;
  76184. /** BABYLON.Observable raised just before an entered character is to be added */
  76185. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76186. /** BABYLON.Observable raised when the control gets the focus */
  76187. onFocusObservable: BABYLON.Observable<InputText>;
  76188. /** BABYLON.Observable raised when the control loses the focus */
  76189. onBlurObservable: BABYLON.Observable<InputText>;
  76190. /**Observable raised when the text is highlighted */
  76191. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76192. /**Observable raised when copy event is triggered */
  76193. onTextCopyObservable: BABYLON.Observable<InputText>;
  76194. /** BABYLON.Observable raised when cut event is triggered */
  76195. onTextCutObservable: BABYLON.Observable<InputText>;
  76196. /** BABYLON.Observable raised when paste event is triggered */
  76197. onTextPasteObservable: BABYLON.Observable<InputText>;
  76198. /** BABYLON.Observable raised when a key event was processed */
  76199. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76200. /** Gets or sets the maximum width allowed by the control */
  76201. get maxWidth(): string | number;
  76202. /** Gets the maximum width allowed by the control in pixels */
  76203. get maxWidthInPixels(): number;
  76204. set maxWidth(value: string | number);
  76205. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76206. get highligherOpacity(): number;
  76207. set highligherOpacity(value: number);
  76208. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76209. get onFocusSelectAll(): boolean;
  76210. set onFocusSelectAll(value: boolean);
  76211. /** Gets or sets the text hightlight color */
  76212. get textHighlightColor(): string;
  76213. set textHighlightColor(value: string);
  76214. /** Gets or sets control margin */
  76215. get margin(): string;
  76216. /** Gets control margin in pixels */
  76217. get marginInPixels(): number;
  76218. set margin(value: string);
  76219. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76220. get autoStretchWidth(): boolean;
  76221. set autoStretchWidth(value: boolean);
  76222. /** Gets or sets border thickness */
  76223. get thickness(): number;
  76224. set thickness(value: number);
  76225. /** Gets or sets the background color when focused */
  76226. get focusedBackground(): string;
  76227. set focusedBackground(value: string);
  76228. /** Gets or sets the background color when focused */
  76229. get focusedColor(): string;
  76230. set focusedColor(value: string);
  76231. /** Gets or sets the background color */
  76232. get background(): string;
  76233. set background(value: string);
  76234. /** Gets or sets the placeholder color */
  76235. get placeholderColor(): string;
  76236. set placeholderColor(value: string);
  76237. /** Gets or sets the text displayed when the control is empty */
  76238. get placeholderText(): string;
  76239. set placeholderText(value: string);
  76240. /** Gets or sets the dead key flag */
  76241. get deadKey(): boolean;
  76242. set deadKey(flag: boolean);
  76243. /** Gets or sets the highlight text */
  76244. get highlightedText(): string;
  76245. set highlightedText(text: string);
  76246. /** Gets or sets if the current key should be added */
  76247. get addKey(): boolean;
  76248. set addKey(flag: boolean);
  76249. /** Gets or sets the value of the current key being entered */
  76250. get currentKey(): string;
  76251. set currentKey(key: string);
  76252. /** Gets or sets the text displayed in the control */
  76253. get text(): string;
  76254. set text(value: string);
  76255. /** Gets or sets control width */
  76256. get width(): string | number;
  76257. set width(value: string | number);
  76258. /**
  76259. * Creates a new InputText
  76260. * @param name defines the control name
  76261. * @param text defines the text of the control
  76262. */
  76263. constructor(name?: string | undefined, text?: string);
  76264. /** @hidden */
  76265. onBlur(): void;
  76266. /** @hidden */
  76267. onFocus(): void;
  76268. protected _getTypeName(): string;
  76269. /**
  76270. * Function called to get the list of controls that should not steal the focus from this control
  76271. * @returns an array of controls
  76272. */
  76273. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76274. /** @hidden */
  76275. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76276. /** @hidden */
  76277. private _updateValueFromCursorIndex;
  76278. /** @hidden */
  76279. private _processDblClick;
  76280. /** @hidden */
  76281. private _selectAllText;
  76282. /**
  76283. * Handles the keyboard event
  76284. * @param evt Defines the KeyboardEvent
  76285. */
  76286. processKeyboard(evt: KeyboardEvent): void;
  76287. /** @hidden */
  76288. private _onCopyText;
  76289. /** @hidden */
  76290. private _onCutText;
  76291. /** @hidden */
  76292. private _onPasteText;
  76293. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76294. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76295. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76296. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76297. protected _beforeRenderText(text: string): string;
  76298. dispose(): void;
  76299. }
  76300. }
  76301. declare module BABYLON.GUI {
  76302. /**
  76303. * Class used to create a 2D grid container
  76304. */
  76305. export class Grid extends Container {
  76306. name?: string | undefined;
  76307. private _rowDefinitions;
  76308. private _columnDefinitions;
  76309. private _cells;
  76310. private _childControls;
  76311. /**
  76312. * Gets the number of columns
  76313. */
  76314. get columnCount(): number;
  76315. /**
  76316. * Gets the number of rows
  76317. */
  76318. get rowCount(): number;
  76319. /** Gets the list of children */
  76320. get children(): Control[];
  76321. /** Gets the list of cells (e.g. the containers) */
  76322. get cells(): {
  76323. [key: string]: Container;
  76324. };
  76325. /**
  76326. * Gets the definition of a specific row
  76327. * @param index defines the index of the row
  76328. * @returns the row definition
  76329. */
  76330. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76331. /**
  76332. * Gets the definition of a specific column
  76333. * @param index defines the index of the column
  76334. * @returns the column definition
  76335. */
  76336. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76337. /**
  76338. * Adds a new row to the grid
  76339. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76340. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76341. * @returns the current grid
  76342. */
  76343. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76344. /**
  76345. * Adds a new column to the grid
  76346. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76347. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76348. * @returns the current grid
  76349. */
  76350. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76351. /**
  76352. * Update a row definition
  76353. * @param index defines the index of the row to update
  76354. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76355. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76356. * @returns the current grid
  76357. */
  76358. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76359. /**
  76360. * Update a column definition
  76361. * @param index defines the index of the column to update
  76362. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76363. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76364. * @returns the current grid
  76365. */
  76366. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76367. /**
  76368. * Gets the list of children stored in a specific cell
  76369. * @param row defines the row to check
  76370. * @param column defines the column to check
  76371. * @returns the list of controls
  76372. */
  76373. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76374. /**
  76375. * Gets a string representing the child cell info (row x column)
  76376. * @param child defines the control to get info from
  76377. * @returns a string containing the child cell info (row x column)
  76378. */
  76379. getChildCellInfo(child: Control): string;
  76380. private _removeCell;
  76381. private _offsetCell;
  76382. /**
  76383. * Remove a column definition at specified index
  76384. * @param index defines the index of the column to remove
  76385. * @returns the current grid
  76386. */
  76387. removeColumnDefinition(index: number): Grid;
  76388. /**
  76389. * Remove a row definition at specified index
  76390. * @param index defines the index of the row to remove
  76391. * @returns the current grid
  76392. */
  76393. removeRowDefinition(index: number): Grid;
  76394. /**
  76395. * Adds a new control to the current grid
  76396. * @param control defines the control to add
  76397. * @param row defines the row where to add the control (0 by default)
  76398. * @param column defines the column where to add the control (0 by default)
  76399. * @returns the current grid
  76400. */
  76401. addControl(control: Control, row?: number, column?: number): Grid;
  76402. /**
  76403. * Removes a control from the current container
  76404. * @param control defines the control to remove
  76405. * @returns the current container
  76406. */
  76407. removeControl(control: Control): Container;
  76408. /**
  76409. * Creates a new Grid
  76410. * @param name defines control name
  76411. */
  76412. constructor(name?: string | undefined);
  76413. protected _getTypeName(): string;
  76414. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76415. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76416. _flagDescendantsAsMatrixDirty(): void;
  76417. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76418. /** Releases associated resources */
  76419. dispose(): void;
  76420. }
  76421. }
  76422. declare module BABYLON.GUI {
  76423. /** Class used to create color pickers */
  76424. export class ColorPicker extends Control {
  76425. name?: string | undefined;
  76426. private static _Epsilon;
  76427. private _colorWheelCanvas;
  76428. private _value;
  76429. private _tmpColor;
  76430. private _pointerStartedOnSquare;
  76431. private _pointerStartedOnWheel;
  76432. private _squareLeft;
  76433. private _squareTop;
  76434. private _squareSize;
  76435. private _h;
  76436. private _s;
  76437. private _v;
  76438. private _lastPointerDownID;
  76439. /**
  76440. * BABYLON.Observable raised when the value changes
  76441. */
  76442. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76443. /** Gets or sets the color of the color picker */
  76444. get value(): BABYLON.Color3;
  76445. set value(value: BABYLON.Color3);
  76446. /**
  76447. * Gets or sets control width
  76448. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76449. */
  76450. get width(): string | number;
  76451. set width(value: string | number);
  76452. /**
  76453. * Gets or sets control height
  76454. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76455. */
  76456. get height(): string | number;
  76457. /** Gets or sets control height */
  76458. set height(value: string | number);
  76459. /** Gets or sets control size */
  76460. get size(): string | number;
  76461. set size(value: string | number);
  76462. /**
  76463. * Creates a new ColorPicker
  76464. * @param name defines the control name
  76465. */
  76466. constructor(name?: string | undefined);
  76467. protected _getTypeName(): string;
  76468. /** @hidden */
  76469. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76470. private _updateSquareProps;
  76471. private _drawGradientSquare;
  76472. private _drawCircle;
  76473. private _createColorWheelCanvas;
  76474. /** @hidden */
  76475. _draw(context: CanvasRenderingContext2D): void;
  76476. private _pointerIsDown;
  76477. private _updateValueFromPointer;
  76478. private _isPointOnSquare;
  76479. private _isPointOnWheel;
  76480. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76481. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76482. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76483. /**
  76484. * This function expands the color picker by creating a color picker dialog with manual
  76485. * color value input and the ability to save colors into an array to be used later in
  76486. * subsequent launches of the dialogue.
  76487. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76488. * @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.
  76489. * @returns picked color as a hex string and the saved colors array as hex strings.
  76490. */
  76491. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76492. pickerWidth?: string;
  76493. pickerHeight?: string;
  76494. headerHeight?: string;
  76495. lastColor?: string;
  76496. swatchLimit?: number;
  76497. numSwatchesPerLine?: number;
  76498. savedColors?: Array<string>;
  76499. }): Promise<{
  76500. savedColors?: string[];
  76501. pickedColor: string;
  76502. }>;
  76503. }
  76504. }
  76505. declare module BABYLON.GUI {
  76506. /** Class used to create 2D ellipse containers */
  76507. export class Ellipse extends Container {
  76508. name?: string | undefined;
  76509. private _thickness;
  76510. /** Gets or sets border thickness */
  76511. get thickness(): number;
  76512. set thickness(value: number);
  76513. /**
  76514. * Creates a new Ellipse
  76515. * @param name defines the control name
  76516. */
  76517. constructor(name?: string | undefined);
  76518. protected _getTypeName(): string;
  76519. protected _localDraw(context: CanvasRenderingContext2D): void;
  76520. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76521. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76522. }
  76523. }
  76524. declare module BABYLON.GUI {
  76525. /**
  76526. * Class used to create a password control
  76527. */
  76528. export class InputPassword extends InputText {
  76529. protected _beforeRenderText(text: string): string;
  76530. }
  76531. }
  76532. declare module BABYLON.GUI {
  76533. /** Class used to render 2D lines */
  76534. export class Line extends Control {
  76535. name?: string | undefined;
  76536. private _lineWidth;
  76537. private _x1;
  76538. private _y1;
  76539. private _x2;
  76540. private _y2;
  76541. private _dash;
  76542. private _connectedControl;
  76543. private _connectedControlDirtyObserver;
  76544. /** Gets or sets the dash pattern */
  76545. get dash(): Array<number>;
  76546. set dash(value: Array<number>);
  76547. /** Gets or sets the control connected with the line end */
  76548. get connectedControl(): Control;
  76549. set connectedControl(value: Control);
  76550. /** Gets or sets start coordinates on X axis */
  76551. get x1(): string | number;
  76552. set x1(value: string | number);
  76553. /** Gets or sets start coordinates on Y axis */
  76554. get y1(): string | number;
  76555. set y1(value: string | number);
  76556. /** Gets or sets end coordinates on X axis */
  76557. get x2(): string | number;
  76558. set x2(value: string | number);
  76559. /** Gets or sets end coordinates on Y axis */
  76560. get y2(): string | number;
  76561. set y2(value: string | number);
  76562. /** Gets or sets line width */
  76563. get lineWidth(): number;
  76564. set lineWidth(value: number);
  76565. /** Gets or sets horizontal alignment */
  76566. set horizontalAlignment(value: number);
  76567. /** Gets or sets vertical alignment */
  76568. set verticalAlignment(value: number);
  76569. private get _effectiveX2();
  76570. private get _effectiveY2();
  76571. /**
  76572. * Creates a new Line
  76573. * @param name defines the control name
  76574. */
  76575. constructor(name?: string | undefined);
  76576. protected _getTypeName(): string;
  76577. _draw(context: CanvasRenderingContext2D): void;
  76578. _measure(): void;
  76579. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76580. /**
  76581. * Move one end of the line given 3D cartesian coordinates.
  76582. * @param position Targeted world position
  76583. * @param scene BABYLON.Scene
  76584. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76585. */
  76586. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76587. /**
  76588. * Move one end of the line to a position in screen absolute space.
  76589. * @param projectedPosition Position in screen absolute space (X, Y)
  76590. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76591. */
  76592. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76593. }
  76594. }
  76595. declare module BABYLON.GUI {
  76596. /**
  76597. * Class used to store a point for a MultiLine object.
  76598. * The point can be pure 2D coordinates, a mesh or a control
  76599. */
  76600. export class MultiLinePoint {
  76601. private _multiLine;
  76602. private _x;
  76603. private _y;
  76604. private _control;
  76605. private _mesh;
  76606. private _controlObserver;
  76607. private _meshObserver;
  76608. /** @hidden */
  76609. _point: BABYLON.Vector2;
  76610. /**
  76611. * Creates a new MultiLinePoint
  76612. * @param multiLine defines the source MultiLine object
  76613. */
  76614. constructor(multiLine: MultiLine);
  76615. /** Gets or sets x coordinate */
  76616. get x(): string | number;
  76617. set x(value: string | number);
  76618. /** Gets or sets y coordinate */
  76619. get y(): string | number;
  76620. set y(value: string | number);
  76621. /** Gets or sets the control associated with this point */
  76622. get control(): BABYLON.Nullable<Control>;
  76623. set control(value: BABYLON.Nullable<Control>);
  76624. /** Gets or sets the mesh associated with this point */
  76625. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76626. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76627. /** Resets links */
  76628. resetLinks(): void;
  76629. /**
  76630. * Gets a translation vector
  76631. * @returns the translation vector
  76632. */
  76633. translate(): BABYLON.Vector2;
  76634. private _translatePoint;
  76635. /** Release associated resources */
  76636. dispose(): void;
  76637. }
  76638. }
  76639. declare module BABYLON.GUI {
  76640. /**
  76641. * Class used to create multi line control
  76642. */
  76643. export class MultiLine extends Control {
  76644. name?: string | undefined;
  76645. private _lineWidth;
  76646. private _dash;
  76647. private _points;
  76648. private _minX;
  76649. private _minY;
  76650. private _maxX;
  76651. private _maxY;
  76652. /**
  76653. * Creates a new MultiLine
  76654. * @param name defines the control name
  76655. */
  76656. constructor(name?: string | undefined);
  76657. /** Gets or sets dash pattern */
  76658. get dash(): Array<number>;
  76659. set dash(value: Array<number>);
  76660. /**
  76661. * Gets point stored at specified index
  76662. * @param index defines the index to look for
  76663. * @returns the requested point if found
  76664. */
  76665. getAt(index: number): MultiLinePoint;
  76666. /** Function called when a point is updated */
  76667. onPointUpdate: () => void;
  76668. /**
  76669. * Adds new points to the point collection
  76670. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76671. * @returns the list of created MultiLinePoint
  76672. */
  76673. add(...items: (AbstractMesh | Control | {
  76674. x: string | number;
  76675. y: string | number;
  76676. })[]): MultiLinePoint[];
  76677. /**
  76678. * Adds a new point to the point collection
  76679. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76680. * @returns the created MultiLinePoint
  76681. */
  76682. push(item?: (AbstractMesh | Control | {
  76683. x: string | number;
  76684. y: string | number;
  76685. })): MultiLinePoint;
  76686. /**
  76687. * Remove a specific value or point from the active point collection
  76688. * @param value defines the value or point to remove
  76689. */
  76690. remove(value: number | MultiLinePoint): void;
  76691. /**
  76692. * Resets this object to initial state (no point)
  76693. */
  76694. reset(): void;
  76695. /**
  76696. * Resets all links
  76697. */
  76698. resetLinks(): void;
  76699. /** Gets or sets line width */
  76700. get lineWidth(): number;
  76701. set lineWidth(value: number);
  76702. set horizontalAlignment(value: number);
  76703. set verticalAlignment(value: number);
  76704. protected _getTypeName(): string;
  76705. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76706. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76707. _measure(): void;
  76708. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76709. dispose(): void;
  76710. }
  76711. }
  76712. declare module BABYLON.GUI {
  76713. /**
  76714. * Class used to create radio button controls
  76715. */
  76716. export class RadioButton extends Control {
  76717. name?: string | undefined;
  76718. private _isChecked;
  76719. private _background;
  76720. private _checkSizeRatio;
  76721. private _thickness;
  76722. /** Gets or sets border thickness */
  76723. get thickness(): number;
  76724. set thickness(value: number);
  76725. /** Gets or sets group name */
  76726. group: string;
  76727. /** BABYLON.Observable raised when isChecked is changed */
  76728. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76729. /** Gets or sets a value indicating the ratio between overall size and check size */
  76730. get checkSizeRatio(): number;
  76731. set checkSizeRatio(value: number);
  76732. /** Gets or sets background color */
  76733. get background(): string;
  76734. set background(value: string);
  76735. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76736. get isChecked(): boolean;
  76737. set isChecked(value: boolean);
  76738. /**
  76739. * Creates a new RadioButton
  76740. * @param name defines the control name
  76741. */
  76742. constructor(name?: string | undefined);
  76743. protected _getTypeName(): string;
  76744. _draw(context: CanvasRenderingContext2D): void;
  76745. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76746. /**
  76747. * Utility function to easily create a radio button with a header
  76748. * @param title defines the label to use for the header
  76749. * @param group defines the group to use for the radio button
  76750. * @param isChecked defines the initial state of the radio button
  76751. * @param onValueChanged defines the callback to call when value changes
  76752. * @returns a StackPanel containing the radio button and a textBlock
  76753. */
  76754. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76755. }
  76756. }
  76757. declare module BABYLON.GUI {
  76758. /**
  76759. * Class used to create slider controls
  76760. */
  76761. export class BaseSlider extends Control {
  76762. name?: string | undefined;
  76763. protected _thumbWidth: ValueAndUnit;
  76764. private _minimum;
  76765. private _maximum;
  76766. private _value;
  76767. private _isVertical;
  76768. protected _barOffset: ValueAndUnit;
  76769. private _isThumbClamped;
  76770. protected _displayThumb: boolean;
  76771. private _step;
  76772. private _lastPointerDownID;
  76773. protected _effectiveBarOffset: number;
  76774. protected _renderLeft: number;
  76775. protected _renderTop: number;
  76776. protected _renderWidth: number;
  76777. protected _renderHeight: number;
  76778. protected _backgroundBoxLength: number;
  76779. protected _backgroundBoxThickness: number;
  76780. protected _effectiveThumbThickness: number;
  76781. /** BABYLON.Observable raised when the sldier value changes */
  76782. onValueChangedObservable: BABYLON.Observable<number>;
  76783. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76784. get displayThumb(): boolean;
  76785. set displayThumb(value: boolean);
  76786. /** Gets or sets a step to apply to values (0 by default) */
  76787. get step(): number;
  76788. set step(value: number);
  76789. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76790. get barOffset(): string | number;
  76791. /** Gets main bar offset in pixels*/
  76792. get barOffsetInPixels(): number;
  76793. set barOffset(value: string | number);
  76794. /** Gets or sets thumb width */
  76795. get thumbWidth(): string | number;
  76796. /** Gets thumb width in pixels */
  76797. get thumbWidthInPixels(): number;
  76798. set thumbWidth(value: string | number);
  76799. /** Gets or sets minimum value */
  76800. get minimum(): number;
  76801. set minimum(value: number);
  76802. /** Gets or sets maximum value */
  76803. get maximum(): number;
  76804. set maximum(value: number);
  76805. /** Gets or sets current value */
  76806. get value(): number;
  76807. set value(value: number);
  76808. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76809. get isVertical(): boolean;
  76810. set isVertical(value: boolean);
  76811. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76812. get isThumbClamped(): boolean;
  76813. set isThumbClamped(value: boolean);
  76814. /**
  76815. * Creates a new BaseSlider
  76816. * @param name defines the control name
  76817. */
  76818. constructor(name?: string | undefined);
  76819. protected _getTypeName(): string;
  76820. protected _getThumbPosition(): number;
  76821. protected _getThumbThickness(type: string): number;
  76822. protected _prepareRenderingData(type: string): void;
  76823. private _pointerIsDown;
  76824. /** @hidden */
  76825. protected _updateValueFromPointer(x: number, y: number): void;
  76826. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76827. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76828. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76829. }
  76830. }
  76831. declare module BABYLON.GUI {
  76832. /**
  76833. * Class used to create slider controls
  76834. */
  76835. export class Slider extends BaseSlider {
  76836. name?: string | undefined;
  76837. private _background;
  76838. private _borderColor;
  76839. private _isThumbCircle;
  76840. protected _displayValueBar: boolean;
  76841. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76842. get displayValueBar(): boolean;
  76843. set displayValueBar(value: boolean);
  76844. /** Gets or sets border color */
  76845. get borderColor(): string;
  76846. set borderColor(value: string);
  76847. /** Gets or sets background color */
  76848. get background(): string;
  76849. set background(value: string);
  76850. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76851. get isThumbCircle(): boolean;
  76852. set isThumbCircle(value: boolean);
  76853. /**
  76854. * Creates a new Slider
  76855. * @param name defines the control name
  76856. */
  76857. constructor(name?: string | undefined);
  76858. protected _getTypeName(): string;
  76859. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76860. }
  76861. }
  76862. declare module BABYLON.GUI {
  76863. /** Class used to create a RadioGroup
  76864. * which contains groups of radio buttons
  76865. */
  76866. export class SelectorGroup {
  76867. /** name of SelectorGroup */
  76868. name: string;
  76869. private _groupPanel;
  76870. private _selectors;
  76871. private _groupHeader;
  76872. /**
  76873. * Creates a new SelectorGroup
  76874. * @param name of group, used as a group heading
  76875. */
  76876. constructor(
  76877. /** name of SelectorGroup */
  76878. name: string);
  76879. /** Gets the groupPanel of the SelectorGroup */
  76880. get groupPanel(): StackPanel;
  76881. /** Gets the selectors array */
  76882. get selectors(): StackPanel[];
  76883. /** Gets and sets the group header */
  76884. get header(): string;
  76885. set header(label: string);
  76886. /** @hidden */
  76887. private _addGroupHeader;
  76888. /** @hidden*/
  76889. _getSelector(selectorNb: number): StackPanel | undefined;
  76890. /** Removes the selector at the given position
  76891. * @param selectorNb the position of the selector within the group
  76892. */
  76893. removeSelector(selectorNb: number): void;
  76894. }
  76895. /** Class used to create a CheckboxGroup
  76896. * which contains groups of checkbox buttons
  76897. */
  76898. export class CheckboxGroup extends SelectorGroup {
  76899. /** Adds a checkbox as a control
  76900. * @param text is the label for the selector
  76901. * @param func is the function called when the Selector is checked
  76902. * @param checked is true when Selector is checked
  76903. */
  76904. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76905. /** @hidden */
  76906. _setSelectorLabel(selectorNb: number, label: string): void;
  76907. /** @hidden */
  76908. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76909. /** @hidden */
  76910. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76911. /** @hidden */
  76912. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76913. }
  76914. /** Class used to create a RadioGroup
  76915. * which contains groups of radio buttons
  76916. */
  76917. export class RadioGroup extends SelectorGroup {
  76918. private _selectNb;
  76919. /** Adds a radio button as a control
  76920. * @param label is the label for the selector
  76921. * @param func is the function called when the Selector is checked
  76922. * @param checked is true when Selector is checked
  76923. */
  76924. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76925. /** @hidden */
  76926. _setSelectorLabel(selectorNb: number, label: string): void;
  76927. /** @hidden */
  76928. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76929. /** @hidden */
  76930. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76931. /** @hidden */
  76932. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76933. }
  76934. /** Class used to create a SliderGroup
  76935. * which contains groups of slider buttons
  76936. */
  76937. export class SliderGroup extends SelectorGroup {
  76938. /**
  76939. * Adds a slider to the SelectorGroup
  76940. * @param label is the label for the SliderBar
  76941. * @param func is the function called when the Slider moves
  76942. * @param unit is a string describing the units used, eg degrees or metres
  76943. * @param min is the minimum value for the Slider
  76944. * @param max is the maximum value for the Slider
  76945. * @param value is the start value for the Slider between min and max
  76946. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76947. */
  76948. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76949. /** @hidden */
  76950. _setSelectorLabel(selectorNb: number, label: string): void;
  76951. /** @hidden */
  76952. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76953. /** @hidden */
  76954. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76955. /** @hidden */
  76956. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76957. }
  76958. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76959. * @see http://doc.babylonjs.com/how_to/selector
  76960. */
  76961. export class SelectionPanel extends Rectangle {
  76962. /** name of SelectionPanel */
  76963. name: string;
  76964. /** an array of SelectionGroups */
  76965. groups: SelectorGroup[];
  76966. private _panel;
  76967. private _buttonColor;
  76968. private _buttonBackground;
  76969. private _headerColor;
  76970. private _barColor;
  76971. private _barHeight;
  76972. private _spacerHeight;
  76973. private _labelColor;
  76974. private _groups;
  76975. private _bars;
  76976. /**
  76977. * Creates a new SelectionPanel
  76978. * @param name of SelectionPanel
  76979. * @param groups is an array of SelectionGroups
  76980. */
  76981. constructor(
  76982. /** name of SelectionPanel */
  76983. name: string,
  76984. /** an array of SelectionGroups */
  76985. groups?: SelectorGroup[]);
  76986. protected _getTypeName(): string;
  76987. /** Gets or sets the headerColor */
  76988. get headerColor(): string;
  76989. set headerColor(color: string);
  76990. private _setHeaderColor;
  76991. /** Gets or sets the button color */
  76992. get buttonColor(): string;
  76993. set buttonColor(color: string);
  76994. private _setbuttonColor;
  76995. /** Gets or sets the label color */
  76996. get labelColor(): string;
  76997. set labelColor(color: string);
  76998. private _setLabelColor;
  76999. /** Gets or sets the button background */
  77000. get buttonBackground(): string;
  77001. set buttonBackground(color: string);
  77002. private _setButtonBackground;
  77003. /** Gets or sets the color of separator bar */
  77004. get barColor(): string;
  77005. set barColor(color: string);
  77006. private _setBarColor;
  77007. /** Gets or sets the height of separator bar */
  77008. get barHeight(): string;
  77009. set barHeight(value: string);
  77010. private _setBarHeight;
  77011. /** Gets or sets the height of spacers*/
  77012. get spacerHeight(): string;
  77013. set spacerHeight(value: string);
  77014. private _setSpacerHeight;
  77015. /** Adds a bar between groups */
  77016. private _addSpacer;
  77017. /** Add a group to the selection panel
  77018. * @param group is the selector group to add
  77019. */
  77020. addGroup(group: SelectorGroup): void;
  77021. /** Remove the group from the given position
  77022. * @param groupNb is the position of the group in the list
  77023. */
  77024. removeGroup(groupNb: number): void;
  77025. /** Change a group header label
  77026. * @param label is the new group header label
  77027. * @param groupNb is the number of the group to relabel
  77028. * */
  77029. setHeaderName(label: string, groupNb: number): void;
  77030. /** Change selector label to the one given
  77031. * @param label is the new selector label
  77032. * @param groupNb is the number of the groupcontaining the selector
  77033. * @param selectorNb is the number of the selector within a group to relabel
  77034. * */
  77035. relabel(label: string, groupNb: number, selectorNb: number): void;
  77036. /** For a given group position remove the selector at the given position
  77037. * @param groupNb is the number of the group to remove the selector from
  77038. * @param selectorNb is the number of the selector within the group
  77039. */
  77040. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77041. /** For a given group position of correct type add a checkbox button
  77042. * @param groupNb is the number of the group to remove the selector from
  77043. * @param label is the label for the selector
  77044. * @param func is the function called when the Selector is checked
  77045. * @param checked is true when Selector is checked
  77046. */
  77047. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77048. /** For a given group position of correct type add a radio button
  77049. * @param groupNb is the number of the group to remove the selector from
  77050. * @param label is the label for the selector
  77051. * @param func is the function called when the Selector is checked
  77052. * @param checked is true when Selector is checked
  77053. */
  77054. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77055. /**
  77056. * For a given slider group add a slider
  77057. * @param groupNb is the number of the group to add the slider to
  77058. * @param label is the label for the Slider
  77059. * @param func is the function called when the Slider moves
  77060. * @param unit is a string describing the units used, eg degrees or metres
  77061. * @param min is the minimum value for the Slider
  77062. * @param max is the maximum value for the Slider
  77063. * @param value is the start value for the Slider between min and max
  77064. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77065. */
  77066. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77067. }
  77068. }
  77069. declare module BABYLON.GUI {
  77070. /**
  77071. * Class used to hold a the container for ScrollViewer
  77072. * @hidden
  77073. */
  77074. export class _ScrollViewerWindow extends Container {
  77075. parentClientWidth: number;
  77076. parentClientHeight: number;
  77077. private _freezeControls;
  77078. private _parentMeasure;
  77079. private _oldLeft;
  77080. private _oldTop;
  77081. get freezeControls(): boolean;
  77082. set freezeControls(value: boolean);
  77083. private _bucketWidth;
  77084. private _bucketHeight;
  77085. private _buckets;
  77086. private _bucketLen;
  77087. get bucketWidth(): number;
  77088. get bucketHeight(): number;
  77089. setBucketSizes(width: number, height: number): void;
  77090. private _useBuckets;
  77091. private _makeBuckets;
  77092. private _dispatchInBuckets;
  77093. private _updateMeasures;
  77094. private _updateChildrenMeasures;
  77095. private _restoreMeasures;
  77096. /**
  77097. * Creates a new ScrollViewerWindow
  77098. * @param name of ScrollViewerWindow
  77099. */
  77100. constructor(name?: string);
  77101. protected _getTypeName(): string;
  77102. /** @hidden */
  77103. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77104. /** @hidden */
  77105. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77106. private _scrollChildren;
  77107. private _scrollChildrenWithBuckets;
  77108. /** @hidden */
  77109. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77110. protected _postMeasure(): void;
  77111. }
  77112. }
  77113. declare module BABYLON.GUI {
  77114. /**
  77115. * Class used to create slider controls
  77116. */
  77117. export class ScrollBar extends BaseSlider {
  77118. name?: string | undefined;
  77119. private _background;
  77120. private _borderColor;
  77121. private _tempMeasure;
  77122. /** Gets or sets border color */
  77123. get borderColor(): string;
  77124. set borderColor(value: string);
  77125. /** Gets or sets background color */
  77126. get background(): string;
  77127. set background(value: string);
  77128. /**
  77129. * Creates a new Slider
  77130. * @param name defines the control name
  77131. */
  77132. constructor(name?: string | undefined);
  77133. protected _getTypeName(): string;
  77134. protected _getThumbThickness(): number;
  77135. _draw(context: CanvasRenderingContext2D): void;
  77136. private _first;
  77137. private _originX;
  77138. private _originY;
  77139. /** @hidden */
  77140. protected _updateValueFromPointer(x: number, y: number): void;
  77141. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77142. }
  77143. }
  77144. declare module BABYLON.GUI {
  77145. /**
  77146. * Class used to create slider controls
  77147. */
  77148. export class ImageScrollBar extends BaseSlider {
  77149. name?: string | undefined;
  77150. private _backgroundBaseImage;
  77151. private _backgroundImage;
  77152. private _thumbImage;
  77153. private _thumbBaseImage;
  77154. private _thumbLength;
  77155. private _thumbHeight;
  77156. private _barImageHeight;
  77157. private _tempMeasure;
  77158. /** Number of 90° rotation to apply on the images when in vertical mode */
  77159. num90RotationInVerticalMode: number;
  77160. /**
  77161. * Gets or sets the image used to render the background for horizontal bar
  77162. */
  77163. get backgroundImage(): Image;
  77164. set backgroundImage(value: Image);
  77165. /**
  77166. * Gets or sets the image used to render the thumb
  77167. */
  77168. get thumbImage(): Image;
  77169. set thumbImage(value: Image);
  77170. /**
  77171. * Gets or sets the length of the thumb
  77172. */
  77173. get thumbLength(): number;
  77174. set thumbLength(value: number);
  77175. /**
  77176. * Gets or sets the height of the thumb
  77177. */
  77178. get thumbHeight(): number;
  77179. set thumbHeight(value: number);
  77180. /**
  77181. * Gets or sets the height of the bar image
  77182. */
  77183. get barImageHeight(): number;
  77184. set barImageHeight(value: number);
  77185. /**
  77186. * Creates a new ImageScrollBar
  77187. * @param name defines the control name
  77188. */
  77189. constructor(name?: string | undefined);
  77190. protected _getTypeName(): string;
  77191. protected _getThumbThickness(): number;
  77192. _draw(context: CanvasRenderingContext2D): void;
  77193. private _first;
  77194. private _originX;
  77195. private _originY;
  77196. /** @hidden */
  77197. protected _updateValueFromPointer(x: number, y: number): void;
  77198. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77199. }
  77200. }
  77201. declare module BABYLON.GUI {
  77202. /**
  77203. * Class used to hold a viewer window and sliders in a grid
  77204. */
  77205. export class ScrollViewer extends Rectangle {
  77206. private _grid;
  77207. private _horizontalBarSpace;
  77208. private _verticalBarSpace;
  77209. private _dragSpace;
  77210. private _horizontalBar;
  77211. private _verticalBar;
  77212. private _barColor;
  77213. private _barBackground;
  77214. private _barImage;
  77215. private _horizontalBarImage;
  77216. private _verticalBarImage;
  77217. private _barBackgroundImage;
  77218. private _horizontalBarBackgroundImage;
  77219. private _verticalBarBackgroundImage;
  77220. private _barSize;
  77221. private _window;
  77222. private _pointerIsOver;
  77223. private _wheelPrecision;
  77224. private _onWheelObserver;
  77225. private _clientWidth;
  77226. private _clientHeight;
  77227. private _useImageBar;
  77228. private _thumbLength;
  77229. private _thumbHeight;
  77230. private _barImageHeight;
  77231. private _horizontalBarImageHeight;
  77232. private _verticalBarImageHeight;
  77233. private _oldWindowContentsWidth;
  77234. private _oldWindowContentsHeight;
  77235. /**
  77236. * Gets the horizontal scrollbar
  77237. */
  77238. get horizontalBar(): ScrollBar | ImageScrollBar;
  77239. /**
  77240. * Gets the vertical scrollbar
  77241. */
  77242. get verticalBar(): ScrollBar | ImageScrollBar;
  77243. /**
  77244. * Adds a new control to the current container
  77245. * @param control defines the control to add
  77246. * @returns the current container
  77247. */
  77248. addControl(control: BABYLON.Nullable<Control>): Container;
  77249. /**
  77250. * Removes a control from the current container
  77251. * @param control defines the control to remove
  77252. * @returns the current container
  77253. */
  77254. removeControl(control: Control): Container;
  77255. /** Gets the list of children */
  77256. get children(): Control[];
  77257. _flagDescendantsAsMatrixDirty(): void;
  77258. /**
  77259. * Freezes or unfreezes the controls in the window.
  77260. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77261. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77262. */
  77263. get freezeControls(): boolean;
  77264. set freezeControls(value: boolean);
  77265. /** Gets the bucket width */
  77266. get bucketWidth(): number;
  77267. /** Gets the bucket height */
  77268. get bucketHeight(): number;
  77269. /**
  77270. * Sets the bucket sizes.
  77271. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77272. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77273. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77274. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77275. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77276. * used), that's why it is not enabled by default.
  77277. * @param width width of the bucket
  77278. * @param height height of the bucket
  77279. */
  77280. setBucketSizes(width: number, height: number): void;
  77281. private _forceHorizontalBar;
  77282. private _forceVerticalBar;
  77283. /**
  77284. * Forces the horizontal scroll bar to be displayed
  77285. */
  77286. get forceHorizontalBar(): boolean;
  77287. set forceHorizontalBar(value: boolean);
  77288. /**
  77289. * Forces the vertical scroll bar to be displayed
  77290. */
  77291. get forceVerticalBar(): boolean;
  77292. set forceVerticalBar(value: boolean);
  77293. /**
  77294. * Creates a new ScrollViewer
  77295. * @param name of ScrollViewer
  77296. */
  77297. constructor(name?: string, isImageBased?: boolean);
  77298. /** Reset the scroll viewer window to initial size */
  77299. resetWindow(): void;
  77300. protected _getTypeName(): string;
  77301. private _buildClientSizes;
  77302. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77303. protected _postMeasure(): void;
  77304. /**
  77305. * Gets or sets the mouse wheel precision
  77306. * from 0 to 1 with a default value of 0.05
  77307. * */
  77308. get wheelPrecision(): number;
  77309. set wheelPrecision(value: number);
  77310. /** Gets or sets the scroll bar container background color */
  77311. get scrollBackground(): string;
  77312. set scrollBackground(color: string);
  77313. /** Gets or sets the bar color */
  77314. get barColor(): string;
  77315. set barColor(color: string);
  77316. /** Gets or sets the bar image */
  77317. get thumbImage(): Image;
  77318. set thumbImage(value: Image);
  77319. /** Gets or sets the horizontal bar image */
  77320. get horizontalThumbImage(): Image;
  77321. set horizontalThumbImage(value: Image);
  77322. /** Gets or sets the vertical bar image */
  77323. get verticalThumbImage(): Image;
  77324. set verticalThumbImage(value: Image);
  77325. /** Gets or sets the size of the bar */
  77326. get barSize(): number;
  77327. set barSize(value: number);
  77328. /** Gets or sets the length of the thumb */
  77329. get thumbLength(): number;
  77330. set thumbLength(value: number);
  77331. /** Gets or sets the height of the thumb */
  77332. get thumbHeight(): number;
  77333. set thumbHeight(value: number);
  77334. /** Gets or sets the height of the bar image */
  77335. get barImageHeight(): number;
  77336. set barImageHeight(value: number);
  77337. /** Gets or sets the height of the horizontal bar image */
  77338. get horizontalBarImageHeight(): number;
  77339. set horizontalBarImageHeight(value: number);
  77340. /** Gets or sets the height of the vertical bar image */
  77341. get verticalBarImageHeight(): number;
  77342. set verticalBarImageHeight(value: number);
  77343. /** Gets or sets the bar background */
  77344. get barBackground(): string;
  77345. set barBackground(color: string);
  77346. /** Gets or sets the bar background image */
  77347. get barImage(): Image;
  77348. set barImage(value: Image);
  77349. /** Gets or sets the horizontal bar background image */
  77350. get horizontalBarImage(): Image;
  77351. set horizontalBarImage(value: Image);
  77352. /** Gets or sets the vertical bar background image */
  77353. get verticalBarImage(): Image;
  77354. set verticalBarImage(value: Image);
  77355. private _setWindowPosition;
  77356. /** @hidden */
  77357. private _updateScroller;
  77358. _link(host: AdvancedDynamicTexture): void;
  77359. /** @hidden */
  77360. private _addBar;
  77361. /** @hidden */
  77362. private _attachWheel;
  77363. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77364. /** Releases associated resources */
  77365. dispose(): void;
  77366. }
  77367. }
  77368. declare module BABYLON.GUI {
  77369. /** Class used to render a grid */
  77370. export class DisplayGrid extends Control {
  77371. name?: string | undefined;
  77372. private _cellWidth;
  77373. private _cellHeight;
  77374. private _minorLineTickness;
  77375. private _minorLineColor;
  77376. private _majorLineTickness;
  77377. private _majorLineColor;
  77378. private _majorLineFrequency;
  77379. private _background;
  77380. private _displayMajorLines;
  77381. private _displayMinorLines;
  77382. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77383. get displayMinorLines(): boolean;
  77384. set displayMinorLines(value: boolean);
  77385. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77386. get displayMajorLines(): boolean;
  77387. set displayMajorLines(value: boolean);
  77388. /** Gets or sets background color (Black by default) */
  77389. get background(): string;
  77390. set background(value: string);
  77391. /** Gets or sets the width of each cell (20 by default) */
  77392. get cellWidth(): number;
  77393. set cellWidth(value: number);
  77394. /** Gets or sets the height of each cell (20 by default) */
  77395. get cellHeight(): number;
  77396. set cellHeight(value: number);
  77397. /** Gets or sets the tickness of minor lines (1 by default) */
  77398. get minorLineTickness(): number;
  77399. set minorLineTickness(value: number);
  77400. /** Gets or sets the color of minor lines (DarkGray by default) */
  77401. get minorLineColor(): string;
  77402. set minorLineColor(value: string);
  77403. /** Gets or sets the tickness of major lines (2 by default) */
  77404. get majorLineTickness(): number;
  77405. set majorLineTickness(value: number);
  77406. /** Gets or sets the color of major lines (White by default) */
  77407. get majorLineColor(): string;
  77408. set majorLineColor(value: string);
  77409. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77410. get majorLineFrequency(): number;
  77411. set majorLineFrequency(value: number);
  77412. /**
  77413. * Creates a new GridDisplayRectangle
  77414. * @param name defines the control name
  77415. */
  77416. constructor(name?: string | undefined);
  77417. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77418. protected _getTypeName(): string;
  77419. }
  77420. }
  77421. declare module BABYLON.GUI {
  77422. /**
  77423. * Class used to create slider controls based on images
  77424. */
  77425. export class ImageBasedSlider extends BaseSlider {
  77426. name?: string | undefined;
  77427. private _backgroundImage;
  77428. private _thumbImage;
  77429. private _valueBarImage;
  77430. private _tempMeasure;
  77431. get displayThumb(): boolean;
  77432. set displayThumb(value: boolean);
  77433. /**
  77434. * Gets or sets the image used to render the background
  77435. */
  77436. get backgroundImage(): Image;
  77437. set backgroundImage(value: Image);
  77438. /**
  77439. * Gets or sets the image used to render the value bar
  77440. */
  77441. get valueBarImage(): Image;
  77442. set valueBarImage(value: Image);
  77443. /**
  77444. * Gets or sets the image used to render the thumb
  77445. */
  77446. get thumbImage(): Image;
  77447. set thumbImage(value: Image);
  77448. /**
  77449. * Creates a new ImageBasedSlider
  77450. * @param name defines the control name
  77451. */
  77452. constructor(name?: string | undefined);
  77453. protected _getTypeName(): string;
  77454. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77455. }
  77456. }
  77457. declare module BABYLON.GUI {
  77458. /**
  77459. * Forcing an export so that this code will execute
  77460. * @hidden
  77461. */
  77462. const name = "Statics";
  77463. }
  77464. declare module BABYLON.GUI {
  77465. /**
  77466. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77467. */
  77468. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77469. /**
  77470. * Define the instrumented AdvancedDynamicTexture.
  77471. */
  77472. texture: AdvancedDynamicTexture;
  77473. private _captureRenderTime;
  77474. private _renderTime;
  77475. private _captureLayoutTime;
  77476. private _layoutTime;
  77477. private _onBeginRenderObserver;
  77478. private _onEndRenderObserver;
  77479. private _onBeginLayoutObserver;
  77480. private _onEndLayoutObserver;
  77481. /**
  77482. * Gets the perf counter used to capture render time
  77483. */
  77484. get renderTimeCounter(): BABYLON.PerfCounter;
  77485. /**
  77486. * Gets the perf counter used to capture layout time
  77487. */
  77488. get layoutTimeCounter(): BABYLON.PerfCounter;
  77489. /**
  77490. * Enable or disable the render time capture
  77491. */
  77492. get captureRenderTime(): boolean;
  77493. set captureRenderTime(value: boolean);
  77494. /**
  77495. * Enable or disable the layout time capture
  77496. */
  77497. get captureLayoutTime(): boolean;
  77498. set captureLayoutTime(value: boolean);
  77499. /**
  77500. * Instantiates a new advanced dynamic texture instrumentation.
  77501. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77502. * @param texture Defines the AdvancedDynamicTexture to instrument
  77503. */
  77504. constructor(
  77505. /**
  77506. * Define the instrumented AdvancedDynamicTexture.
  77507. */
  77508. texture: AdvancedDynamicTexture);
  77509. /**
  77510. * Dispose and release associated resources.
  77511. */
  77512. dispose(): void;
  77513. }
  77514. }
  77515. declare module BABYLON.GUI {
  77516. /**
  77517. * Class used to load GUI via XML.
  77518. */
  77519. export class XmlLoader {
  77520. private _nodes;
  77521. private _nodeTypes;
  77522. private _isLoaded;
  77523. private _objectAttributes;
  77524. private _parentClass;
  77525. /**
  77526. * Create a new xml loader
  77527. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77528. */
  77529. constructor(parentClass?: null);
  77530. private _getChainElement;
  77531. private _getClassAttribute;
  77532. private _createGuiElement;
  77533. private _parseGrid;
  77534. private _parseElement;
  77535. private _prepareSourceElement;
  77536. private _parseElementsFromSource;
  77537. private _parseXml;
  77538. /**
  77539. * Gets if the loading has finished.
  77540. * @returns whether the loading has finished or not
  77541. */
  77542. isLoaded(): boolean;
  77543. /**
  77544. * Gets a loaded node / control by id.
  77545. * @param id the Controls id set in the xml
  77546. * @returns element of type Control
  77547. */
  77548. getNodeById(id: string): any;
  77549. /**
  77550. * Gets all loaded nodes / controls
  77551. * @returns Array of controls
  77552. */
  77553. getNodes(): any;
  77554. /**
  77555. * Initiates the xml layout loading
  77556. * @param xmlFile defines the xml layout to load
  77557. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77558. * @param callback defines the callback called on layout load.
  77559. */
  77560. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77561. }
  77562. }
  77563. declare module BABYLON.GUI {
  77564. /**
  77565. * Class used to create containers for controls
  77566. */
  77567. export class Container3D extends Control3D {
  77568. private _blockLayout;
  77569. /**
  77570. * Gets the list of child controls
  77571. */
  77572. protected _children: Control3D[];
  77573. /**
  77574. * Gets the list of child controls
  77575. */
  77576. get children(): Array<Control3D>;
  77577. /**
  77578. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77579. * This is helpful to optimize layout operation when adding multiple children in a row
  77580. */
  77581. get blockLayout(): boolean;
  77582. set blockLayout(value: boolean);
  77583. /**
  77584. * Creates a new container
  77585. * @param name defines the container name
  77586. */
  77587. constructor(name?: string);
  77588. /**
  77589. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77590. * @returns the current container
  77591. */
  77592. updateLayout(): Container3D;
  77593. /**
  77594. * Gets a boolean indicating if the given control is in the children of this control
  77595. * @param control defines the control to check
  77596. * @returns true if the control is in the child list
  77597. */
  77598. containsControl(control: Control3D): boolean;
  77599. /**
  77600. * Adds a control to the children of this control
  77601. * @param control defines the control to add
  77602. * @returns the current container
  77603. */
  77604. addControl(control: Control3D): Container3D;
  77605. /**
  77606. * This function will be called everytime a new control is added
  77607. */
  77608. protected _arrangeChildren(): void;
  77609. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77610. /**
  77611. * Removes a control from the children of this control
  77612. * @param control defines the control to remove
  77613. * @returns the current container
  77614. */
  77615. removeControl(control: Control3D): Container3D;
  77616. protected _getTypeName(): string;
  77617. /**
  77618. * Releases all associated resources
  77619. */
  77620. dispose(): void;
  77621. /** Control rotation will remain unchanged */
  77622. static readonly UNSET_ORIENTATION: number;
  77623. /** Control will rotate to make it look at sphere central axis */
  77624. static readonly FACEORIGIN_ORIENTATION: number;
  77625. /** Control will rotate to make it look back at sphere central axis */
  77626. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77627. /** Control will rotate to look at z axis (0, 0, 1) */
  77628. static readonly FACEFORWARD_ORIENTATION: number;
  77629. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77630. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77631. }
  77632. }
  77633. declare module BABYLON.GUI {
  77634. /**
  77635. * Class used to manage 3D user interface
  77636. * @see http://doc.babylonjs.com/how_to/gui3d
  77637. */
  77638. export class GUI3DManager implements BABYLON.IDisposable {
  77639. private _scene;
  77640. private _sceneDisposeObserver;
  77641. private _utilityLayer;
  77642. private _rootContainer;
  77643. private _pointerObserver;
  77644. private _pointerOutObserver;
  77645. /** @hidden */
  77646. _lastPickedControl: Control3D;
  77647. /** @hidden */
  77648. _lastControlOver: {
  77649. [pointerId: number]: Control3D;
  77650. };
  77651. /** @hidden */
  77652. _lastControlDown: {
  77653. [pointerId: number]: Control3D;
  77654. };
  77655. /**
  77656. * BABYLON.Observable raised when the point picked by the pointer events changed
  77657. */
  77658. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77659. /** @hidden */
  77660. _sharedMaterials: {
  77661. [key: string]: BABYLON.Material;
  77662. };
  77663. /** Gets the hosting scene */
  77664. get scene(): BABYLON.Scene;
  77665. /** Gets associated utility layer */
  77666. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77667. /**
  77668. * Creates a new GUI3DManager
  77669. * @param scene
  77670. */
  77671. constructor(scene?: BABYLON.Scene);
  77672. private _handlePointerOut;
  77673. private _doPicking;
  77674. /**
  77675. * Gets the root container
  77676. */
  77677. get rootContainer(): Container3D;
  77678. /**
  77679. * Gets a boolean indicating if the given control is in the root child list
  77680. * @param control defines the control to check
  77681. * @returns true if the control is in the root child list
  77682. */
  77683. containsControl(control: Control3D): boolean;
  77684. /**
  77685. * Adds a control to the root child list
  77686. * @param control defines the control to add
  77687. * @returns the current manager
  77688. */
  77689. addControl(control: Control3D): GUI3DManager;
  77690. /**
  77691. * Removes a control from the root child list
  77692. * @param control defines the control to remove
  77693. * @returns the current container
  77694. */
  77695. removeControl(control: Control3D): GUI3DManager;
  77696. /**
  77697. * Releases all associated resources
  77698. */
  77699. dispose(): void;
  77700. }
  77701. }
  77702. declare module BABYLON.GUI {
  77703. /**
  77704. * Class used to transport BABYLON.Vector3 information for pointer events
  77705. */
  77706. export class Vector3WithInfo extends BABYLON.Vector3 {
  77707. /** defines the current mouse button index */
  77708. buttonIndex: number;
  77709. /**
  77710. * Creates a new Vector3WithInfo
  77711. * @param source defines the vector3 data to transport
  77712. * @param buttonIndex defines the current mouse button index
  77713. */
  77714. constructor(source: BABYLON.Vector3,
  77715. /** defines the current mouse button index */
  77716. buttonIndex?: number);
  77717. }
  77718. }
  77719. declare module BABYLON.GUI {
  77720. /**
  77721. * Class used as base class for controls
  77722. */
  77723. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77724. /** Defines the control name */
  77725. name?: string | undefined;
  77726. /** @hidden */
  77727. _host: GUI3DManager;
  77728. private _node;
  77729. private _downCount;
  77730. private _enterCount;
  77731. private _downPointerIds;
  77732. private _isVisible;
  77733. /** Gets or sets the control position in world space */
  77734. get position(): BABYLON.Vector3;
  77735. set position(value: BABYLON.Vector3);
  77736. /** Gets or sets the control scaling in world space */
  77737. get scaling(): BABYLON.Vector3;
  77738. set scaling(value: BABYLON.Vector3);
  77739. /** Callback used to start pointer enter animation */
  77740. pointerEnterAnimation: () => void;
  77741. /** Callback used to start pointer out animation */
  77742. pointerOutAnimation: () => void;
  77743. /** Callback used to start pointer down animation */
  77744. pointerDownAnimation: () => void;
  77745. /** Callback used to start pointer up animation */
  77746. pointerUpAnimation: () => void;
  77747. /**
  77748. * An event triggered when the pointer move over the control
  77749. */
  77750. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77751. /**
  77752. * An event triggered when the pointer move out of the control
  77753. */
  77754. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77755. /**
  77756. * An event triggered when the pointer taps the control
  77757. */
  77758. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77759. /**
  77760. * An event triggered when pointer is up
  77761. */
  77762. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77763. /**
  77764. * An event triggered when a control is clicked on (with a mouse)
  77765. */
  77766. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77767. /**
  77768. * An event triggered when pointer enters the control
  77769. */
  77770. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77771. /**
  77772. * Gets or sets the parent container
  77773. */
  77774. parent: BABYLON.Nullable<Container3D>;
  77775. private _behaviors;
  77776. /**
  77777. * Gets the list of attached behaviors
  77778. * @see http://doc.babylonjs.com/features/behaviour
  77779. */
  77780. get behaviors(): BABYLON.Behavior<Control3D>[];
  77781. /**
  77782. * Attach a behavior to the control
  77783. * @see http://doc.babylonjs.com/features/behaviour
  77784. * @param behavior defines the behavior to attach
  77785. * @returns the current control
  77786. */
  77787. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77788. /**
  77789. * Remove an attached behavior
  77790. * @see http://doc.babylonjs.com/features/behaviour
  77791. * @param behavior defines the behavior to attach
  77792. * @returns the current control
  77793. */
  77794. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77795. /**
  77796. * Gets an attached behavior by name
  77797. * @param name defines the name of the behavior to look for
  77798. * @see http://doc.babylonjs.com/features/behaviour
  77799. * @returns null if behavior was not found else the requested behavior
  77800. */
  77801. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77802. /** Gets or sets a boolean indicating if the control is visible */
  77803. get isVisible(): boolean;
  77804. set isVisible(value: boolean);
  77805. /**
  77806. * Creates a new control
  77807. * @param name defines the control name
  77808. */
  77809. constructor(
  77810. /** Defines the control name */
  77811. name?: string | undefined);
  77812. /**
  77813. * Gets a string representing the class name
  77814. */
  77815. get typeName(): string;
  77816. /**
  77817. * Get the current class name of the control.
  77818. * @returns current class name
  77819. */
  77820. getClassName(): string;
  77821. protected _getTypeName(): string;
  77822. /**
  77823. * Gets the transform node used by this control
  77824. */
  77825. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77826. /**
  77827. * Gets the mesh used to render this control
  77828. */
  77829. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77830. /**
  77831. * Link the control as child of the given node
  77832. * @param node defines the node to link to. Use null to unlink the control
  77833. * @returns the current control
  77834. */
  77835. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77836. /** @hidden **/
  77837. _prepareNode(scene: BABYLON.Scene): void;
  77838. /**
  77839. * Node creation.
  77840. * Can be overriden by children
  77841. * @param scene defines the scene where the node must be attached
  77842. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77843. */
  77844. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77845. /**
  77846. * Affect a material to the given mesh
  77847. * @param mesh defines the mesh which will represent the control
  77848. */
  77849. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77850. /** @hidden */
  77851. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77852. /** @hidden */
  77853. _onPointerEnter(target: Control3D): boolean;
  77854. /** @hidden */
  77855. _onPointerOut(target: Control3D): void;
  77856. /** @hidden */
  77857. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77858. /** @hidden */
  77859. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77860. /** @hidden */
  77861. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77862. /** @hidden */
  77863. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77864. /** @hidden */
  77865. _disposeNode(): void;
  77866. /**
  77867. * Releases all associated resources
  77868. */
  77869. dispose(): void;
  77870. }
  77871. }
  77872. declare module BABYLON.GUI {
  77873. /**
  77874. * Class used as a root to all buttons
  77875. */
  77876. export class AbstractButton3D extends Control3D {
  77877. /**
  77878. * Creates a new button
  77879. * @param name defines the control name
  77880. */
  77881. constructor(name?: string);
  77882. protected _getTypeName(): string;
  77883. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77884. }
  77885. }
  77886. declare module BABYLON.GUI {
  77887. /**
  77888. * Class used to create a button in 3D
  77889. */
  77890. export class Button3D extends AbstractButton3D {
  77891. /** @hidden */
  77892. protected _currentMaterial: BABYLON.Material;
  77893. private _facadeTexture;
  77894. private _content;
  77895. private _contentResolution;
  77896. private _contentScaleRatio;
  77897. /**
  77898. * Gets or sets the texture resolution used to render content (512 by default)
  77899. */
  77900. get contentResolution(): BABYLON.int;
  77901. set contentResolution(value: BABYLON.int);
  77902. /**
  77903. * Gets or sets the texture scale ratio used to render content (2 by default)
  77904. */
  77905. get contentScaleRatio(): number;
  77906. set contentScaleRatio(value: number);
  77907. protected _disposeFacadeTexture(): void;
  77908. protected _resetContent(): void;
  77909. /**
  77910. * Creates a new button
  77911. * @param name defines the control name
  77912. */
  77913. constructor(name?: string);
  77914. /**
  77915. * Gets or sets the GUI 2D content used to display the button's facade
  77916. */
  77917. get content(): Control;
  77918. set content(value: Control);
  77919. /**
  77920. * Apply the facade texture (created from the content property).
  77921. * This function can be overloaded by child classes
  77922. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77923. */
  77924. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77925. protected _getTypeName(): string;
  77926. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77927. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77928. /**
  77929. * Releases all associated resources
  77930. */
  77931. dispose(): void;
  77932. }
  77933. }
  77934. declare module BABYLON.GUI {
  77935. /**
  77936. * Abstract class used to create a container panel deployed on the surface of a volume
  77937. */
  77938. export abstract class VolumeBasedPanel extends Container3D {
  77939. private _columns;
  77940. private _rows;
  77941. private _rowThenColum;
  77942. private _orientation;
  77943. protected _cellWidth: number;
  77944. protected _cellHeight: number;
  77945. /**
  77946. * Gets or sets the distance between elements
  77947. */
  77948. margin: number;
  77949. /**
  77950. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77951. * | Value | Type | Description |
  77952. * | ----- | ----------------------------------- | ----------- |
  77953. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77954. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77955. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77956. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77957. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77958. */
  77959. get orientation(): number;
  77960. set orientation(value: number);
  77961. /**
  77962. * Gets or sets the number of columns requested (10 by default).
  77963. * The panel will automatically compute the number of rows based on number of child controls.
  77964. */
  77965. get columns(): BABYLON.int;
  77966. set columns(value: BABYLON.int);
  77967. /**
  77968. * Gets or sets a the number of rows requested.
  77969. * The panel will automatically compute the number of columns based on number of child controls.
  77970. */
  77971. get rows(): BABYLON.int;
  77972. set rows(value: BABYLON.int);
  77973. /**
  77974. * Creates new VolumeBasedPanel
  77975. */
  77976. constructor();
  77977. protected _arrangeChildren(): void;
  77978. /** Child classes must implement this function to provide correct control positioning */
  77979. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77980. /** Child classes can implement this function to provide additional processing */
  77981. protected _finalProcessing(): void;
  77982. }
  77983. }
  77984. declare module BABYLON.GUI {
  77985. /**
  77986. * Class used to create a container panel deployed on the surface of a cylinder
  77987. */
  77988. export class CylinderPanel extends VolumeBasedPanel {
  77989. private _radius;
  77990. /**
  77991. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77992. */
  77993. get radius(): BABYLON.float;
  77994. set radius(value: BABYLON.float);
  77995. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77996. private _cylindricalMapping;
  77997. }
  77998. }
  77999. declare module BABYLON.GUI {
  78000. /** @hidden */
  78001. export var fluentVertexShader: {
  78002. name: string;
  78003. shader: string;
  78004. };
  78005. }
  78006. declare module BABYLON.GUI {
  78007. /** @hidden */
  78008. export var fluentPixelShader: {
  78009. name: string;
  78010. shader: string;
  78011. };
  78012. }
  78013. declare module BABYLON.GUI {
  78014. /** @hidden */
  78015. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78016. INNERGLOW: boolean;
  78017. BORDER: boolean;
  78018. HOVERLIGHT: boolean;
  78019. TEXTURE: boolean;
  78020. constructor();
  78021. }
  78022. /**
  78023. * Class used to render controls with fluent desgin
  78024. */
  78025. export class FluentMaterial extends BABYLON.PushMaterial {
  78026. /**
  78027. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78028. */
  78029. innerGlowColorIntensity: number;
  78030. /**
  78031. * Gets or sets the inner glow color (white by default)
  78032. */
  78033. innerGlowColor: BABYLON.Color3;
  78034. /**
  78035. * Gets or sets alpha value (default is 1.0)
  78036. */
  78037. alpha: number;
  78038. /**
  78039. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78040. */
  78041. albedoColor: BABYLON.Color3;
  78042. /**
  78043. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78044. */
  78045. renderBorders: boolean;
  78046. /**
  78047. * Gets or sets border width (default is 0.5)
  78048. */
  78049. borderWidth: number;
  78050. /**
  78051. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78052. */
  78053. edgeSmoothingValue: number;
  78054. /**
  78055. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78056. */
  78057. borderMinValue: number;
  78058. /**
  78059. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78060. */
  78061. renderHoverLight: boolean;
  78062. /**
  78063. * Gets or sets the radius used to render the hover light (default is 1.0)
  78064. */
  78065. hoverRadius: number;
  78066. /**
  78067. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78068. */
  78069. hoverColor: BABYLON.Color4;
  78070. /**
  78071. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78072. */
  78073. hoverPosition: BABYLON.Vector3;
  78074. private _albedoTexture;
  78075. /** Gets or sets the texture to use for albedo color */
  78076. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78077. /**
  78078. * Creates a new Fluent material
  78079. * @param name defines the name of the material
  78080. * @param scene defines the hosting scene
  78081. */
  78082. constructor(name: string, scene: BABYLON.Scene);
  78083. needAlphaBlending(): boolean;
  78084. needAlphaTesting(): boolean;
  78085. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78086. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78087. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78088. getActiveTextures(): BABYLON.BaseTexture[];
  78089. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78090. dispose(forceDisposeEffect?: boolean): void;
  78091. clone(name: string): FluentMaterial;
  78092. serialize(): any;
  78093. getClassName(): string;
  78094. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78095. }
  78096. }
  78097. declare module BABYLON.GUI {
  78098. /**
  78099. * Class used to create a holographic button in 3D
  78100. */
  78101. export class HolographicButton extends Button3D {
  78102. private _backPlate;
  78103. private _textPlate;
  78104. private _frontPlate;
  78105. private _text;
  78106. private _imageUrl;
  78107. private _shareMaterials;
  78108. private _frontMaterial;
  78109. private _backMaterial;
  78110. private _plateMaterial;
  78111. private _pickedPointObserver;
  78112. private _tooltipFade;
  78113. private _tooltipTextBlock;
  78114. private _tooltipTexture;
  78115. private _tooltipMesh;
  78116. private _tooltipHoverObserver;
  78117. private _tooltipOutObserver;
  78118. private _disposeTooltip;
  78119. /**
  78120. * Rendering ground id of all the mesh in the button
  78121. */
  78122. set renderingGroupId(id: number);
  78123. get renderingGroupId(): number;
  78124. /**
  78125. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78126. */
  78127. set tooltipText(text: BABYLON.Nullable<string>);
  78128. get tooltipText(): BABYLON.Nullable<string>;
  78129. /**
  78130. * Gets or sets text for the button
  78131. */
  78132. get text(): string;
  78133. set text(value: string);
  78134. /**
  78135. * Gets or sets the image url for the button
  78136. */
  78137. get imageUrl(): string;
  78138. set imageUrl(value: string);
  78139. /**
  78140. * Gets the back material used by this button
  78141. */
  78142. get backMaterial(): FluentMaterial;
  78143. /**
  78144. * Gets the front material used by this button
  78145. */
  78146. get frontMaterial(): FluentMaterial;
  78147. /**
  78148. * Gets the plate material used by this button
  78149. */
  78150. get plateMaterial(): BABYLON.StandardMaterial;
  78151. /**
  78152. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78153. */
  78154. get shareMaterials(): boolean;
  78155. /**
  78156. * Creates a new button
  78157. * @param name defines the control name
  78158. */
  78159. constructor(name?: string, shareMaterials?: boolean);
  78160. protected _getTypeName(): string;
  78161. private _rebuildContent;
  78162. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78163. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78164. private _createBackMaterial;
  78165. private _createFrontMaterial;
  78166. private _createPlateMaterial;
  78167. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78168. /**
  78169. * Releases all associated resources
  78170. */
  78171. dispose(): void;
  78172. }
  78173. }
  78174. declare module BABYLON.GUI {
  78175. /**
  78176. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78177. */
  78178. export class MeshButton3D extends Button3D {
  78179. /** @hidden */
  78180. protected _currentMesh: BABYLON.Mesh;
  78181. /**
  78182. * Creates a new 3D button based on a mesh
  78183. * @param mesh mesh to become a 3D button
  78184. * @param name defines the control name
  78185. */
  78186. constructor(mesh: BABYLON.Mesh, name?: string);
  78187. protected _getTypeName(): string;
  78188. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78189. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78190. }
  78191. }
  78192. declare module BABYLON.GUI {
  78193. /**
  78194. * Class used to create a container panel deployed on the surface of a plane
  78195. */
  78196. export class PlanePanel extends VolumeBasedPanel {
  78197. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78198. }
  78199. }
  78200. declare module BABYLON.GUI {
  78201. /**
  78202. * Class used to create a container panel where items get randomized planar mapping
  78203. */
  78204. export class ScatterPanel extends VolumeBasedPanel {
  78205. private _iteration;
  78206. /**
  78207. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78208. */
  78209. get iteration(): BABYLON.float;
  78210. set iteration(value: BABYLON.float);
  78211. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78212. private _scatterMapping;
  78213. protected _finalProcessing(): void;
  78214. }
  78215. }
  78216. declare module BABYLON.GUI {
  78217. /**
  78218. * Class used to create a container panel deployed on the surface of a sphere
  78219. */
  78220. export class SpherePanel extends VolumeBasedPanel {
  78221. private _radius;
  78222. /**
  78223. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78224. */
  78225. get radius(): BABYLON.float;
  78226. set radius(value: BABYLON.float);
  78227. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78228. private _sphericalMapping;
  78229. }
  78230. }
  78231. declare module BABYLON.GUI {
  78232. /**
  78233. * Class used to create a stack panel in 3D on XY plane
  78234. */
  78235. export class StackPanel3D extends Container3D {
  78236. private _isVertical;
  78237. /**
  78238. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78239. */
  78240. get isVertical(): boolean;
  78241. set isVertical(value: boolean);
  78242. /**
  78243. * Gets or sets the distance between elements
  78244. */
  78245. margin: number;
  78246. /**
  78247. * Creates new StackPanel
  78248. * @param isVertical
  78249. */
  78250. constructor(isVertical?: boolean);
  78251. protected _arrangeChildren(): void;
  78252. }
  78253. }
  78254. declare module BABYLON {
  78255. /**
  78256. * Configuration for glTF validation
  78257. */
  78258. export interface IGLTFValidationConfiguration {
  78259. /**
  78260. * The url of the glTF validator.
  78261. */
  78262. url: string;
  78263. }
  78264. /**
  78265. * glTF validation
  78266. */
  78267. export class GLTFValidation {
  78268. /**
  78269. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78270. */
  78271. static Configuration: IGLTFValidationConfiguration;
  78272. private static _LoadScriptPromise;
  78273. /**
  78274. * Validate a glTF asset using the glTF-Validator.
  78275. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78276. * @param rootUrl The root url for the glTF
  78277. * @param fileName The file name for the glTF
  78278. * @param getExternalResource The callback to get external resources for the glTF validator
  78279. * @returns A promise that resolves with the glTF validation results once complete
  78280. */
  78281. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78282. }
  78283. }
  78284. declare module BABYLON {
  78285. /**
  78286. * Mode that determines the coordinate system to use.
  78287. */
  78288. export enum GLTFLoaderCoordinateSystemMode {
  78289. /**
  78290. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78291. */
  78292. AUTO = 0,
  78293. /**
  78294. * Sets the useRightHandedSystem flag on the scene.
  78295. */
  78296. FORCE_RIGHT_HANDED = 1
  78297. }
  78298. /**
  78299. * Mode that determines what animations will start.
  78300. */
  78301. export enum GLTFLoaderAnimationStartMode {
  78302. /**
  78303. * No animation will start.
  78304. */
  78305. NONE = 0,
  78306. /**
  78307. * The first animation will start.
  78308. */
  78309. FIRST = 1,
  78310. /**
  78311. * All animations will start.
  78312. */
  78313. ALL = 2
  78314. }
  78315. /**
  78316. * Interface that contains the data for the glTF asset.
  78317. */
  78318. export interface IGLTFLoaderData {
  78319. /**
  78320. * The object that represents the glTF JSON.
  78321. */
  78322. json: Object;
  78323. /**
  78324. * The BIN chunk of a binary glTF.
  78325. */
  78326. bin: Nullable<IDataBuffer>;
  78327. }
  78328. /**
  78329. * Interface for extending the loader.
  78330. */
  78331. export interface IGLTFLoaderExtension {
  78332. /**
  78333. * The name of this extension.
  78334. */
  78335. readonly name: string;
  78336. /**
  78337. * Defines whether this extension is enabled.
  78338. */
  78339. enabled: boolean;
  78340. /**
  78341. * Defines the order of this extension.
  78342. * The loader sorts the extensions using these values when loading.
  78343. */
  78344. order?: number;
  78345. }
  78346. /**
  78347. * Loader state.
  78348. */
  78349. export enum GLTFLoaderState {
  78350. /**
  78351. * The asset is loading.
  78352. */
  78353. LOADING = 0,
  78354. /**
  78355. * The asset is ready for rendering.
  78356. */
  78357. READY = 1,
  78358. /**
  78359. * The asset is completely loaded.
  78360. */
  78361. COMPLETE = 2
  78362. }
  78363. /** @hidden */
  78364. export interface IImportMeshAsyncOutput {
  78365. meshes: AbstractMesh[];
  78366. particleSystems: IParticleSystem[];
  78367. skeletons: Skeleton[];
  78368. animationGroups: AnimationGroup[];
  78369. lights: Light[];
  78370. transformNodes: TransformNode[];
  78371. }
  78372. /** @hidden */
  78373. export interface IGLTFLoader extends IDisposable {
  78374. readonly state: Nullable<GLTFLoaderState>;
  78375. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78376. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78377. }
  78378. /**
  78379. * File loader for loading glTF files into a scene.
  78380. */
  78381. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78382. /** @hidden */
  78383. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78384. /** @hidden */
  78385. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78386. /**
  78387. * Raised when the asset has been parsed
  78388. */
  78389. onParsedObservable: Observable<IGLTFLoaderData>;
  78390. private _onParsedObserver;
  78391. /**
  78392. * Raised when the asset has been parsed
  78393. */
  78394. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78395. /**
  78396. * 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.
  78397. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78398. * Defaults to true.
  78399. * @hidden
  78400. */
  78401. static IncrementalLoading: boolean;
  78402. /**
  78403. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78404. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78405. * @hidden
  78406. */
  78407. static HomogeneousCoordinates: boolean;
  78408. /**
  78409. * The coordinate system mode. Defaults to AUTO.
  78410. */
  78411. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78412. /**
  78413. * The animation start mode. Defaults to FIRST.
  78414. */
  78415. animationStartMode: GLTFLoaderAnimationStartMode;
  78416. /**
  78417. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78418. */
  78419. compileMaterials: boolean;
  78420. /**
  78421. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78422. */
  78423. useClipPlane: boolean;
  78424. /**
  78425. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78426. */
  78427. compileShadowGenerators: boolean;
  78428. /**
  78429. * Defines if the Alpha blended materials are only applied as coverage.
  78430. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78431. * If true, no extra effects are applied to transparent pixels.
  78432. */
  78433. transparencyAsCoverage: boolean;
  78434. /**
  78435. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78436. * Enabling will disable offline support and glTF validator.
  78437. * Defaults to false.
  78438. */
  78439. useRangeRequests: boolean;
  78440. /**
  78441. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78442. */
  78443. createInstances: boolean;
  78444. /**
  78445. * Function called before loading a url referenced by the asset.
  78446. */
  78447. preprocessUrlAsync: (url: string) => Promise<string>;
  78448. /**
  78449. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78450. */
  78451. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78452. private _onMeshLoadedObserver;
  78453. /**
  78454. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78455. */
  78456. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78457. /**
  78458. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78459. */
  78460. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78461. private _onTextureLoadedObserver;
  78462. /**
  78463. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78464. */
  78465. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78466. /**
  78467. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78468. */
  78469. readonly onMaterialLoadedObservable: Observable<Material>;
  78470. private _onMaterialLoadedObserver;
  78471. /**
  78472. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78473. */
  78474. set onMaterialLoaded(callback: (material: Material) => void);
  78475. /**
  78476. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78477. */
  78478. readonly onCameraLoadedObservable: Observable<Camera>;
  78479. private _onCameraLoadedObserver;
  78480. /**
  78481. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78482. */
  78483. set onCameraLoaded(callback: (camera: Camera) => void);
  78484. /**
  78485. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78486. * For assets with LODs, raised when all of the LODs are complete.
  78487. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78488. */
  78489. readonly onCompleteObservable: Observable<void>;
  78490. private _onCompleteObserver;
  78491. /**
  78492. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78493. * For assets with LODs, raised when all of the LODs are complete.
  78494. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78495. */
  78496. set onComplete(callback: () => void);
  78497. /**
  78498. * Observable raised when an error occurs.
  78499. */
  78500. readonly onErrorObservable: Observable<any>;
  78501. private _onErrorObserver;
  78502. /**
  78503. * Callback raised when an error occurs.
  78504. */
  78505. set onError(callback: (reason: any) => void);
  78506. /**
  78507. * Observable raised after the loader is disposed.
  78508. */
  78509. readonly onDisposeObservable: Observable<void>;
  78510. private _onDisposeObserver;
  78511. /**
  78512. * Callback raised after the loader is disposed.
  78513. */
  78514. set onDispose(callback: () => void);
  78515. /**
  78516. * Observable raised after a loader extension is created.
  78517. * Set additional options for a loader extension in this event.
  78518. */
  78519. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78520. private _onExtensionLoadedObserver;
  78521. /**
  78522. * Callback raised after a loader extension is created.
  78523. */
  78524. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78525. /**
  78526. * Defines if the loader logging is enabled.
  78527. */
  78528. get loggingEnabled(): boolean;
  78529. set loggingEnabled(value: boolean);
  78530. /**
  78531. * Defines if the loader should capture performance counters.
  78532. */
  78533. get capturePerformanceCounters(): boolean;
  78534. set capturePerformanceCounters(value: boolean);
  78535. /**
  78536. * Defines if the loader should validate the asset.
  78537. */
  78538. validate: boolean;
  78539. /**
  78540. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78541. */
  78542. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78543. private _onValidatedObserver;
  78544. /**
  78545. * Callback raised after a loader extension is created.
  78546. */
  78547. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78548. private _loader;
  78549. private _progressCallback?;
  78550. private _requests;
  78551. /**
  78552. * Name of the loader ("gltf")
  78553. */
  78554. name: string;
  78555. /** @hidden */
  78556. extensions: ISceneLoaderPluginExtensions;
  78557. /**
  78558. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78559. */
  78560. dispose(): void;
  78561. /** @hidden */
  78562. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78563. /** @hidden */
  78564. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78565. /** @hidden */
  78566. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78567. meshes: AbstractMesh[];
  78568. particleSystems: IParticleSystem[];
  78569. skeletons: Skeleton[];
  78570. animationGroups: AnimationGroup[];
  78571. }>;
  78572. /** @hidden */
  78573. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78574. /** @hidden */
  78575. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78576. /** @hidden */
  78577. canDirectLoad(data: string): boolean;
  78578. /** @hidden */
  78579. directLoad(scene: Scene, data: string): any;
  78580. /**
  78581. * The callback that allows custom handling of the root url based on the response url.
  78582. * @param rootUrl the original root url
  78583. * @param responseURL the response url if available
  78584. * @returns the new root url
  78585. */
  78586. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78587. /** @hidden */
  78588. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78589. /**
  78590. * The loader state or null if the loader is not active.
  78591. */
  78592. get loaderState(): Nullable<GLTFLoaderState>;
  78593. /**
  78594. * Returns a promise that resolves when the asset is completely loaded.
  78595. * @returns a promise that resolves when the asset is completely loaded.
  78596. */
  78597. whenCompleteAsync(): Promise<void>;
  78598. /** @hidden */
  78599. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  78600. /** @hidden */
  78601. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  78602. private _onProgress;
  78603. private _validate;
  78604. private _getLoader;
  78605. private _parseJson;
  78606. private _unpackBinaryAsync;
  78607. private _unpackBinaryV1Async;
  78608. private _unpackBinaryV2Async;
  78609. private static _parseVersion;
  78610. private static _compareVersion;
  78611. private static readonly _logSpaces;
  78612. private _logIndentLevel;
  78613. private _loggingEnabled;
  78614. /** @hidden */
  78615. _log: (message: string) => void;
  78616. /** @hidden */
  78617. _logOpen(message: string): void;
  78618. /** @hidden */
  78619. _logClose(): void;
  78620. private _logEnabled;
  78621. private _logDisabled;
  78622. private _capturePerformanceCounters;
  78623. /** @hidden */
  78624. _startPerformanceCounter: (counterName: string) => void;
  78625. /** @hidden */
  78626. _endPerformanceCounter: (counterName: string) => void;
  78627. private _startPerformanceCounterEnabled;
  78628. private _startPerformanceCounterDisabled;
  78629. private _endPerformanceCounterEnabled;
  78630. private _endPerformanceCounterDisabled;
  78631. }
  78632. }
  78633. declare module BABYLON.GLTF1 {
  78634. /**
  78635. * Enums
  78636. * @hidden
  78637. */
  78638. export enum EComponentType {
  78639. BYTE = 5120,
  78640. UNSIGNED_BYTE = 5121,
  78641. SHORT = 5122,
  78642. UNSIGNED_SHORT = 5123,
  78643. FLOAT = 5126
  78644. }
  78645. /** @hidden */
  78646. export enum EShaderType {
  78647. FRAGMENT = 35632,
  78648. VERTEX = 35633
  78649. }
  78650. /** @hidden */
  78651. export enum EParameterType {
  78652. BYTE = 5120,
  78653. UNSIGNED_BYTE = 5121,
  78654. SHORT = 5122,
  78655. UNSIGNED_SHORT = 5123,
  78656. INT = 5124,
  78657. UNSIGNED_INT = 5125,
  78658. FLOAT = 5126,
  78659. FLOAT_VEC2 = 35664,
  78660. FLOAT_VEC3 = 35665,
  78661. FLOAT_VEC4 = 35666,
  78662. INT_VEC2 = 35667,
  78663. INT_VEC3 = 35668,
  78664. INT_VEC4 = 35669,
  78665. BOOL = 35670,
  78666. BOOL_VEC2 = 35671,
  78667. BOOL_VEC3 = 35672,
  78668. BOOL_VEC4 = 35673,
  78669. FLOAT_MAT2 = 35674,
  78670. FLOAT_MAT3 = 35675,
  78671. FLOAT_MAT4 = 35676,
  78672. SAMPLER_2D = 35678
  78673. }
  78674. /** @hidden */
  78675. export enum ETextureWrapMode {
  78676. CLAMP_TO_EDGE = 33071,
  78677. MIRRORED_REPEAT = 33648,
  78678. REPEAT = 10497
  78679. }
  78680. /** @hidden */
  78681. export enum ETextureFilterType {
  78682. NEAREST = 9728,
  78683. LINEAR = 9728,
  78684. NEAREST_MIPMAP_NEAREST = 9984,
  78685. LINEAR_MIPMAP_NEAREST = 9985,
  78686. NEAREST_MIPMAP_LINEAR = 9986,
  78687. LINEAR_MIPMAP_LINEAR = 9987
  78688. }
  78689. /** @hidden */
  78690. export enum ETextureFormat {
  78691. ALPHA = 6406,
  78692. RGB = 6407,
  78693. RGBA = 6408,
  78694. LUMINANCE = 6409,
  78695. LUMINANCE_ALPHA = 6410
  78696. }
  78697. /** @hidden */
  78698. export enum ECullingType {
  78699. FRONT = 1028,
  78700. BACK = 1029,
  78701. FRONT_AND_BACK = 1032
  78702. }
  78703. /** @hidden */
  78704. export enum EBlendingFunction {
  78705. ZERO = 0,
  78706. ONE = 1,
  78707. SRC_COLOR = 768,
  78708. ONE_MINUS_SRC_COLOR = 769,
  78709. DST_COLOR = 774,
  78710. ONE_MINUS_DST_COLOR = 775,
  78711. SRC_ALPHA = 770,
  78712. ONE_MINUS_SRC_ALPHA = 771,
  78713. DST_ALPHA = 772,
  78714. ONE_MINUS_DST_ALPHA = 773,
  78715. CONSTANT_COLOR = 32769,
  78716. ONE_MINUS_CONSTANT_COLOR = 32770,
  78717. CONSTANT_ALPHA = 32771,
  78718. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78719. SRC_ALPHA_SATURATE = 776
  78720. }
  78721. /** @hidden */
  78722. export interface IGLTFProperty {
  78723. extensions?: {
  78724. [key: string]: any;
  78725. };
  78726. extras?: Object;
  78727. }
  78728. /** @hidden */
  78729. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78730. name?: string;
  78731. }
  78732. /** @hidden */
  78733. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78734. bufferView: string;
  78735. byteOffset: number;
  78736. byteStride: number;
  78737. count: number;
  78738. type: string;
  78739. componentType: EComponentType;
  78740. max?: number[];
  78741. min?: number[];
  78742. name?: string;
  78743. }
  78744. /** @hidden */
  78745. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78746. buffer: string;
  78747. byteOffset: number;
  78748. byteLength: number;
  78749. byteStride: number;
  78750. target?: number;
  78751. }
  78752. /** @hidden */
  78753. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78754. uri: string;
  78755. byteLength?: number;
  78756. type?: string;
  78757. }
  78758. /** @hidden */
  78759. export interface IGLTFShader extends IGLTFChildRootProperty {
  78760. uri: string;
  78761. type: EShaderType;
  78762. }
  78763. /** @hidden */
  78764. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78765. attributes: string[];
  78766. fragmentShader: string;
  78767. vertexShader: string;
  78768. }
  78769. /** @hidden */
  78770. export interface IGLTFTechniqueParameter {
  78771. type: number;
  78772. count?: number;
  78773. semantic?: string;
  78774. node?: string;
  78775. value?: number | boolean | string | Array<any>;
  78776. source?: string;
  78777. babylonValue?: any;
  78778. }
  78779. /** @hidden */
  78780. export interface IGLTFTechniqueCommonProfile {
  78781. lightingModel: string;
  78782. texcoordBindings: Object;
  78783. parameters?: Array<any>;
  78784. }
  78785. /** @hidden */
  78786. export interface IGLTFTechniqueStatesFunctions {
  78787. blendColor?: number[];
  78788. blendEquationSeparate?: number[];
  78789. blendFuncSeparate?: number[];
  78790. colorMask: boolean[];
  78791. cullFace: number[];
  78792. }
  78793. /** @hidden */
  78794. export interface IGLTFTechniqueStates {
  78795. enable: number[];
  78796. functions: IGLTFTechniqueStatesFunctions;
  78797. }
  78798. /** @hidden */
  78799. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78800. parameters: {
  78801. [key: string]: IGLTFTechniqueParameter;
  78802. };
  78803. program: string;
  78804. attributes: {
  78805. [key: string]: string;
  78806. };
  78807. uniforms: {
  78808. [key: string]: string;
  78809. };
  78810. states: IGLTFTechniqueStates;
  78811. }
  78812. /** @hidden */
  78813. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78814. technique?: string;
  78815. values: string[];
  78816. }
  78817. /** @hidden */
  78818. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78819. attributes: {
  78820. [key: string]: string;
  78821. };
  78822. indices: string;
  78823. material: string;
  78824. mode?: number;
  78825. }
  78826. /** @hidden */
  78827. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78828. primitives: IGLTFMeshPrimitive[];
  78829. }
  78830. /** @hidden */
  78831. export interface IGLTFImage extends IGLTFChildRootProperty {
  78832. uri: string;
  78833. }
  78834. /** @hidden */
  78835. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78836. magFilter?: number;
  78837. minFilter?: number;
  78838. wrapS?: number;
  78839. wrapT?: number;
  78840. }
  78841. /** @hidden */
  78842. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78843. sampler: string;
  78844. source: string;
  78845. format?: ETextureFormat;
  78846. internalFormat?: ETextureFormat;
  78847. target?: number;
  78848. type?: number;
  78849. babylonTexture?: Texture;
  78850. }
  78851. /** @hidden */
  78852. export interface IGLTFAmbienLight {
  78853. color?: number[];
  78854. }
  78855. /** @hidden */
  78856. export interface IGLTFDirectionalLight {
  78857. color?: number[];
  78858. }
  78859. /** @hidden */
  78860. export interface IGLTFPointLight {
  78861. color?: number[];
  78862. constantAttenuation?: number;
  78863. linearAttenuation?: number;
  78864. quadraticAttenuation?: number;
  78865. }
  78866. /** @hidden */
  78867. export interface IGLTFSpotLight {
  78868. color?: number[];
  78869. constantAttenuation?: number;
  78870. fallOfAngle?: number;
  78871. fallOffExponent?: number;
  78872. linearAttenuation?: number;
  78873. quadraticAttenuation?: number;
  78874. }
  78875. /** @hidden */
  78876. export interface IGLTFLight extends IGLTFChildRootProperty {
  78877. type: string;
  78878. }
  78879. /** @hidden */
  78880. export interface IGLTFCameraOrthographic {
  78881. xmag: number;
  78882. ymag: number;
  78883. zfar: number;
  78884. znear: number;
  78885. }
  78886. /** @hidden */
  78887. export interface IGLTFCameraPerspective {
  78888. aspectRatio: number;
  78889. yfov: number;
  78890. zfar: number;
  78891. znear: number;
  78892. }
  78893. /** @hidden */
  78894. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78895. type: string;
  78896. }
  78897. /** @hidden */
  78898. export interface IGLTFAnimationChannelTarget {
  78899. id: string;
  78900. path: string;
  78901. }
  78902. /** @hidden */
  78903. export interface IGLTFAnimationChannel {
  78904. sampler: string;
  78905. target: IGLTFAnimationChannelTarget;
  78906. }
  78907. /** @hidden */
  78908. export interface IGLTFAnimationSampler {
  78909. input: string;
  78910. output: string;
  78911. interpolation?: string;
  78912. }
  78913. /** @hidden */
  78914. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78915. channels?: IGLTFAnimationChannel[];
  78916. parameters?: {
  78917. [key: string]: string;
  78918. };
  78919. samplers?: {
  78920. [key: string]: IGLTFAnimationSampler;
  78921. };
  78922. }
  78923. /** @hidden */
  78924. export interface IGLTFNodeInstanceSkin {
  78925. skeletons: string[];
  78926. skin: string;
  78927. meshes: string[];
  78928. }
  78929. /** @hidden */
  78930. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78931. bindShapeMatrix: number[];
  78932. inverseBindMatrices: string;
  78933. jointNames: string[];
  78934. babylonSkeleton?: Skeleton;
  78935. }
  78936. /** @hidden */
  78937. export interface IGLTFNode extends IGLTFChildRootProperty {
  78938. camera?: string;
  78939. children: string[];
  78940. skin?: string;
  78941. jointName?: string;
  78942. light?: string;
  78943. matrix: number[];
  78944. mesh?: string;
  78945. meshes?: string[];
  78946. rotation?: number[];
  78947. scale?: number[];
  78948. translation?: number[];
  78949. babylonNode?: Node;
  78950. }
  78951. /** @hidden */
  78952. export interface IGLTFScene extends IGLTFChildRootProperty {
  78953. nodes: string[];
  78954. }
  78955. /** @hidden */
  78956. export interface IGLTFRuntime {
  78957. extensions: {
  78958. [key: string]: any;
  78959. };
  78960. accessors: {
  78961. [key: string]: IGLTFAccessor;
  78962. };
  78963. buffers: {
  78964. [key: string]: IGLTFBuffer;
  78965. };
  78966. bufferViews: {
  78967. [key: string]: IGLTFBufferView;
  78968. };
  78969. meshes: {
  78970. [key: string]: IGLTFMesh;
  78971. };
  78972. lights: {
  78973. [key: string]: IGLTFLight;
  78974. };
  78975. cameras: {
  78976. [key: string]: IGLTFCamera;
  78977. };
  78978. nodes: {
  78979. [key: string]: IGLTFNode;
  78980. };
  78981. images: {
  78982. [key: string]: IGLTFImage;
  78983. };
  78984. textures: {
  78985. [key: string]: IGLTFTexture;
  78986. };
  78987. shaders: {
  78988. [key: string]: IGLTFShader;
  78989. };
  78990. programs: {
  78991. [key: string]: IGLTFProgram;
  78992. };
  78993. samplers: {
  78994. [key: string]: IGLTFSampler;
  78995. };
  78996. techniques: {
  78997. [key: string]: IGLTFTechnique;
  78998. };
  78999. materials: {
  79000. [key: string]: IGLTFMaterial;
  79001. };
  79002. animations: {
  79003. [key: string]: IGLTFAnimation;
  79004. };
  79005. skins: {
  79006. [key: string]: IGLTFSkins;
  79007. };
  79008. currentScene?: Object;
  79009. scenes: {
  79010. [key: string]: IGLTFScene;
  79011. };
  79012. extensionsUsed: string[];
  79013. extensionsRequired?: string[];
  79014. buffersCount: number;
  79015. shaderscount: number;
  79016. scene: Scene;
  79017. rootUrl: string;
  79018. loadedBufferCount: number;
  79019. loadedBufferViews: {
  79020. [name: string]: ArrayBufferView;
  79021. };
  79022. loadedShaderCount: number;
  79023. importOnlyMeshes: boolean;
  79024. importMeshesNames?: string[];
  79025. dummyNodes: Node[];
  79026. forAssetContainer: boolean;
  79027. }
  79028. /** @hidden */
  79029. export interface INodeToRoot {
  79030. bone: Bone;
  79031. node: IGLTFNode;
  79032. id: string;
  79033. }
  79034. /** @hidden */
  79035. export interface IJointNode {
  79036. node: IGLTFNode;
  79037. id: string;
  79038. }
  79039. }
  79040. declare module BABYLON.GLTF1 {
  79041. /**
  79042. * Utils functions for GLTF
  79043. * @hidden
  79044. */
  79045. export class GLTFUtils {
  79046. /**
  79047. * Sets the given "parameter" matrix
  79048. * @param scene: the Scene object
  79049. * @param source: the source node where to pick the matrix
  79050. * @param parameter: the GLTF technique parameter
  79051. * @param uniformName: the name of the shader's uniform
  79052. * @param shaderMaterial: the shader material
  79053. */
  79054. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79055. /**
  79056. * Sets the given "parameter" matrix
  79057. * @param shaderMaterial: the shader material
  79058. * @param uniform: the name of the shader's uniform
  79059. * @param value: the value of the uniform
  79060. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79061. */
  79062. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79063. /**
  79064. * Returns the wrap mode of the texture
  79065. * @param mode: the mode value
  79066. */
  79067. static GetWrapMode(mode: number): number;
  79068. /**
  79069. * Returns the byte stride giving an accessor
  79070. * @param accessor: the GLTF accessor objet
  79071. */
  79072. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79073. /**
  79074. * Returns the texture filter mode giving a mode value
  79075. * @param mode: the filter mode value
  79076. */
  79077. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79078. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79079. /**
  79080. * Returns a buffer from its accessor
  79081. * @param gltfRuntime: the GLTF runtime
  79082. * @param accessor: the GLTF accessor
  79083. */
  79084. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79085. /**
  79086. * Decodes a buffer view into a string
  79087. * @param view: the buffer view
  79088. */
  79089. static DecodeBufferToText(view: ArrayBufferView): string;
  79090. /**
  79091. * Returns the default material of gltf. Related to
  79092. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79093. * @param scene: the Babylon.js scene
  79094. */
  79095. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79096. private static _DefaultMaterial;
  79097. }
  79098. }
  79099. declare module BABYLON.GLTF1 {
  79100. /**
  79101. * Implementation of the base glTF spec
  79102. * @hidden
  79103. */
  79104. export class GLTFLoaderBase {
  79105. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79106. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79107. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79108. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79109. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79110. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79111. }
  79112. /**
  79113. * glTF V1 Loader
  79114. * @hidden
  79115. */
  79116. export class GLTFLoader implements IGLTFLoader {
  79117. static Extensions: {
  79118. [name: string]: GLTFLoaderExtension;
  79119. };
  79120. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79121. state: Nullable<GLTFLoaderState>;
  79122. dispose(): void;
  79123. private _importMeshAsync;
  79124. /**
  79125. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79126. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79127. * @param scene the scene the meshes should be added to
  79128. * @param forAssetContainer defines if the entities must be stored in the scene
  79129. * @param data gltf data containing information of the meshes in a loaded file
  79130. * @param rootUrl root url to load from
  79131. * @param onProgress event that fires when loading progress has occured
  79132. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79133. */
  79134. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79135. private _loadAsync;
  79136. /**
  79137. * Imports all objects from a loaded gltf file and adds them to the scene
  79138. * @param scene the scene the objects should be added to
  79139. * @param data gltf data containing information of the meshes in a loaded file
  79140. * @param rootUrl root url to load from
  79141. * @param onProgress event that fires when loading progress has occured
  79142. * @returns a promise which completes when objects have been loaded to the scene
  79143. */
  79144. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79145. private _loadShadersAsync;
  79146. private _loadBuffersAsync;
  79147. private _createNodes;
  79148. }
  79149. /** @hidden */
  79150. export abstract class GLTFLoaderExtension {
  79151. private _name;
  79152. constructor(name: string);
  79153. get name(): string;
  79154. /**
  79155. * Defines an override for loading the runtime
  79156. * Return true to stop further extensions from loading the runtime
  79157. */
  79158. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79159. /**
  79160. * Defines an onverride for creating gltf runtime
  79161. * Return true to stop further extensions from creating the runtime
  79162. */
  79163. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79164. /**
  79165. * Defines an override for loading buffers
  79166. * Return true to stop further extensions from loading this buffer
  79167. */
  79168. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79169. /**
  79170. * Defines an override for loading texture buffers
  79171. * Return true to stop further extensions from loading this texture data
  79172. */
  79173. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79174. /**
  79175. * Defines an override for creating textures
  79176. * Return true to stop further extensions from loading this texture
  79177. */
  79178. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79179. /**
  79180. * Defines an override for loading shader strings
  79181. * Return true to stop further extensions from loading this shader data
  79182. */
  79183. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79184. /**
  79185. * Defines an override for loading materials
  79186. * Return true to stop further extensions from loading this material
  79187. */
  79188. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79189. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79190. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79191. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79192. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79193. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79194. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79195. private static LoadTextureBufferAsync;
  79196. private static CreateTextureAsync;
  79197. private static ApplyExtensions;
  79198. }
  79199. }
  79200. declare module BABYLON.GLTF1 {
  79201. /** @hidden */
  79202. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79203. private _bin;
  79204. constructor();
  79205. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79206. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79207. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79208. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79209. }
  79210. }
  79211. declare module BABYLON.GLTF1 {
  79212. /** @hidden */
  79213. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79214. constructor();
  79215. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79216. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79217. private _loadTexture;
  79218. }
  79219. }
  79220. declare module BABYLON.GLTF2.Loader {
  79221. /**
  79222. * Loader interface with an index field.
  79223. */
  79224. export interface IArrayItem {
  79225. /**
  79226. * The index of this item in the array.
  79227. */
  79228. index: number;
  79229. }
  79230. /**
  79231. * Loader interface with additional members.
  79232. */
  79233. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79234. /** @hidden */
  79235. _data?: Promise<ArrayBufferView>;
  79236. /** @hidden */
  79237. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79238. }
  79239. /**
  79240. * Loader interface with additional members.
  79241. */
  79242. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79243. }
  79244. /** @hidden */
  79245. export interface _IAnimationSamplerData {
  79246. input: Float32Array;
  79247. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79248. output: Float32Array;
  79249. }
  79250. /**
  79251. * Loader interface with additional members.
  79252. */
  79253. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79254. /** @hidden */
  79255. _data?: Promise<_IAnimationSamplerData>;
  79256. }
  79257. /**
  79258. * Loader interface with additional members.
  79259. */
  79260. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79261. channels: IAnimationChannel[];
  79262. samplers: IAnimationSampler[];
  79263. /** @hidden */
  79264. _babylonAnimationGroup?: AnimationGroup;
  79265. }
  79266. /**
  79267. * Loader interface with additional members.
  79268. */
  79269. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79270. /** @hidden */
  79271. _data?: Promise<ArrayBufferView>;
  79272. }
  79273. /**
  79274. * Loader interface with additional members.
  79275. */
  79276. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79277. /** @hidden */
  79278. _data?: Promise<ArrayBufferView>;
  79279. /** @hidden */
  79280. _babylonBuffer?: Promise<Buffer>;
  79281. }
  79282. /**
  79283. * Loader interface with additional members.
  79284. */
  79285. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79286. }
  79287. /**
  79288. * Loader interface with additional members.
  79289. */
  79290. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79291. /** @hidden */
  79292. _data?: Promise<ArrayBufferView>;
  79293. }
  79294. /**
  79295. * Loader interface with additional members.
  79296. */
  79297. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79298. }
  79299. /**
  79300. * Loader interface with additional members.
  79301. */
  79302. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79303. }
  79304. /**
  79305. * Loader interface with additional members.
  79306. */
  79307. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79308. baseColorTexture?: ITextureInfo;
  79309. metallicRoughnessTexture?: ITextureInfo;
  79310. }
  79311. /**
  79312. * Loader interface with additional members.
  79313. */
  79314. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79315. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79316. normalTexture?: IMaterialNormalTextureInfo;
  79317. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79318. emissiveTexture?: ITextureInfo;
  79319. /** @hidden */
  79320. _data?: {
  79321. [babylonDrawMode: number]: {
  79322. babylonMaterial: Material;
  79323. babylonMeshes: AbstractMesh[];
  79324. promise: Promise<void>;
  79325. };
  79326. };
  79327. }
  79328. /**
  79329. * Loader interface with additional members.
  79330. */
  79331. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79332. primitives: IMeshPrimitive[];
  79333. }
  79334. /**
  79335. * Loader interface with additional members.
  79336. */
  79337. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79338. /** @hidden */
  79339. _instanceData?: {
  79340. babylonSourceMesh: Mesh;
  79341. promise: Promise<any>;
  79342. };
  79343. }
  79344. /**
  79345. * Loader interface with additional members.
  79346. */
  79347. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79348. /**
  79349. * The parent glTF node.
  79350. */
  79351. parent?: INode;
  79352. /** @hidden */
  79353. _babylonTransformNode?: TransformNode;
  79354. /** @hidden */
  79355. _primitiveBabylonMeshes?: AbstractMesh[];
  79356. /** @hidden */
  79357. _babylonBones?: Bone[];
  79358. /** @hidden */
  79359. _numMorphTargets?: number;
  79360. }
  79361. /** @hidden */
  79362. export interface _ISamplerData {
  79363. noMipMaps: boolean;
  79364. samplingMode: number;
  79365. wrapU: number;
  79366. wrapV: number;
  79367. }
  79368. /**
  79369. * Loader interface with additional members.
  79370. */
  79371. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79372. /** @hidden */
  79373. _data?: _ISamplerData;
  79374. }
  79375. /**
  79376. * Loader interface with additional members.
  79377. */
  79378. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79379. }
  79380. /**
  79381. * Loader interface with additional members.
  79382. */
  79383. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79384. /** @hidden */
  79385. _data?: {
  79386. babylonSkeleton: Skeleton;
  79387. promise: Promise<void>;
  79388. };
  79389. }
  79390. /**
  79391. * Loader interface with additional members.
  79392. */
  79393. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79394. }
  79395. /**
  79396. * Loader interface with additional members.
  79397. */
  79398. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79399. }
  79400. /**
  79401. * Loader interface with additional members.
  79402. */
  79403. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79404. accessors?: IAccessor[];
  79405. animations?: IAnimation[];
  79406. buffers?: IBuffer[];
  79407. bufferViews?: IBufferView[];
  79408. cameras?: ICamera[];
  79409. images?: IImage[];
  79410. materials?: IMaterial[];
  79411. meshes?: IMesh[];
  79412. nodes?: INode[];
  79413. samplers?: ISampler[];
  79414. scenes?: IScene[];
  79415. skins?: ISkin[];
  79416. textures?: ITexture[];
  79417. }
  79418. }
  79419. declare module BABYLON.GLTF2 {
  79420. /**
  79421. * Interface for a glTF loader extension.
  79422. */
  79423. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79424. /**
  79425. * Called after the loader state changes to LOADING.
  79426. */
  79427. onLoading?(): void;
  79428. /**
  79429. * Called after the loader state changes to READY.
  79430. */
  79431. onReady?(): void;
  79432. /**
  79433. * Define this method to modify the default behavior when loading scenes.
  79434. * @param context The context when loading the asset
  79435. * @param scene The glTF scene property
  79436. * @returns A promise that resolves when the load is complete or null if not handled
  79437. */
  79438. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79439. /**
  79440. * Define this method to modify the default behavior when loading nodes.
  79441. * @param context The context when loading the asset
  79442. * @param node The glTF node property
  79443. * @param assign A function called synchronously after parsing the glTF properties
  79444. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79445. */
  79446. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79447. /**
  79448. * Define this method to modify the default behavior when loading cameras.
  79449. * @param context The context when loading the asset
  79450. * @param camera The glTF camera property
  79451. * @param assign A function called synchronously after parsing the glTF properties
  79452. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79453. */
  79454. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79455. /**
  79456. * @hidden
  79457. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79458. * @param context The context when loading the asset
  79459. * @param primitive The glTF mesh primitive property
  79460. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79461. */
  79462. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79463. /**
  79464. * @hidden
  79465. * Define this method to modify the default behavior when loading data for mesh primitives.
  79466. * @param context The context when loading the asset
  79467. * @param name The mesh name when loading the asset
  79468. * @param node The glTF node when loading the asset
  79469. * @param mesh The glTF mesh when loading the asset
  79470. * @param primitive The glTF mesh primitive property
  79471. * @param assign A function called synchronously after parsing the glTF properties
  79472. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79473. */
  79474. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79475. /**
  79476. * @hidden
  79477. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79478. * @param context The context when loading the asset
  79479. * @param material The glTF material property
  79480. * @param assign A function called synchronously after parsing the glTF properties
  79481. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79482. */
  79483. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79484. /**
  79485. * Define this method to modify the default behavior when creating materials.
  79486. * @param context The context when loading the asset
  79487. * @param material The glTF material property
  79488. * @param babylonDrawMode The draw mode for the Babylon material
  79489. * @returns The Babylon material or null if not handled
  79490. */
  79491. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79492. /**
  79493. * Define this method to modify the default behavior when loading material properties.
  79494. * @param context The context when loading the asset
  79495. * @param material The glTF material property
  79496. * @param babylonMaterial The Babylon material
  79497. * @returns A promise that resolves when the load is complete or null if not handled
  79498. */
  79499. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79500. /**
  79501. * Define this method to modify the default behavior when loading texture infos.
  79502. * @param context The context when loading the asset
  79503. * @param textureInfo The glTF texture info property
  79504. * @param assign A function called synchronously after parsing the glTF properties
  79505. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79506. */
  79507. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79508. /**
  79509. * @hidden
  79510. * Define this method to modify the default behavior when loading textures.
  79511. * @param context The context when loading the asset
  79512. * @param texture The glTF texture property
  79513. * @param assign A function called synchronously after parsing the glTF properties
  79514. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79515. */
  79516. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79517. /**
  79518. * Define this method to modify the default behavior when loading animations.
  79519. * @param context The context when loading the asset
  79520. * @param animation The glTF animation property
  79521. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79522. */
  79523. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79524. /**
  79525. * @hidden
  79526. * Define this method to modify the default behavior when loading skins.
  79527. * @param context The context when loading the asset
  79528. * @param node The glTF node property
  79529. * @param skin The glTF skin property
  79530. * @returns A promise that resolves when the load is complete or null if not handled
  79531. */
  79532. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79533. /**
  79534. * @hidden
  79535. * Define this method to modify the default behavior when loading uris.
  79536. * @param context The context when loading the asset
  79537. * @param property The glTF property associated with the uri
  79538. * @param uri The uri to load
  79539. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79540. */
  79541. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79542. /**
  79543. * Define this method to modify the default behavior when loading buffer views.
  79544. * @param context The context when loading the asset
  79545. * @param bufferView The glTF buffer view property
  79546. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79547. */
  79548. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79549. /**
  79550. * Define this method to modify the default behavior when loading buffers.
  79551. * @param context The context when loading the asset
  79552. * @param buffer The glTF buffer property
  79553. * @param byteOffset The byte offset to load
  79554. * @param byteLength The byte length to load
  79555. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79556. */
  79557. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79558. }
  79559. }
  79560. declare module BABYLON.GLTF2 {
  79561. /**
  79562. * Helper class for working with arrays when loading the glTF asset
  79563. */
  79564. export class ArrayItem {
  79565. /**
  79566. * Gets an item from the given array.
  79567. * @param context The context when loading the asset
  79568. * @param array The array to get the item from
  79569. * @param index The index to the array
  79570. * @returns The array item
  79571. */
  79572. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79573. /**
  79574. * Assign an `index` field to each item of the given array.
  79575. * @param array The array of items
  79576. */
  79577. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79578. }
  79579. /**
  79580. * The glTF 2.0 loader
  79581. */
  79582. export class GLTFLoader implements IGLTFLoader {
  79583. /** @hidden */
  79584. _completePromises: Promise<any>[];
  79585. /** @hidden */
  79586. _forAssetContainer: boolean;
  79587. /** Storage */
  79588. _babylonLights: Light[];
  79589. /** @hidden */
  79590. _disableInstancedMesh: number;
  79591. private _disposed;
  79592. private _parent;
  79593. private _state;
  79594. private _extensions;
  79595. private _rootUrl;
  79596. private _fileName;
  79597. private _uniqueRootUrl;
  79598. private _gltf;
  79599. private _bin;
  79600. private _babylonScene;
  79601. private _rootBabylonMesh;
  79602. private _defaultBabylonMaterialData;
  79603. private static _RegisteredExtensions;
  79604. /**
  79605. * The default glTF sampler.
  79606. */
  79607. static readonly DefaultSampler: ISampler;
  79608. /**
  79609. * Registers a loader extension.
  79610. * @param name The name of the loader extension.
  79611. * @param factory The factory function that creates the loader extension.
  79612. */
  79613. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79614. /**
  79615. * Unregisters a loader extension.
  79616. * @param name The name of the loader extension.
  79617. * @returns A boolean indicating whether the extension has been unregistered
  79618. */
  79619. static UnregisterExtension(name: string): boolean;
  79620. /**
  79621. * The loader state.
  79622. */
  79623. get state(): Nullable<GLTFLoaderState>;
  79624. /**
  79625. * The object that represents the glTF JSON.
  79626. */
  79627. get gltf(): IGLTF;
  79628. /**
  79629. * The BIN chunk of a binary glTF.
  79630. */
  79631. get bin(): Nullable<IDataBuffer>;
  79632. /**
  79633. * The parent file loader.
  79634. */
  79635. get parent(): GLTFFileLoader;
  79636. /**
  79637. * The Babylon scene when loading the asset.
  79638. */
  79639. get babylonScene(): Scene;
  79640. /**
  79641. * The root Babylon mesh when loading the asset.
  79642. */
  79643. get rootBabylonMesh(): Mesh;
  79644. /** @hidden */
  79645. constructor(parent: GLTFFileLoader);
  79646. /** @hidden */
  79647. dispose(): void;
  79648. /** @hidden */
  79649. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79650. /** @hidden */
  79651. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79652. private _loadAsync;
  79653. private _loadData;
  79654. private _setupData;
  79655. private _loadExtensions;
  79656. private _checkExtensions;
  79657. private _setState;
  79658. private _createRootNode;
  79659. /**
  79660. * Loads a glTF scene.
  79661. * @param context The context when loading the asset
  79662. * @param scene The glTF scene property
  79663. * @returns A promise that resolves when the load is complete
  79664. */
  79665. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79666. private _forEachPrimitive;
  79667. private _getMeshes;
  79668. private _getTransformNodes;
  79669. private _getSkeletons;
  79670. private _getAnimationGroups;
  79671. private _startAnimations;
  79672. /**
  79673. * Loads a glTF node.
  79674. * @param context The context when loading the asset
  79675. * @param node The glTF node property
  79676. * @param assign A function called synchronously after parsing the glTF properties
  79677. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79678. */
  79679. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79680. private _loadMeshAsync;
  79681. /**
  79682. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79683. * @param context The context when loading the asset
  79684. * @param name The mesh name when loading the asset
  79685. * @param node The glTF node when loading the asset
  79686. * @param mesh The glTF mesh when loading the asset
  79687. * @param primitive The glTF mesh primitive property
  79688. * @param assign A function called synchronously after parsing the glTF properties
  79689. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79690. */
  79691. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79692. private _loadVertexDataAsync;
  79693. private _createMorphTargets;
  79694. private _loadMorphTargetsAsync;
  79695. private _loadMorphTargetVertexDataAsync;
  79696. private static _LoadTransform;
  79697. private _loadSkinAsync;
  79698. private _loadBones;
  79699. private _loadBone;
  79700. private _loadSkinInverseBindMatricesDataAsync;
  79701. private _updateBoneMatrices;
  79702. private _getNodeMatrix;
  79703. /**
  79704. * Loads a glTF camera.
  79705. * @param context The context when loading the asset
  79706. * @param camera The glTF camera property
  79707. * @param assign A function called synchronously after parsing the glTF properties
  79708. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79709. */
  79710. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79711. private _loadAnimationsAsync;
  79712. /**
  79713. * Loads a glTF animation.
  79714. * @param context The context when loading the asset
  79715. * @param animation The glTF animation property
  79716. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79717. */
  79718. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79719. /**
  79720. * @hidden Loads a glTF animation channel.
  79721. * @param context The context when loading the asset
  79722. * @param animationContext The context of the animation when loading the asset
  79723. * @param animation The glTF animation property
  79724. * @param channel The glTF animation channel property
  79725. * @param babylonAnimationGroup The babylon animation group property
  79726. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79727. * @returns A void promise when the channel load is complete
  79728. */
  79729. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79730. private _loadAnimationSamplerAsync;
  79731. private _loadBufferAsync;
  79732. /**
  79733. * Loads a glTF buffer view.
  79734. * @param context The context when loading the asset
  79735. * @param bufferView The glTF buffer view property
  79736. * @returns A promise that resolves with the loaded data when the load is complete
  79737. */
  79738. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79739. private _loadAccessorAsync;
  79740. /** @hidden */
  79741. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79742. private _loadIndicesAccessorAsync;
  79743. private _loadVertexBufferViewAsync;
  79744. private _loadVertexAccessorAsync;
  79745. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79746. /** @hidden */
  79747. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79748. private _createDefaultMaterial;
  79749. /**
  79750. * Creates a Babylon material from a glTF material.
  79751. * @param context The context when loading the asset
  79752. * @param material The glTF material property
  79753. * @param babylonDrawMode The draw mode for the Babylon material
  79754. * @returns The Babylon material
  79755. */
  79756. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79757. /**
  79758. * Loads properties from a glTF material into a Babylon material.
  79759. * @param context The context when loading the asset
  79760. * @param material The glTF material property
  79761. * @param babylonMaterial The Babylon material
  79762. * @returns A promise that resolves when the load is complete
  79763. */
  79764. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79765. /**
  79766. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79767. * @param context The context when loading the asset
  79768. * @param material The glTF material property
  79769. * @param babylonMaterial The Babylon material
  79770. * @returns A promise that resolves when the load is complete
  79771. */
  79772. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79773. /**
  79774. * Loads the alpha properties from a glTF material into a Babylon material.
  79775. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79776. * @param context The context when loading the asset
  79777. * @param material The glTF material property
  79778. * @param babylonMaterial The Babylon material
  79779. */
  79780. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79781. /**
  79782. * Loads a glTF texture info.
  79783. * @param context The context when loading the asset
  79784. * @param textureInfo The glTF texture info property
  79785. * @param assign A function called synchronously after parsing the glTF properties
  79786. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79787. */
  79788. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79789. /** @hidden */
  79790. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79791. /** @hidden */
  79792. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79793. private _loadSampler;
  79794. /**
  79795. * Loads a glTF image.
  79796. * @param context The context when loading the asset
  79797. * @param image The glTF image property
  79798. * @returns A promise that resolves with the loaded data when the load is complete
  79799. */
  79800. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79801. /**
  79802. * Loads a glTF uri.
  79803. * @param context The context when loading the asset
  79804. * @param property The glTF property associated with the uri
  79805. * @param uri The base64 or relative uri
  79806. * @returns A promise that resolves with the loaded data when the load is complete
  79807. */
  79808. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79809. /**
  79810. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79811. * @param babylonObject the Babylon object with metadata
  79812. * @param pointer the JSON pointer
  79813. */
  79814. static AddPointerMetadata(babylonObject: {
  79815. metadata: any;
  79816. }, pointer: string): void;
  79817. private static _GetTextureWrapMode;
  79818. private static _GetTextureSamplingMode;
  79819. private static _GetTypedArrayConstructor;
  79820. private static _GetTypedArray;
  79821. private static _GetNumComponents;
  79822. private static _ValidateUri;
  79823. private static _GetDrawMode;
  79824. private _compileMaterialsAsync;
  79825. private _compileShadowGeneratorsAsync;
  79826. private _forEachExtensions;
  79827. private _applyExtensions;
  79828. private _extensionsOnLoading;
  79829. private _extensionsOnReady;
  79830. private _extensionsLoadSceneAsync;
  79831. private _extensionsLoadNodeAsync;
  79832. private _extensionsLoadCameraAsync;
  79833. private _extensionsLoadVertexDataAsync;
  79834. private _extensionsLoadMeshPrimitiveAsync;
  79835. private _extensionsLoadMaterialAsync;
  79836. private _extensionsCreateMaterial;
  79837. private _extensionsLoadMaterialPropertiesAsync;
  79838. private _extensionsLoadTextureInfoAsync;
  79839. private _extensionsLoadTextureAsync;
  79840. private _extensionsLoadAnimationAsync;
  79841. private _extensionsLoadSkinAsync;
  79842. private _extensionsLoadUriAsync;
  79843. private _extensionsLoadBufferViewAsync;
  79844. private _extensionsLoadBufferAsync;
  79845. /**
  79846. * Helper method called by a loader extension to load an glTF extension.
  79847. * @param context The context when loading the asset
  79848. * @param property The glTF property to load the extension from
  79849. * @param extensionName The name of the extension to load
  79850. * @param actionAsync The action to run
  79851. * @returns The promise returned by actionAsync or null if the extension does not exist
  79852. */
  79853. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79854. /**
  79855. * Helper method called by a loader extension to load a glTF extra.
  79856. * @param context The context when loading the asset
  79857. * @param property The glTF property to load the extra from
  79858. * @param extensionName The name of the extension to load
  79859. * @param actionAsync The action to run
  79860. * @returns The promise returned by actionAsync or null if the extra does not exist
  79861. */
  79862. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79863. /**
  79864. * Checks for presence of an extension.
  79865. * @param name The name of the extension to check
  79866. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79867. */
  79868. isExtensionUsed(name: string): boolean;
  79869. /**
  79870. * Increments the indentation level and logs a message.
  79871. * @param message The message to log
  79872. */
  79873. logOpen(message: string): void;
  79874. /**
  79875. * Decrements the indentation level.
  79876. */
  79877. logClose(): void;
  79878. /**
  79879. * Logs a message
  79880. * @param message The message to log
  79881. */
  79882. log(message: string): void;
  79883. /**
  79884. * Starts a performance counter.
  79885. * @param counterName The name of the performance counter
  79886. */
  79887. startPerformanceCounter(counterName: string): void;
  79888. /**
  79889. * Ends a performance counter.
  79890. * @param counterName The name of the performance counter
  79891. */
  79892. endPerformanceCounter(counterName: string): void;
  79893. }
  79894. }
  79895. declare module BABYLON.GLTF2.Loader.Extensions {
  79896. /**
  79897. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79898. */
  79899. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79900. /**
  79901. * The name of this extension.
  79902. */
  79903. readonly name: string;
  79904. /**
  79905. * Defines whether this extension is enabled.
  79906. */
  79907. enabled: boolean;
  79908. private _loader;
  79909. private _lights?;
  79910. /** @hidden */
  79911. constructor(loader: GLTFLoader);
  79912. /** @hidden */
  79913. dispose(): void;
  79914. /** @hidden */
  79915. onLoading(): void;
  79916. /** @hidden */
  79917. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79918. private _loadLightAsync;
  79919. }
  79920. }
  79921. declare module BABYLON.GLTF2.Loader.Extensions {
  79922. /**
  79923. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79924. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79925. * !!! Experimental Extension Subject to Changes !!!
  79926. */
  79927. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79928. /**
  79929. * The name of this extension.
  79930. */
  79931. readonly name: string;
  79932. /**
  79933. * Defines whether this extension is enabled.
  79934. */
  79935. enabled: boolean;
  79936. private _loader;
  79937. /** @hidden */
  79938. constructor(loader: GLTFLoader);
  79939. /** @hidden */
  79940. dispose(): void;
  79941. /** @hidden */
  79942. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79943. }
  79944. }
  79945. declare module BABYLON.GLTF2.Loader.Extensions {
  79946. /**
  79947. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79948. */
  79949. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79950. /**
  79951. * The name of this extension.
  79952. */
  79953. readonly name: string;
  79954. /**
  79955. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79956. */
  79957. dracoCompression?: DracoCompression;
  79958. /**
  79959. * Defines whether this extension is enabled.
  79960. */
  79961. enabled: boolean;
  79962. private _loader;
  79963. /** @hidden */
  79964. constructor(loader: GLTFLoader);
  79965. /** @hidden */
  79966. dispose(): void;
  79967. /** @hidden */
  79968. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79969. }
  79970. }
  79971. declare module BABYLON.GLTF2.Loader.Extensions {
  79972. /**
  79973. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79974. */
  79975. export class KHR_lights implements IGLTFLoaderExtension {
  79976. /**
  79977. * The name of this extension.
  79978. */
  79979. readonly name: string;
  79980. /**
  79981. * Defines whether this extension is enabled.
  79982. */
  79983. enabled: boolean;
  79984. private _loader;
  79985. private _lights?;
  79986. /** @hidden */
  79987. constructor(loader: GLTFLoader);
  79988. /** @hidden */
  79989. dispose(): void;
  79990. /** @hidden */
  79991. onLoading(): void;
  79992. /** @hidden */
  79993. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79994. }
  79995. }
  79996. declare module BABYLON.GLTF2.Loader.Extensions {
  79997. /**
  79998. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79999. */
  80000. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80001. /**
  80002. * The name of this extension.
  80003. */
  80004. readonly name: string;
  80005. /**
  80006. * Defines whether this extension is enabled.
  80007. */
  80008. enabled: boolean;
  80009. /**
  80010. * Defines a number that determines the order the extensions are applied.
  80011. */
  80012. order: number;
  80013. private _loader;
  80014. /** @hidden */
  80015. constructor(loader: GLTFLoader);
  80016. /** @hidden */
  80017. dispose(): void;
  80018. /** @hidden */
  80019. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80020. private _loadSpecularGlossinessPropertiesAsync;
  80021. }
  80022. }
  80023. declare module BABYLON.GLTF2.Loader.Extensions {
  80024. /**
  80025. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80026. */
  80027. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80028. /**
  80029. * The name of this extension.
  80030. */
  80031. readonly name: string;
  80032. /**
  80033. * Defines whether this extension is enabled.
  80034. */
  80035. enabled: boolean;
  80036. /**
  80037. * Defines a number that determines the order the extensions are applied.
  80038. */
  80039. order: number;
  80040. private _loader;
  80041. /** @hidden */
  80042. constructor(loader: GLTFLoader);
  80043. /** @hidden */
  80044. dispose(): void;
  80045. /** @hidden */
  80046. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80047. private _loadUnlitPropertiesAsync;
  80048. }
  80049. }
  80050. declare module BABYLON.GLTF2.Loader.Extensions {
  80051. /**
  80052. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80053. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80054. * !!! Experimental Extension Subject to Changes !!!
  80055. */
  80056. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80057. /**
  80058. * The name of this extension.
  80059. */
  80060. readonly name: string;
  80061. /**
  80062. * Defines whether this extension is enabled.
  80063. */
  80064. enabled: boolean;
  80065. /**
  80066. * Defines a number that determines the order the extensions are applied.
  80067. */
  80068. order: number;
  80069. private _loader;
  80070. /** @hidden */
  80071. constructor(loader: GLTFLoader);
  80072. /** @hidden */
  80073. dispose(): void;
  80074. /** @hidden */
  80075. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80076. private _loadClearCoatPropertiesAsync;
  80077. }
  80078. }
  80079. declare module BABYLON.GLTF2.Loader.Extensions {
  80080. /**
  80081. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80082. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80083. * !!! Experimental Extension Subject to Changes !!!
  80084. */
  80085. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80086. /**
  80087. * The name of this extension.
  80088. */
  80089. readonly name: string;
  80090. /**
  80091. * Defines whether this extension is enabled.
  80092. */
  80093. enabled: boolean;
  80094. /**
  80095. * Defines a number that determines the order the extensions are applied.
  80096. */
  80097. order: number;
  80098. private _loader;
  80099. /** @hidden */
  80100. constructor(loader: GLTFLoader);
  80101. /** @hidden */
  80102. dispose(): void;
  80103. /** @hidden */
  80104. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80105. private _loadSheenPropertiesAsync;
  80106. }
  80107. }
  80108. declare module BABYLON.GLTF2.Loader.Extensions {
  80109. /**
  80110. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80111. * !!! Experimental Extension Subject to Changes !!!
  80112. */
  80113. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80114. /**
  80115. * The name of this extension.
  80116. */
  80117. readonly name: string;
  80118. /**
  80119. * Defines whether this extension is enabled.
  80120. */
  80121. enabled: boolean;
  80122. /**
  80123. * Defines a number that determines the order the extensions are applied.
  80124. */
  80125. order: number;
  80126. private _loader;
  80127. /** @hidden */
  80128. constructor(loader: GLTFLoader);
  80129. /** @hidden */
  80130. dispose(): void;
  80131. /** @hidden */
  80132. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80133. private _loadSpecularPropertiesAsync;
  80134. }
  80135. }
  80136. declare module BABYLON.GLTF2.Loader.Extensions {
  80137. /**
  80138. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80139. * !!! Experimental Extension Subject to Changes !!!
  80140. */
  80141. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80142. /**
  80143. * Default ior Value from the spec.
  80144. */
  80145. private static readonly _DEFAULT_IOR;
  80146. /**
  80147. * The name of this extension.
  80148. */
  80149. readonly name: string;
  80150. /**
  80151. * Defines whether this extension is enabled.
  80152. */
  80153. enabled: boolean;
  80154. /**
  80155. * Defines a number that determines the order the extensions are applied.
  80156. */
  80157. order: number;
  80158. private _loader;
  80159. /** @hidden */
  80160. constructor(loader: GLTFLoader);
  80161. /** @hidden */
  80162. dispose(): void;
  80163. /** @hidden */
  80164. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80165. private _loadIorPropertiesAsync;
  80166. }
  80167. }
  80168. declare module BABYLON.GLTF2.Loader.Extensions {
  80169. /**
  80170. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80171. * !!! Experimental Extension Subject to Changes !!!
  80172. */
  80173. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80174. /**
  80175. * The name of this extension.
  80176. */
  80177. readonly name: string;
  80178. /**
  80179. * Defines whether this extension is enabled.
  80180. */
  80181. enabled: boolean;
  80182. private _loader;
  80183. /**
  80184. * The default variant name.
  80185. */
  80186. defaultVariant: string | undefined;
  80187. private _tagsToMap;
  80188. /** @hidden */
  80189. constructor(loader: GLTFLoader);
  80190. /** @hidden */
  80191. dispose(): void;
  80192. /**
  80193. * Return a list of available variants for this asset.
  80194. * @returns {string[]}
  80195. */
  80196. getVariants(): string[];
  80197. /**
  80198. * Select a variant by providing a list of variant tag names.
  80199. *
  80200. * @param {(string | string[])} variantName
  80201. */
  80202. selectVariant(variantName: string | string[]): void;
  80203. /**
  80204. * Select a variant by providing a single variant tag.
  80205. *
  80206. * @param {string} variantName
  80207. */
  80208. selectVariantTag(variantName: string): void;
  80209. /** @hidden */
  80210. onLoading(): void;
  80211. /** @hidden */
  80212. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80213. }
  80214. }
  80215. declare module BABYLON.GLTF2.Loader.Extensions {
  80216. /**
  80217. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80218. * !!! Experimental Extension Subject to Changes !!!
  80219. */
  80220. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80221. /**
  80222. * The name of this extension.
  80223. */
  80224. readonly name: string;
  80225. /**
  80226. * Defines whether this extension is enabled.
  80227. */
  80228. enabled: boolean;
  80229. /**
  80230. * Defines a number that determines the order the extensions are applied.
  80231. */
  80232. order: number;
  80233. private _loader;
  80234. /** @hidden */
  80235. constructor(loader: GLTFLoader);
  80236. /** @hidden */
  80237. dispose(): void;
  80238. /** @hidden */
  80239. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80240. private _loadTransparentPropertiesAsync;
  80241. }
  80242. }
  80243. declare module BABYLON.GLTF2.Loader.Extensions {
  80244. /**
  80245. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80246. */
  80247. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80248. /**
  80249. * The name of this extension.
  80250. */
  80251. readonly name: string;
  80252. /**
  80253. * Defines whether this extension is enabled.
  80254. */
  80255. enabled: boolean;
  80256. /** @hidden */
  80257. constructor(loader: GLTFLoader);
  80258. /** @hidden */
  80259. dispose(): void;
  80260. }
  80261. }
  80262. declare module BABYLON.GLTF2.Loader.Extensions {
  80263. /**
  80264. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80265. * !!! Experimental Extension Subject to Changes !!!
  80266. */
  80267. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80268. /** The name of this extension. */
  80269. readonly name: string;
  80270. /** Defines whether this extension is enabled. */
  80271. enabled: boolean;
  80272. private _loader;
  80273. /** @hidden */
  80274. constructor(loader: GLTFLoader);
  80275. /** @hidden */
  80276. dispose(): void;
  80277. /** @hidden */
  80278. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80279. }
  80280. }
  80281. declare module BABYLON.GLTF2.Loader.Extensions {
  80282. /**
  80283. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80284. */
  80285. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80286. /**
  80287. * The name of this extension.
  80288. */
  80289. readonly name: string;
  80290. /**
  80291. * Defines whether this extension is enabled.
  80292. */
  80293. enabled: boolean;
  80294. private _loader;
  80295. /** @hidden */
  80296. constructor(loader: GLTFLoader);
  80297. /** @hidden */
  80298. dispose(): void;
  80299. /** @hidden */
  80300. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80301. }
  80302. }
  80303. declare module BABYLON.GLTF2.Loader.Extensions {
  80304. /**
  80305. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80306. * !!! Experimental Extension Subject to Changes !!!
  80307. */
  80308. export class KHR_xmp implements IGLTFLoaderExtension {
  80309. /**
  80310. * The name of this extension.
  80311. */
  80312. readonly name: string;
  80313. /**
  80314. * Defines whether this extension is enabled.
  80315. */
  80316. enabled: boolean;
  80317. /**
  80318. * Defines a number that determines the order the extensions are applied.
  80319. */
  80320. order: number;
  80321. private _loader;
  80322. /** @hidden */
  80323. constructor(loader: GLTFLoader);
  80324. /** @hidden */
  80325. dispose(): void;
  80326. /**
  80327. * Called after the loader state changes to LOADING.
  80328. */
  80329. onLoading(): void;
  80330. }
  80331. }
  80332. declare module BABYLON.GLTF2.Loader.Extensions {
  80333. /**
  80334. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80335. */
  80336. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80337. /**
  80338. * The name of this extension.
  80339. */
  80340. readonly name: string;
  80341. /**
  80342. * Defines whether this extension is enabled.
  80343. */
  80344. enabled: boolean;
  80345. private _loader;
  80346. private _clips;
  80347. private _emitters;
  80348. /** @hidden */
  80349. constructor(loader: GLTFLoader);
  80350. /** @hidden */
  80351. dispose(): void;
  80352. /** @hidden */
  80353. onLoading(): void;
  80354. /** @hidden */
  80355. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80356. /** @hidden */
  80357. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80358. /** @hidden */
  80359. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80360. private _loadClipAsync;
  80361. private _loadEmitterAsync;
  80362. private _getEventAction;
  80363. private _loadAnimationEventAsync;
  80364. }
  80365. }
  80366. declare module BABYLON.GLTF2.Loader.Extensions {
  80367. /**
  80368. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80369. */
  80370. export class MSFT_lod implements IGLTFLoaderExtension {
  80371. /**
  80372. * The name of this extension.
  80373. */
  80374. readonly name: string;
  80375. /**
  80376. * Defines whether this extension is enabled.
  80377. */
  80378. enabled: boolean;
  80379. /**
  80380. * Defines a number that determines the order the extensions are applied.
  80381. */
  80382. order: number;
  80383. /**
  80384. * Maximum number of LODs to load, starting from the lowest LOD.
  80385. */
  80386. maxLODsToLoad: number;
  80387. /**
  80388. * Observable raised when all node LODs of one level are loaded.
  80389. * The event data is the index of the loaded LOD starting from zero.
  80390. * Dispose the loader to cancel the loading of the next level of LODs.
  80391. */
  80392. onNodeLODsLoadedObservable: Observable<number>;
  80393. /**
  80394. * Observable raised when all material LODs of one level are loaded.
  80395. * The event data is the index of the loaded LOD starting from zero.
  80396. * Dispose the loader to cancel the loading of the next level of LODs.
  80397. */
  80398. onMaterialLODsLoadedObservable: Observable<number>;
  80399. private _loader;
  80400. private _bufferLODs;
  80401. private _nodeIndexLOD;
  80402. private _nodeSignalLODs;
  80403. private _nodePromiseLODs;
  80404. private _nodeBufferLODs;
  80405. private _materialIndexLOD;
  80406. private _materialSignalLODs;
  80407. private _materialPromiseLODs;
  80408. private _materialBufferLODs;
  80409. /** @hidden */
  80410. constructor(loader: GLTFLoader);
  80411. /** @hidden */
  80412. dispose(): void;
  80413. /** @hidden */
  80414. onReady(): void;
  80415. /** @hidden */
  80416. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80417. /** @hidden */
  80418. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80419. /** @hidden */
  80420. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80421. /** @hidden */
  80422. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80423. /** @hidden */
  80424. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80425. private _loadBufferLOD;
  80426. /**
  80427. * Gets an array of LOD properties from lowest to highest.
  80428. */
  80429. private _getLODs;
  80430. private _disposeTransformNode;
  80431. private _disposeMaterials;
  80432. }
  80433. }
  80434. declare module BABYLON.GLTF2.Loader.Extensions {
  80435. /** @hidden */
  80436. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80437. readonly name: string;
  80438. enabled: boolean;
  80439. private _loader;
  80440. constructor(loader: GLTFLoader);
  80441. dispose(): void;
  80442. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80443. }
  80444. }
  80445. declare module BABYLON.GLTF2.Loader.Extensions {
  80446. /** @hidden */
  80447. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80448. readonly name: string;
  80449. enabled: boolean;
  80450. private _loader;
  80451. constructor(loader: GLTFLoader);
  80452. dispose(): void;
  80453. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80454. }
  80455. }
  80456. declare module BABYLON.GLTF2.Loader.Extensions {
  80457. /**
  80458. * Store glTF extras (if present) in BJS objects' metadata
  80459. */
  80460. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80461. /**
  80462. * The name of this extension.
  80463. */
  80464. readonly name: string;
  80465. /**
  80466. * Defines whether this extension is enabled.
  80467. */
  80468. enabled: boolean;
  80469. private _loader;
  80470. private _assignExtras;
  80471. /** @hidden */
  80472. constructor(loader: GLTFLoader);
  80473. /** @hidden */
  80474. dispose(): void;
  80475. /** @hidden */
  80476. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80477. /** @hidden */
  80478. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80479. /** @hidden */
  80480. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80481. }
  80482. }
  80483. declare module BABYLON {
  80484. /**
  80485. * Class reading and parsing the MTL file bundled with the obj file.
  80486. */
  80487. export class MTLFileLoader {
  80488. /**
  80489. * Invert Y-Axis of referenced textures on load
  80490. */
  80491. static INVERT_TEXTURE_Y: boolean;
  80492. /**
  80493. * All material loaded from the mtl will be set here
  80494. */
  80495. materials: StandardMaterial[];
  80496. /**
  80497. * This function will read the mtl file and create each material described inside
  80498. * This function could be improve by adding :
  80499. * -some component missing (Ni, Tf...)
  80500. * -including the specific options available
  80501. *
  80502. * @param scene defines the scene the material will be created in
  80503. * @param data defines the mtl data to parse
  80504. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80505. * @param forAssetContainer defines if the material should be registered in the scene
  80506. */
  80507. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80508. /**
  80509. * Gets the texture for the material.
  80510. *
  80511. * If the material is imported from input file,
  80512. * We sanitize the url to ensure it takes the textre from aside the material.
  80513. *
  80514. * @param rootUrl The root url to load from
  80515. * @param value The value stored in the mtl
  80516. * @return The Texture
  80517. */
  80518. private static _getTexture;
  80519. }
  80520. }
  80521. declare module BABYLON {
  80522. /**
  80523. * Options for loading OBJ/MTL files
  80524. */
  80525. type MeshLoadOptions = {
  80526. /**
  80527. * Defines if UVs are optimized by default during load.
  80528. */
  80529. OptimizeWithUV: boolean;
  80530. /**
  80531. * Defines custom scaling of UV coordinates of loaded meshes.
  80532. */
  80533. UVScaling: Vector2;
  80534. /**
  80535. * Invert model on y-axis (does a model scaling inversion)
  80536. */
  80537. InvertY: boolean;
  80538. /**
  80539. * Invert Y-Axis of referenced textures on load
  80540. */
  80541. InvertTextureY: boolean;
  80542. /**
  80543. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80544. */
  80545. ImportVertexColors: boolean;
  80546. /**
  80547. * Compute the normals for the model, even if normals are present in the file.
  80548. */
  80549. ComputeNormals: boolean;
  80550. /**
  80551. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80552. */
  80553. SkipMaterials: boolean;
  80554. /**
  80555. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80556. */
  80557. MaterialLoadingFailsSilently: boolean;
  80558. };
  80559. /**
  80560. * OBJ file type loader.
  80561. * This is a babylon scene loader plugin.
  80562. */
  80563. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80564. /**
  80565. * Defines if UVs are optimized by default during load.
  80566. */
  80567. static OPTIMIZE_WITH_UV: boolean;
  80568. /**
  80569. * Invert model on y-axis (does a model scaling inversion)
  80570. */
  80571. static INVERT_Y: boolean;
  80572. /**
  80573. * Invert Y-Axis of referenced textures on load
  80574. */
  80575. static get INVERT_TEXTURE_Y(): boolean;
  80576. static set INVERT_TEXTURE_Y(value: boolean);
  80577. /**
  80578. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80579. */
  80580. static IMPORT_VERTEX_COLORS: boolean;
  80581. /**
  80582. * Compute the normals for the model, even if normals are present in the file.
  80583. */
  80584. static COMPUTE_NORMALS: boolean;
  80585. /**
  80586. * Defines custom scaling of UV coordinates of loaded meshes.
  80587. */
  80588. static UV_SCALING: Vector2;
  80589. /**
  80590. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80591. */
  80592. static SKIP_MATERIALS: boolean;
  80593. /**
  80594. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80595. *
  80596. * Defaults to true for backwards compatibility.
  80597. */
  80598. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80599. /**
  80600. * Defines the name of the plugin.
  80601. */
  80602. name: string;
  80603. /**
  80604. * Defines the extension the plugin is able to load.
  80605. */
  80606. extensions: string;
  80607. /** @hidden */
  80608. obj: RegExp;
  80609. /** @hidden */
  80610. group: RegExp;
  80611. /** @hidden */
  80612. mtllib: RegExp;
  80613. /** @hidden */
  80614. usemtl: RegExp;
  80615. /** @hidden */
  80616. smooth: RegExp;
  80617. /** @hidden */
  80618. vertexPattern: RegExp;
  80619. /** @hidden */
  80620. normalPattern: RegExp;
  80621. /** @hidden */
  80622. uvPattern: RegExp;
  80623. /** @hidden */
  80624. facePattern1: RegExp;
  80625. /** @hidden */
  80626. facePattern2: RegExp;
  80627. /** @hidden */
  80628. facePattern3: RegExp;
  80629. /** @hidden */
  80630. facePattern4: RegExp;
  80631. /** @hidden */
  80632. facePattern5: RegExp;
  80633. private _forAssetContainer;
  80634. private _meshLoadOptions;
  80635. /**
  80636. * Creates loader for .OBJ files
  80637. *
  80638. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80639. */
  80640. constructor(meshLoadOptions?: MeshLoadOptions);
  80641. private static get currentMeshLoadOptions();
  80642. /**
  80643. * Calls synchronously the MTL file attached to this obj.
  80644. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80645. * Without this function materials are not displayed in the first frame (but displayed after).
  80646. * In consequence it is impossible to get material information in your HTML file
  80647. *
  80648. * @param url The URL of the MTL file
  80649. * @param rootUrl
  80650. * @param onSuccess Callback function to be called when the MTL file is loaded
  80651. * @private
  80652. */
  80653. private _loadMTL;
  80654. /**
  80655. * Instantiates a OBJ file loader plugin.
  80656. * @returns the created plugin
  80657. */
  80658. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80659. /**
  80660. * If the data string can be loaded directly.
  80661. *
  80662. * @param data string containing the file data
  80663. * @returns if the data can be loaded directly
  80664. */
  80665. canDirectLoad(data: string): boolean;
  80666. /**
  80667. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80668. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80669. * @param scene the scene the meshes should be added to
  80670. * @param data the OBJ data to load
  80671. * @param rootUrl root url to load from
  80672. * @param onProgress event that fires when loading progress has occured
  80673. * @param fileName Defines the name of the file to load
  80674. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80675. */
  80676. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80677. meshes: AbstractMesh[];
  80678. particleSystems: IParticleSystem[];
  80679. skeletons: Skeleton[];
  80680. animationGroups: AnimationGroup[];
  80681. }>;
  80682. /**
  80683. * Imports all objects from the loaded OBJ data and adds them to the scene
  80684. * @param scene the scene the objects should be added to
  80685. * @param data the OBJ data to load
  80686. * @param rootUrl root url to load from
  80687. * @param onProgress event that fires when loading progress has occured
  80688. * @param fileName Defines the name of the file to load
  80689. * @returns a promise which completes when objects have been loaded to the scene
  80690. */
  80691. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80692. /**
  80693. * Load into an asset container.
  80694. * @param scene The scene to load into
  80695. * @param data The data to import
  80696. * @param rootUrl The root url for scene and resources
  80697. * @param onProgress The callback when the load progresses
  80698. * @param fileName Defines the name of the file to load
  80699. * @returns The loaded asset container
  80700. */
  80701. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80702. /**
  80703. * Read the OBJ file and create an Array of meshes.
  80704. * Each mesh contains all information given by the OBJ and the MTL file.
  80705. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80706. *
  80707. * @param meshesNames
  80708. * @param scene Scene The scene where are displayed the data
  80709. * @param data String The content of the obj file
  80710. * @param rootUrl String The path to the folder
  80711. * @returns Array<AbstractMesh>
  80712. * @private
  80713. */
  80714. private _parseSolid;
  80715. }
  80716. }
  80717. declare module BABYLON {
  80718. /**
  80719. * STL file type loader.
  80720. * This is a babylon scene loader plugin.
  80721. */
  80722. export class STLFileLoader implements ISceneLoaderPlugin {
  80723. /** @hidden */
  80724. solidPattern: RegExp;
  80725. /** @hidden */
  80726. facetsPattern: RegExp;
  80727. /** @hidden */
  80728. normalPattern: RegExp;
  80729. /** @hidden */
  80730. vertexPattern: RegExp;
  80731. /**
  80732. * Defines the name of the plugin.
  80733. */
  80734. name: string;
  80735. /**
  80736. * Defines the extensions the stl loader is able to load.
  80737. * force data to come in as an ArrayBuffer
  80738. * we'll convert to string if it looks like it's an ASCII .stl
  80739. */
  80740. extensions: ISceneLoaderPluginExtensions;
  80741. /**
  80742. * Import meshes into a scene.
  80743. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80744. * @param scene The scene to import into
  80745. * @param data The data to import
  80746. * @param rootUrl The root url for scene and resources
  80747. * @param meshes The meshes array to import into
  80748. * @param particleSystems The particle systems array to import into
  80749. * @param skeletons The skeletons array to import into
  80750. * @param onError The callback when import fails
  80751. * @returns True if successful or false otherwise
  80752. */
  80753. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80754. /**
  80755. * Load into a scene.
  80756. * @param scene The scene to load into
  80757. * @param data The data to import
  80758. * @param rootUrl The root url for scene and resources
  80759. * @param onError The callback when import fails
  80760. * @returns true if successful or false otherwise
  80761. */
  80762. load(scene: Scene, data: any, rootUrl: string): boolean;
  80763. /**
  80764. * Load into an asset container.
  80765. * @param scene The scene to load into
  80766. * @param data The data to import
  80767. * @param rootUrl The root url for scene and resources
  80768. * @param onError The callback when import fails
  80769. * @returns The loaded asset container
  80770. */
  80771. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80772. private _isBinary;
  80773. private _parseBinary;
  80774. private _parseASCII;
  80775. }
  80776. }
  80777. declare module BABYLON {
  80778. /**
  80779. * Class for generating OBJ data from a Babylon scene.
  80780. */
  80781. export class OBJExport {
  80782. /**
  80783. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80784. * @param mesh defines the list of meshes to serialize
  80785. * @param materials defines if materials should be exported
  80786. * @param matlibname defines the name of the associated mtl file
  80787. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80788. * @returns the OBJ content
  80789. */
  80790. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80791. /**
  80792. * Exports the material(s) of a mesh in .MTL file format (text)
  80793. * @param mesh defines the mesh to extract the material from
  80794. * @returns the mtl content
  80795. */
  80796. static MTL(mesh: Mesh): string;
  80797. }
  80798. }
  80799. declare module BABYLON {
  80800. /** @hidden */
  80801. export var __IGLTFExporterExtension: number;
  80802. /**
  80803. * Interface for extending the exporter
  80804. * @hidden
  80805. */
  80806. export interface IGLTFExporterExtension {
  80807. /**
  80808. * The name of this extension
  80809. */
  80810. readonly name: string;
  80811. /**
  80812. * Defines whether this extension is enabled
  80813. */
  80814. enabled: boolean;
  80815. /**
  80816. * Defines whether this extension is required
  80817. */
  80818. required: boolean;
  80819. }
  80820. }
  80821. declare module BABYLON.GLTF2.Exporter {
  80822. /** @hidden */
  80823. export var __IGLTFExporterExtensionV2: number;
  80824. /**
  80825. * Interface for a glTF exporter extension
  80826. * @hidden
  80827. */
  80828. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80829. /**
  80830. * Define this method to modify the default behavior before exporting a texture
  80831. * @param context The context when loading the asset
  80832. * @param babylonTexture The Babylon.js texture
  80833. * @param mimeType The mime-type of the generated image
  80834. * @returns A promise that resolves with the exported texture
  80835. */
  80836. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80837. /**
  80838. * Define this method to get notified when a texture info is created
  80839. * @param context The context when loading the asset
  80840. * @param textureInfo The glTF texture info
  80841. * @param babylonTexture The Babylon.js texture
  80842. */
  80843. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80844. /**
  80845. * Define this method to modify the default behavior when exporting texture info
  80846. * @param context The context when loading the asset
  80847. * @param meshPrimitive glTF mesh primitive
  80848. * @param babylonSubMesh Babylon submesh
  80849. * @param binaryWriter glTF serializer binary writer instance
  80850. * @returns nullable IMeshPrimitive promise
  80851. */
  80852. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80853. /**
  80854. * Define this method to modify the default behavior when exporting a node
  80855. * @param context The context when exporting the node
  80856. * @param node glTF node
  80857. * @param babylonNode BabylonJS node
  80858. * @returns nullable INode promise
  80859. */
  80860. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80861. [key: number]: number;
  80862. }): Promise<Nullable<INode>>;
  80863. /**
  80864. * Define this method to modify the default behavior when exporting a material
  80865. * @param material glTF material
  80866. * @param babylonMaterial BabylonJS material
  80867. * @returns nullable IMaterial promise
  80868. */
  80869. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80870. /**
  80871. * Define this method to return additional textures to export from a material
  80872. * @param material glTF material
  80873. * @param babylonMaterial BabylonJS material
  80874. * @returns List of textures
  80875. */
  80876. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80877. /** Gets a boolean indicating that this extension was used */
  80878. wasUsed: boolean;
  80879. /** Gets a boolean indicating that this extension is required for the file to work */
  80880. required: boolean;
  80881. /**
  80882. * Called after the exporter state changes to EXPORTING
  80883. */
  80884. onExporting?(): void;
  80885. }
  80886. }
  80887. declare module BABYLON.GLTF2.Exporter {
  80888. /**
  80889. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80890. * @hidden
  80891. */
  80892. export class _GLTFMaterialExporter {
  80893. /**
  80894. * Represents the dielectric specular values for R, G and B
  80895. */
  80896. private static readonly _DielectricSpecular;
  80897. /**
  80898. * Allows the maximum specular power to be defined for material calculations
  80899. */
  80900. private static readonly _MaxSpecularPower;
  80901. /**
  80902. * Mapping to store textures
  80903. */
  80904. private _textureMap;
  80905. /**
  80906. * Numeric tolerance value
  80907. */
  80908. private static readonly _Epsilon;
  80909. /**
  80910. * Reference to the glTF Exporter
  80911. */
  80912. private _exporter;
  80913. constructor(exporter: _Exporter);
  80914. /**
  80915. * Specifies if two colors are approximately equal in value
  80916. * @param color1 first color to compare to
  80917. * @param color2 second color to compare to
  80918. * @param epsilon threshold value
  80919. */
  80920. private static FuzzyEquals;
  80921. /**
  80922. * Gets the materials from a Babylon scene and converts them to glTF materials
  80923. * @param scene babylonjs scene
  80924. * @param mimeType texture mime type
  80925. * @param images array of images
  80926. * @param textures array of textures
  80927. * @param materials array of materials
  80928. * @param imageData mapping of texture names to base64 textures
  80929. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80930. */
  80931. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80932. /**
  80933. * Makes a copy of the glTF material without the texture parameters
  80934. * @param originalMaterial original glTF material
  80935. * @returns glTF material without texture parameters
  80936. */
  80937. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80938. /**
  80939. * Specifies if the material has any texture parameters present
  80940. * @param material glTF Material
  80941. * @returns boolean specifying if texture parameters are present
  80942. */
  80943. _hasTexturesPresent(material: IMaterial): boolean;
  80944. /**
  80945. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80946. * @param babylonStandardMaterial
  80947. * @returns glTF Metallic Roughness Material representation
  80948. */
  80949. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80950. /**
  80951. * Computes the metallic factor
  80952. * @param diffuse diffused value
  80953. * @param specular specular value
  80954. * @param oneMinusSpecularStrength one minus the specular strength
  80955. * @returns metallic value
  80956. */
  80957. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80958. /**
  80959. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80960. * @param glTFMaterial glTF material
  80961. * @param babylonMaterial Babylon material
  80962. */
  80963. private static _SetAlphaMode;
  80964. /**
  80965. * Converts a Babylon Standard Material to a glTF Material
  80966. * @param babylonStandardMaterial BJS Standard Material
  80967. * @param mimeType mime type to use for the textures
  80968. * @param images array of glTF image interfaces
  80969. * @param textures array of glTF texture interfaces
  80970. * @param materials array of glTF material interfaces
  80971. * @param imageData map of image file name to data
  80972. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80973. */
  80974. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80975. private _finishMaterial;
  80976. /**
  80977. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80978. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80979. * @param mimeType mime type to use for the textures
  80980. * @param images array of glTF image interfaces
  80981. * @param textures array of glTF texture interfaces
  80982. * @param materials array of glTF material interfaces
  80983. * @param imageData map of image file name to data
  80984. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80985. */
  80986. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80987. /**
  80988. * Converts an image typed array buffer to a base64 image
  80989. * @param buffer typed array buffer
  80990. * @param width width of the image
  80991. * @param height height of the image
  80992. * @param mimeType mimetype of the image
  80993. * @returns base64 image string
  80994. */
  80995. private _createBase64FromCanvasAsync;
  80996. /**
  80997. * Generates a white texture based on the specified width and height
  80998. * @param width width of the texture in pixels
  80999. * @param height height of the texture in pixels
  81000. * @param scene babylonjs scene
  81001. * @returns white texture
  81002. */
  81003. private _createWhiteTexture;
  81004. /**
  81005. * 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
  81006. * @param texture1 first texture to resize
  81007. * @param texture2 second texture to resize
  81008. * @param scene babylonjs scene
  81009. * @returns resized textures or null
  81010. */
  81011. private _resizeTexturesToSameDimensions;
  81012. /**
  81013. * Converts an array of pixels to a Float32Array
  81014. * Throws an error if the pixel format is not supported
  81015. * @param pixels - array buffer containing pixel values
  81016. * @returns Float32 of pixels
  81017. */
  81018. private _convertPixelArrayToFloat32;
  81019. /**
  81020. * Convert Specular Glossiness Textures to Metallic Roughness
  81021. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81022. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81023. * @param diffuseTexture texture used to store diffuse information
  81024. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81025. * @param factors specular glossiness material factors
  81026. * @param mimeType the mime type to use for the texture
  81027. * @returns pbr metallic roughness interface or null
  81028. */
  81029. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81030. /**
  81031. * Converts specular glossiness material properties to metallic roughness
  81032. * @param specularGlossiness interface with specular glossiness material properties
  81033. * @returns interface with metallic roughness material properties
  81034. */
  81035. private _convertSpecularGlossinessToMetallicRoughness;
  81036. /**
  81037. * Calculates the surface reflectance, independent of lighting conditions
  81038. * @param color Color source to calculate brightness from
  81039. * @returns number representing the perceived brightness, or zero if color is undefined
  81040. */
  81041. private _getPerceivedBrightness;
  81042. /**
  81043. * Returns the maximum color component value
  81044. * @param color
  81045. * @returns maximum color component value, or zero if color is null or undefined
  81046. */
  81047. private _getMaxComponent;
  81048. /**
  81049. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81050. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81051. * @param mimeType mime type to use for the textures
  81052. * @param images array of glTF image interfaces
  81053. * @param textures array of glTF texture interfaces
  81054. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81055. * @param imageData map of image file name to data
  81056. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81057. * @returns glTF PBR Metallic Roughness factors
  81058. */
  81059. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81060. private _getGLTFTextureSampler;
  81061. private _getGLTFTextureWrapMode;
  81062. private _getGLTFTextureWrapModesSampler;
  81063. /**
  81064. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81065. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81066. * @param mimeType mime type to use for the textures
  81067. * @param images array of glTF image interfaces
  81068. * @param textures array of glTF texture interfaces
  81069. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81070. * @param imageData map of image file name to data
  81071. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81072. * @returns glTF PBR Metallic Roughness factors
  81073. */
  81074. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81075. /**
  81076. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81077. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81078. * @param mimeType mime type to use for the textures
  81079. * @param images array of glTF image interfaces
  81080. * @param textures array of glTF texture interfaces
  81081. * @param materials array of glTF material interfaces
  81082. * @param imageData map of image file name to data
  81083. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81084. */
  81085. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81086. private setMetallicRoughnessPbrMaterial;
  81087. private getPixelsFromTexture;
  81088. /**
  81089. * Extracts a texture from a Babylon texture into file data and glTF data
  81090. * @param babylonTexture Babylon texture to extract
  81091. * @param mimeType Mime Type of the babylonTexture
  81092. * @return glTF texture info, or null if the texture format is not supported
  81093. */
  81094. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81095. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81096. /**
  81097. * Builds a texture from base64 string
  81098. * @param base64Texture base64 texture string
  81099. * @param baseTextureName Name to use for the texture
  81100. * @param mimeType image mime type for the texture
  81101. * @param images array of images
  81102. * @param textures array of textures
  81103. * @param imageData map of image data
  81104. * @returns glTF texture info, or null if the texture format is not supported
  81105. */
  81106. private _getTextureInfoFromBase64;
  81107. }
  81108. }
  81109. declare module BABYLON {
  81110. /**
  81111. * Class for holding and downloading glTF file data
  81112. */
  81113. export class GLTFData {
  81114. /**
  81115. * Object which contains the file name as the key and its data as the value
  81116. */
  81117. glTFFiles: {
  81118. [fileName: string]: string | Blob;
  81119. };
  81120. /**
  81121. * Initializes the glTF file object
  81122. */
  81123. constructor();
  81124. /**
  81125. * Downloads the glTF data as files based on their names and data
  81126. */
  81127. downloadFiles(): void;
  81128. }
  81129. }
  81130. declare module BABYLON {
  81131. /**
  81132. * Holds a collection of exporter options and parameters
  81133. */
  81134. export interface IExportOptions {
  81135. /**
  81136. * Function which indicates whether a babylon node should be exported or not
  81137. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81138. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81139. */
  81140. shouldExportNode?(node: Node): boolean;
  81141. /**
  81142. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81143. * @param metadata source metadata to read from
  81144. * @returns the data to store to glTF node extras
  81145. */
  81146. metadataSelector?(metadata: any): any;
  81147. /**
  81148. * The sample rate to bake animation curves
  81149. */
  81150. animationSampleRate?: number;
  81151. /**
  81152. * Begin serialization without waiting for the scene to be ready
  81153. */
  81154. exportWithoutWaitingForScene?: boolean;
  81155. /**
  81156. * Indicates if coordinate system swapping root nodes should be included in export
  81157. */
  81158. includeCoordinateSystemConversionNodes?: boolean;
  81159. }
  81160. /**
  81161. * Class for generating glTF data from a Babylon scene.
  81162. */
  81163. export class GLTF2Export {
  81164. /**
  81165. * Exports the geometry of the scene to .gltf file format asynchronously
  81166. * @param scene Babylon scene with scene hierarchy information
  81167. * @param filePrefix File prefix to use when generating the glTF file
  81168. * @param options Exporter options
  81169. * @returns Returns an object with a .gltf file and associates texture names
  81170. * as keys and their data and paths as values
  81171. */
  81172. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81173. private static _PreExportAsync;
  81174. private static _PostExportAsync;
  81175. /**
  81176. * Exports the geometry of the scene to .glb file format asychronously
  81177. * @param scene Babylon scene with scene hierarchy information
  81178. * @param filePrefix File prefix to use when generating glb file
  81179. * @param options Exporter options
  81180. * @returns Returns an object with a .glb filename as key and data as value
  81181. */
  81182. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81183. }
  81184. }
  81185. declare module BABYLON.GLTF2.Exporter {
  81186. /**
  81187. * @hidden
  81188. */
  81189. export class _GLTFUtilities {
  81190. /**
  81191. * Creates a buffer view based on the supplied arguments
  81192. * @param bufferIndex index value of the specified buffer
  81193. * @param byteOffset byte offset value
  81194. * @param byteLength byte length of the bufferView
  81195. * @param byteStride byte distance between conequential elements
  81196. * @param name name of the buffer view
  81197. * @returns bufferView for glTF
  81198. */
  81199. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81200. /**
  81201. * Creates an accessor based on the supplied arguments
  81202. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81203. * @param name The name of the accessor
  81204. * @param type The type of the accessor
  81205. * @param componentType The datatype of components in the attribute
  81206. * @param count The number of attributes referenced by this accessor
  81207. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81208. * @param min Minimum value of each component in this attribute
  81209. * @param max Maximum value of each component in this attribute
  81210. * @returns accessor for glTF
  81211. */
  81212. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81213. /**
  81214. * Calculates the minimum and maximum values of an array of position floats
  81215. * @param positions Positions array of a mesh
  81216. * @param vertexStart Starting vertex offset to calculate min and max values
  81217. * @param vertexCount Number of vertices to check for min and max values
  81218. * @returns min number array and max number array
  81219. */
  81220. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81221. min: number[];
  81222. max: number[];
  81223. };
  81224. /**
  81225. * Converts a new right-handed Vector3
  81226. * @param vector vector3 array
  81227. * @returns right-handed Vector3
  81228. */
  81229. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81230. /**
  81231. * Converts a Vector3 to right-handed
  81232. * @param vector Vector3 to convert to right-handed
  81233. */
  81234. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81235. /**
  81236. * Converts a three element number array to right-handed
  81237. * @param vector number array to convert to right-handed
  81238. */
  81239. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81240. /**
  81241. * Converts a new right-handed Vector3
  81242. * @param vector vector3 array
  81243. * @returns right-handed Vector3
  81244. */
  81245. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81246. /**
  81247. * Converts a Vector3 to right-handed
  81248. * @param vector Vector3 to convert to right-handed
  81249. */
  81250. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81251. /**
  81252. * Converts a three element number array to right-handed
  81253. * @param vector number array to convert to right-handed
  81254. */
  81255. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81256. /**
  81257. * Converts a Vector4 to right-handed
  81258. * @param vector Vector4 to convert to right-handed
  81259. */
  81260. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81261. /**
  81262. * Converts a Vector4 to right-handed
  81263. * @param vector Vector4 to convert to right-handed
  81264. */
  81265. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81266. /**
  81267. * Converts a Quaternion to right-handed
  81268. * @param quaternion Source quaternion to convert to right-handed
  81269. */
  81270. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81271. /**
  81272. * Converts a Quaternion to right-handed
  81273. * @param quaternion Source quaternion to convert to right-handed
  81274. */
  81275. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81276. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81277. }
  81278. }
  81279. declare module BABYLON.GLTF2.Exporter {
  81280. /**
  81281. * Converts Babylon Scene into glTF 2.0.
  81282. * @hidden
  81283. */
  81284. export class _Exporter {
  81285. /**
  81286. * Stores the glTF to export
  81287. */
  81288. _glTF: IGLTF;
  81289. /**
  81290. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81291. */
  81292. _bufferViews: IBufferView[];
  81293. /**
  81294. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81295. */
  81296. _accessors: IAccessor[];
  81297. /**
  81298. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81299. */
  81300. _nodes: INode[];
  81301. /**
  81302. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81303. */
  81304. private _scenes;
  81305. /**
  81306. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81307. */
  81308. private _meshes;
  81309. /**
  81310. * Stores all the generated material information, which represents the appearance of each primitive
  81311. */
  81312. _materials: IMaterial[];
  81313. _materialMap: {
  81314. [materialID: number]: number;
  81315. };
  81316. /**
  81317. * Stores all the generated texture information, which is referenced by glTF materials
  81318. */
  81319. _textures: ITexture[];
  81320. /**
  81321. * Stores all the generated image information, which is referenced by glTF textures
  81322. */
  81323. _images: IImage[];
  81324. /**
  81325. * Stores all the texture samplers
  81326. */
  81327. _samplers: ISampler[];
  81328. /**
  81329. * Stores all the generated animation samplers, which is referenced by glTF animations
  81330. */
  81331. /**
  81332. * Stores the animations for glTF models
  81333. */
  81334. private _animations;
  81335. /**
  81336. * Stores the total amount of bytes stored in the glTF buffer
  81337. */
  81338. private _totalByteLength;
  81339. /**
  81340. * Stores a reference to the Babylon scene containing the source geometry and material information
  81341. */
  81342. _babylonScene: Scene;
  81343. /**
  81344. * Stores a map of the image data, where the key is the file name and the value
  81345. * is the image data
  81346. */
  81347. _imageData: {
  81348. [fileName: string]: {
  81349. data: Uint8Array;
  81350. mimeType: ImageMimeType;
  81351. };
  81352. };
  81353. /**
  81354. * Stores a map of the unique id of a node to its index in the node array
  81355. */
  81356. _nodeMap: {
  81357. [key: number]: number;
  81358. };
  81359. /**
  81360. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81361. */
  81362. _convertToRightHandedSystem: boolean;
  81363. /**
  81364. * Specifies if a Babylon node should be converted to right-handed on export
  81365. */
  81366. _convertToRightHandedSystemMap: {
  81367. [nodeId: number]: boolean;
  81368. };
  81369. _includeCoordinateSystemConversionNodes: boolean;
  81370. /**
  81371. * Baked animation sample rate
  81372. */
  81373. private _animationSampleRate;
  81374. private _options;
  81375. private _localEngine;
  81376. _glTFMaterialExporter: _GLTFMaterialExporter;
  81377. private _extensions;
  81378. private static _ExtensionNames;
  81379. private static _ExtensionFactories;
  81380. private _applyExtension;
  81381. private _applyExtensions;
  81382. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81383. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81384. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81385. [key: number]: number;
  81386. }): Promise<Nullable<INode>>;
  81387. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81388. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81389. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81390. private _forEachExtensions;
  81391. private _extensionsOnExporting;
  81392. /**
  81393. * Load glTF serializer extensions
  81394. */
  81395. private _loadExtensions;
  81396. /**
  81397. * Creates a glTF Exporter instance, which can accept optional exporter options
  81398. * @param babylonScene Babylon scene object
  81399. * @param options Options to modify the behavior of the exporter
  81400. */
  81401. constructor(babylonScene: Scene, options?: IExportOptions);
  81402. dispose(): void;
  81403. /**
  81404. * Registers a glTF exporter extension
  81405. * @param name Name of the extension to export
  81406. * @param factory The factory function that creates the exporter extension
  81407. */
  81408. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81409. /**
  81410. * Un-registers an exporter extension
  81411. * @param name The name fo the exporter extension
  81412. * @returns A boolean indicating whether the extension has been un-registered
  81413. */
  81414. static UnregisterExtension(name: string): boolean;
  81415. /**
  81416. * Lazy load a local engine
  81417. */
  81418. _getLocalEngine(): Engine;
  81419. private reorderIndicesBasedOnPrimitiveMode;
  81420. /**
  81421. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81422. * clock-wise during export to glTF
  81423. * @param submesh BabylonJS submesh
  81424. * @param primitiveMode Primitive mode of the mesh
  81425. * @param sideOrientation the winding order of the submesh
  81426. * @param vertexBufferKind The type of vertex attribute
  81427. * @param meshAttributeArray The vertex attribute data
  81428. * @param byteOffset The offset to the binary data
  81429. * @param binaryWriter The binary data for the glTF file
  81430. * @param convertToRightHandedSystem Converts the values to right-handed
  81431. */
  81432. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81433. /**
  81434. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81435. * clock-wise during export to glTF
  81436. * @param submesh BabylonJS submesh
  81437. * @param primitiveMode Primitive mode of the mesh
  81438. * @param sideOrientation the winding order of the submesh
  81439. * @param vertexBufferKind The type of vertex attribute
  81440. * @param meshAttributeArray The vertex attribute data
  81441. * @param byteOffset The offset to the binary data
  81442. * @param binaryWriter The binary data for the glTF file
  81443. * @param convertToRightHandedSystem Converts the values to right-handed
  81444. */
  81445. private reorderTriangleFillMode;
  81446. /**
  81447. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81448. * clock-wise during export to glTF
  81449. * @param submesh BabylonJS submesh
  81450. * @param primitiveMode Primitive mode of the mesh
  81451. * @param sideOrientation the winding order of the submesh
  81452. * @param vertexBufferKind The type of vertex attribute
  81453. * @param meshAttributeArray The vertex attribute data
  81454. * @param byteOffset The offset to the binary data
  81455. * @param binaryWriter The binary data for the glTF file
  81456. * @param convertToRightHandedSystem Converts the values to right-handed
  81457. */
  81458. private reorderTriangleStripDrawMode;
  81459. /**
  81460. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81461. * clock-wise during export to glTF
  81462. * @param submesh BabylonJS submesh
  81463. * @param primitiveMode Primitive mode of the mesh
  81464. * @param sideOrientation the winding order of the submesh
  81465. * @param vertexBufferKind The type of vertex attribute
  81466. * @param meshAttributeArray The vertex attribute data
  81467. * @param byteOffset The offset to the binary data
  81468. * @param binaryWriter The binary data for the glTF file
  81469. * @param convertToRightHandedSystem Converts the values to right-handed
  81470. */
  81471. private reorderTriangleFanMode;
  81472. /**
  81473. * Writes the vertex attribute data to binary
  81474. * @param vertices The vertices to write to the binary writer
  81475. * @param byteOffset The offset into the binary writer to overwrite binary data
  81476. * @param vertexAttributeKind The vertex attribute type
  81477. * @param meshAttributeArray The vertex attribute data
  81478. * @param binaryWriter The writer containing the binary data
  81479. * @param convertToRightHandedSystem Converts the values to right-handed
  81480. */
  81481. private writeVertexAttributeData;
  81482. /**
  81483. * Writes mesh attribute data to a data buffer
  81484. * Returns the bytelength of the data
  81485. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81486. * @param meshAttributeArray Array containing the attribute data
  81487. * @param binaryWriter The buffer to write the binary data to
  81488. * @param indices Used to specify the order of the vertex data
  81489. * @param convertToRightHandedSystem Converts the values to right-handed
  81490. */
  81491. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81492. /**
  81493. * Generates glTF json data
  81494. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81495. * @param glTFPrefix Text to use when prefixing a glTF file
  81496. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81497. * @returns json data as string
  81498. */
  81499. private generateJSON;
  81500. /**
  81501. * Generates data for .gltf and .bin files based on the glTF prefix string
  81502. * @param glTFPrefix Text to use when prefixing a glTF file
  81503. * @param dispose Dispose the exporter
  81504. * @returns GLTFData with glTF file data
  81505. */
  81506. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81507. /**
  81508. * Creates a binary buffer for glTF
  81509. * @returns array buffer for binary data
  81510. */
  81511. private _generateBinaryAsync;
  81512. /**
  81513. * Pads the number to a multiple of 4
  81514. * @param num number to pad
  81515. * @returns padded number
  81516. */
  81517. private _getPadding;
  81518. /**
  81519. * @hidden
  81520. */
  81521. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81522. /**
  81523. * Sets the TRS for each node
  81524. * @param node glTF Node for storing the transformation data
  81525. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  81526. * @param convertToRightHandedSystem Converts the values to right-handed
  81527. */
  81528. private setNodeTransformation;
  81529. private getVertexBufferFromMesh;
  81530. /**
  81531. * Creates a bufferview based on the vertices type for the Babylon mesh
  81532. * @param kind Indicates the type of vertices data
  81533. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  81534. * @param binaryWriter The buffer to write the bufferview data to
  81535. * @param convertToRightHandedSystem Converts the values to right-handed
  81536. */
  81537. private createBufferViewKind;
  81538. /**
  81539. * The primitive mode of the Babylon mesh
  81540. * @param babylonMesh The BabylonJS mesh
  81541. */
  81542. private getMeshPrimitiveMode;
  81543. /**
  81544. * Sets the primitive mode of the glTF mesh primitive
  81545. * @param meshPrimitive glTF mesh primitive
  81546. * @param primitiveMode The primitive mode
  81547. */
  81548. private setPrimitiveMode;
  81549. /**
  81550. * Sets the vertex attribute accessor based of the glTF mesh primitive
  81551. * @param meshPrimitive glTF mesh primitive
  81552. * @param attributeKind vertex attribute
  81553. * @returns boolean specifying if uv coordinates are present
  81554. */
  81555. private setAttributeKind;
  81556. /**
  81557. * Sets data for the primitive attributes of each submesh
  81558. * @param mesh glTF Mesh object to store the primitive attribute information
  81559. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  81560. * @param binaryWriter Buffer to write the attribute data to
  81561. * @param convertToRightHandedSystem Converts the values to right-handed
  81562. */
  81563. private setPrimitiveAttributesAsync;
  81564. /**
  81565. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  81566. * @param node The node to check
  81567. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81568. */
  81569. private isBabylonCoordinateSystemConvertingNode;
  81570. /**
  81571. * Creates a glTF scene based on the array of meshes
  81572. * Returns the the total byte offset
  81573. * @param babylonScene Babylon scene to get the mesh data from
  81574. * @param binaryWriter Buffer to write binary data to
  81575. */
  81576. private createSceneAsync;
  81577. /**
  81578. * Creates a mapping of Node unique id to node index and handles animations
  81579. * @param babylonScene Babylon Scene
  81580. * @param nodes Babylon transform nodes
  81581. * @param binaryWriter Buffer to write binary data to
  81582. * @returns Node mapping of unique id to index
  81583. */
  81584. private createNodeMapAndAnimationsAsync;
  81585. /**
  81586. * Creates a glTF node from a Babylon mesh
  81587. * @param babylonMesh Source Babylon mesh
  81588. * @param binaryWriter Buffer for storing geometry data
  81589. * @param convertToRightHandedSystem Converts the values to right-handed
  81590. * @param nodeMap Node mapping of unique id to glTF node index
  81591. * @returns glTF node
  81592. */
  81593. private createNodeAsync;
  81594. }
  81595. /**
  81596. * @hidden
  81597. *
  81598. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81599. */
  81600. export class _BinaryWriter {
  81601. /**
  81602. * Array buffer which stores all binary data
  81603. */
  81604. private _arrayBuffer;
  81605. /**
  81606. * View of the array buffer
  81607. */
  81608. private _dataView;
  81609. /**
  81610. * byte offset of data in array buffer
  81611. */
  81612. private _byteOffset;
  81613. /**
  81614. * Initialize binary writer with an initial byte length
  81615. * @param byteLength Initial byte length of the array buffer
  81616. */
  81617. constructor(byteLength: number);
  81618. /**
  81619. * Resize the array buffer to the specified byte length
  81620. * @param byteLength
  81621. */
  81622. private resizeBuffer;
  81623. /**
  81624. * Get an array buffer with the length of the byte offset
  81625. * @returns ArrayBuffer resized to the byte offset
  81626. */
  81627. getArrayBuffer(): ArrayBuffer;
  81628. /**
  81629. * Get the byte offset of the array buffer
  81630. * @returns byte offset
  81631. */
  81632. getByteOffset(): number;
  81633. /**
  81634. * Stores an UInt8 in the array buffer
  81635. * @param entry
  81636. * @param byteOffset If defined, specifies where to set the value as an offset.
  81637. */
  81638. setUInt8(entry: number, byteOffset?: number): void;
  81639. /**
  81640. * Gets an UInt32 in the array buffer
  81641. * @param entry
  81642. * @param byteOffset If defined, specifies where to set the value as an offset.
  81643. */
  81644. getUInt32(byteOffset: number): number;
  81645. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81646. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81647. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81648. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81649. /**
  81650. * Stores a Float32 in the array buffer
  81651. * @param entry
  81652. */
  81653. setFloat32(entry: number, byteOffset?: number): void;
  81654. /**
  81655. * Stores an UInt32 in the array buffer
  81656. * @param entry
  81657. * @param byteOffset If defined, specifies where to set the value as an offset.
  81658. */
  81659. setUInt32(entry: number, byteOffset?: number): void;
  81660. }
  81661. }
  81662. declare module BABYLON.GLTF2.Exporter {
  81663. /**
  81664. * @hidden
  81665. * Interface to store animation data.
  81666. */
  81667. export interface _IAnimationData {
  81668. /**
  81669. * Keyframe data.
  81670. */
  81671. inputs: number[];
  81672. /**
  81673. * Value data.
  81674. */
  81675. outputs: number[][];
  81676. /**
  81677. * Animation interpolation data.
  81678. */
  81679. samplerInterpolation: AnimationSamplerInterpolation;
  81680. /**
  81681. * Minimum keyframe value.
  81682. */
  81683. inputsMin: number;
  81684. /**
  81685. * Maximum keyframe value.
  81686. */
  81687. inputsMax: number;
  81688. }
  81689. /**
  81690. * @hidden
  81691. */
  81692. export interface _IAnimationInfo {
  81693. /**
  81694. * The target channel for the animation
  81695. */
  81696. animationChannelTargetPath: AnimationChannelTargetPath;
  81697. /**
  81698. * The glTF accessor type for the data.
  81699. */
  81700. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81701. /**
  81702. * Specifies if quaternions should be used.
  81703. */
  81704. useQuaternion: boolean;
  81705. }
  81706. /**
  81707. * @hidden
  81708. * Utility class for generating glTF animation data from BabylonJS.
  81709. */
  81710. export class _GLTFAnimation {
  81711. /**
  81712. * @ignore
  81713. *
  81714. * Creates glTF channel animation from BabylonJS animation.
  81715. * @param babylonTransformNode - BabylonJS mesh.
  81716. * @param animation - animation.
  81717. * @param animationChannelTargetPath - The target animation channel.
  81718. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81719. * @param useQuaternion - Specifies if quaternions are used.
  81720. * @returns nullable IAnimationData
  81721. */
  81722. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81723. private static _DeduceAnimationInfo;
  81724. /**
  81725. * @ignore
  81726. * Create node animations from the transform node animations
  81727. * @param babylonNode
  81728. * @param runtimeGLTFAnimation
  81729. * @param idleGLTFAnimations
  81730. * @param nodeMap
  81731. * @param nodes
  81732. * @param binaryWriter
  81733. * @param bufferViews
  81734. * @param accessors
  81735. * @param convertToRightHandedSystem
  81736. * @param animationSampleRate
  81737. */
  81738. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81739. [key: number]: number;
  81740. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81741. /**
  81742. * @ignore
  81743. * Create node animations from the animation groups
  81744. * @param babylonScene
  81745. * @param glTFAnimations
  81746. * @param nodeMap
  81747. * @param nodes
  81748. * @param binaryWriter
  81749. * @param bufferViews
  81750. * @param accessors
  81751. * @param convertToRightHandedSystemMap
  81752. * @param animationSampleRate
  81753. */
  81754. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81755. [key: number]: number;
  81756. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81757. [nodeId: number]: boolean;
  81758. }, animationSampleRate: number): void;
  81759. private static AddAnimation;
  81760. /**
  81761. * Create a baked animation
  81762. * @param babylonTransformNode BabylonJS mesh
  81763. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81764. * @param animationChannelTargetPath animation target channel
  81765. * @param minFrame minimum animation frame
  81766. * @param maxFrame maximum animation frame
  81767. * @param fps frames per second of the animation
  81768. * @param inputs input key frames of the animation
  81769. * @param outputs output key frame data of the animation
  81770. * @param convertToRightHandedSystem converts the values to right-handed
  81771. * @param useQuaternion specifies if quaternions should be used
  81772. */
  81773. private static _CreateBakedAnimation;
  81774. private static _ConvertFactorToVector3OrQuaternion;
  81775. private static _SetInterpolatedValue;
  81776. /**
  81777. * Creates linear animation from the animation key frames
  81778. * @param babylonTransformNode BabylonJS mesh
  81779. * @param animation BabylonJS animation
  81780. * @param animationChannelTargetPath The target animation channel
  81781. * @param frameDelta The difference between the last and first frame of the animation
  81782. * @param inputs Array to store the key frame times
  81783. * @param outputs Array to store the key frame data
  81784. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81785. * @param useQuaternion Specifies if quaternions are used in the animation
  81786. */
  81787. private static _CreateLinearOrStepAnimation;
  81788. /**
  81789. * Creates cubic spline animation from the animation key frames
  81790. * @param babylonTransformNode BabylonJS mesh
  81791. * @param animation BabylonJS animation
  81792. * @param animationChannelTargetPath The target animation channel
  81793. * @param frameDelta The difference between the last and first frame of the animation
  81794. * @param inputs Array to store the key frame times
  81795. * @param outputs Array to store the key frame data
  81796. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81797. * @param useQuaternion Specifies if quaternions are used in the animation
  81798. */
  81799. private static _CreateCubicSplineAnimation;
  81800. private static _GetBasePositionRotationOrScale;
  81801. /**
  81802. * Adds a key frame value
  81803. * @param keyFrame
  81804. * @param animation
  81805. * @param outputs
  81806. * @param animationChannelTargetPath
  81807. * @param basePositionRotationOrScale
  81808. * @param convertToRightHandedSystem
  81809. * @param useQuaternion
  81810. */
  81811. private static _AddKeyframeValue;
  81812. /**
  81813. * Determine the interpolation based on the key frames
  81814. * @param keyFrames
  81815. * @param animationChannelTargetPath
  81816. * @param useQuaternion
  81817. */
  81818. private static _DeduceInterpolation;
  81819. /**
  81820. * Adds an input tangent or output tangent to the output data
  81821. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81822. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81823. * @param outputs The animation data by keyframe
  81824. * @param animationChannelTargetPath The target animation channel
  81825. * @param interpolation The interpolation type
  81826. * @param keyFrame The key frame with the animation data
  81827. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81828. * @param useQuaternion Specifies if quaternions are used
  81829. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81830. */
  81831. private static AddSplineTangent;
  81832. /**
  81833. * Get the minimum and maximum key frames' frame values
  81834. * @param keyFrames animation key frames
  81835. * @returns the minimum and maximum key frame value
  81836. */
  81837. private static calculateMinMaxKeyFrames;
  81838. }
  81839. }
  81840. declare module BABYLON.GLTF2.Exporter {
  81841. /** @hidden */
  81842. export var textureTransformPixelShader: {
  81843. name: string;
  81844. shader: string;
  81845. };
  81846. }
  81847. declare module BABYLON.GLTF2.Exporter.Extensions {
  81848. /**
  81849. * @hidden
  81850. */
  81851. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81852. private _recordedTextures;
  81853. /** Name of this extension */
  81854. readonly name: string;
  81855. /** Defines whether this extension is enabled */
  81856. enabled: boolean;
  81857. /** Defines whether this extension is required */
  81858. required: boolean;
  81859. /** Reference to the glTF exporter */
  81860. private _wasUsed;
  81861. constructor(exporter: _Exporter);
  81862. dispose(): void;
  81863. /** @hidden */
  81864. get wasUsed(): boolean;
  81865. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81866. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81867. /**
  81868. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81869. * @param babylonTexture
  81870. * @param offset
  81871. * @param rotation
  81872. * @param scale
  81873. * @param scene
  81874. */
  81875. private _textureTransformTextureAsync;
  81876. }
  81877. }
  81878. declare module BABYLON.GLTF2.Exporter.Extensions {
  81879. /**
  81880. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81881. */
  81882. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81883. /** The name of this extension. */
  81884. readonly name: string;
  81885. /** Defines whether this extension is enabled. */
  81886. enabled: boolean;
  81887. /** Defines whether this extension is required */
  81888. required: boolean;
  81889. /** Reference to the glTF exporter */
  81890. private _exporter;
  81891. private _lights;
  81892. /** @hidden */
  81893. constructor(exporter: _Exporter);
  81894. /** @hidden */
  81895. dispose(): void;
  81896. /** @hidden */
  81897. get wasUsed(): boolean;
  81898. /** @hidden */
  81899. onExporting(): void;
  81900. /**
  81901. * Define this method to modify the default behavior when exporting a node
  81902. * @param context The context when exporting the node
  81903. * @param node glTF node
  81904. * @param babylonNode BabylonJS node
  81905. * @param nodeMap Node mapping of unique id to glTF node index
  81906. * @returns nullable INode promise
  81907. */
  81908. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81909. [key: number]: number;
  81910. }): Promise<Nullable<INode>>;
  81911. }
  81912. }
  81913. declare module BABYLON.GLTF2.Exporter.Extensions {
  81914. /**
  81915. * @hidden
  81916. */
  81917. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81918. /** Name of this extension */
  81919. readonly name: string;
  81920. /** Defines whether this extension is enabled */
  81921. enabled: boolean;
  81922. /** Defines whether this extension is required */
  81923. required: boolean;
  81924. /** Reference to the glTF exporter */
  81925. private _textureInfos;
  81926. private _exportedTextures;
  81927. private _wasUsed;
  81928. constructor(exporter: _Exporter);
  81929. dispose(): void;
  81930. /** @hidden */
  81931. get wasUsed(): boolean;
  81932. private _getTextureIndex;
  81933. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81934. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81935. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81936. }
  81937. }
  81938. declare module BABYLON {
  81939. /**
  81940. * Class for generating STL data from a Babylon scene.
  81941. */
  81942. export class STLExport {
  81943. /**
  81944. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81945. * @param meshes list defines the mesh to serialize
  81946. * @param download triggers the automatic download of the file.
  81947. * @param fileName changes the downloads fileName.
  81948. * @param binary changes the STL to a binary type.
  81949. * @param isLittleEndian toggle for binary type exporter.
  81950. * @returns the STL as UTF8 string
  81951. */
  81952. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81953. }
  81954. }
  81955. declare module "babylonjs-gltf2interface" {
  81956. export = BABYLON.GLTF2;
  81957. }
  81958. /**
  81959. * Module for glTF 2.0 Interface
  81960. */
  81961. declare module BABYLON.GLTF2 {
  81962. /**
  81963. * The datatype of the components in the attribute
  81964. */
  81965. const enum AccessorComponentType {
  81966. /**
  81967. * Byte
  81968. */
  81969. BYTE = 5120,
  81970. /**
  81971. * Unsigned Byte
  81972. */
  81973. UNSIGNED_BYTE = 5121,
  81974. /**
  81975. * Short
  81976. */
  81977. SHORT = 5122,
  81978. /**
  81979. * Unsigned Short
  81980. */
  81981. UNSIGNED_SHORT = 5123,
  81982. /**
  81983. * Unsigned Int
  81984. */
  81985. UNSIGNED_INT = 5125,
  81986. /**
  81987. * Float
  81988. */
  81989. FLOAT = 5126,
  81990. }
  81991. /**
  81992. * Specifies if the attirbute is a scalar, vector, or matrix
  81993. */
  81994. const enum AccessorType {
  81995. /**
  81996. * Scalar
  81997. */
  81998. SCALAR = "SCALAR",
  81999. /**
  82000. * Vector2
  82001. */
  82002. VEC2 = "VEC2",
  82003. /**
  82004. * Vector3
  82005. */
  82006. VEC3 = "VEC3",
  82007. /**
  82008. * Vector4
  82009. */
  82010. VEC4 = "VEC4",
  82011. /**
  82012. * Matrix2x2
  82013. */
  82014. MAT2 = "MAT2",
  82015. /**
  82016. * Matrix3x3
  82017. */
  82018. MAT3 = "MAT3",
  82019. /**
  82020. * Matrix4x4
  82021. */
  82022. MAT4 = "MAT4",
  82023. }
  82024. /**
  82025. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82026. */
  82027. const enum AnimationChannelTargetPath {
  82028. /**
  82029. * Translation
  82030. */
  82031. TRANSLATION = "translation",
  82032. /**
  82033. * Rotation
  82034. */
  82035. ROTATION = "rotation",
  82036. /**
  82037. * Scale
  82038. */
  82039. SCALE = "scale",
  82040. /**
  82041. * Weights
  82042. */
  82043. WEIGHTS = "weights",
  82044. }
  82045. /**
  82046. * Interpolation algorithm
  82047. */
  82048. const enum AnimationSamplerInterpolation {
  82049. /**
  82050. * The animated values are linearly interpolated between keyframes
  82051. */
  82052. LINEAR = "LINEAR",
  82053. /**
  82054. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82055. */
  82056. STEP = "STEP",
  82057. /**
  82058. * The animation's interpolation is computed using a cubic spline with specified tangents
  82059. */
  82060. CUBICSPLINE = "CUBICSPLINE",
  82061. }
  82062. /**
  82063. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82064. */
  82065. const enum CameraType {
  82066. /**
  82067. * A perspective camera containing properties to create a perspective projection matrix
  82068. */
  82069. PERSPECTIVE = "perspective",
  82070. /**
  82071. * An orthographic camera containing properties to create an orthographic projection matrix
  82072. */
  82073. ORTHOGRAPHIC = "orthographic",
  82074. }
  82075. /**
  82076. * The mime-type of the image
  82077. */
  82078. const enum ImageMimeType {
  82079. /**
  82080. * JPEG Mime-type
  82081. */
  82082. JPEG = "image/jpeg",
  82083. /**
  82084. * PNG Mime-type
  82085. */
  82086. PNG = "image/png",
  82087. }
  82088. /**
  82089. * The alpha rendering mode of the material
  82090. */
  82091. const enum MaterialAlphaMode {
  82092. /**
  82093. * The alpha value is ignored and the rendered output is fully opaque
  82094. */
  82095. OPAQUE = "OPAQUE",
  82096. /**
  82097. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82098. */
  82099. MASK = "MASK",
  82100. /**
  82101. * 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)
  82102. */
  82103. BLEND = "BLEND",
  82104. }
  82105. /**
  82106. * The type of the primitives to render
  82107. */
  82108. const enum MeshPrimitiveMode {
  82109. /**
  82110. * Points
  82111. */
  82112. POINTS = 0,
  82113. /**
  82114. * Lines
  82115. */
  82116. LINES = 1,
  82117. /**
  82118. * Line Loop
  82119. */
  82120. LINE_LOOP = 2,
  82121. /**
  82122. * Line Strip
  82123. */
  82124. LINE_STRIP = 3,
  82125. /**
  82126. * Triangles
  82127. */
  82128. TRIANGLES = 4,
  82129. /**
  82130. * Triangle Strip
  82131. */
  82132. TRIANGLE_STRIP = 5,
  82133. /**
  82134. * Triangle Fan
  82135. */
  82136. TRIANGLE_FAN = 6,
  82137. }
  82138. /**
  82139. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82140. */
  82141. const enum TextureMagFilter {
  82142. /**
  82143. * Nearest
  82144. */
  82145. NEAREST = 9728,
  82146. /**
  82147. * Linear
  82148. */
  82149. LINEAR = 9729,
  82150. }
  82151. /**
  82152. * Minification filter. All valid values correspond to WebGL enums
  82153. */
  82154. const enum TextureMinFilter {
  82155. /**
  82156. * Nearest
  82157. */
  82158. NEAREST = 9728,
  82159. /**
  82160. * Linear
  82161. */
  82162. LINEAR = 9729,
  82163. /**
  82164. * Nearest Mip-Map Nearest
  82165. */
  82166. NEAREST_MIPMAP_NEAREST = 9984,
  82167. /**
  82168. * Linear Mipmap Nearest
  82169. */
  82170. LINEAR_MIPMAP_NEAREST = 9985,
  82171. /**
  82172. * Nearest Mipmap Linear
  82173. */
  82174. NEAREST_MIPMAP_LINEAR = 9986,
  82175. /**
  82176. * Linear Mipmap Linear
  82177. */
  82178. LINEAR_MIPMAP_LINEAR = 9987,
  82179. }
  82180. /**
  82181. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82182. */
  82183. const enum TextureWrapMode {
  82184. /**
  82185. * Clamp to Edge
  82186. */
  82187. CLAMP_TO_EDGE = 33071,
  82188. /**
  82189. * Mirrored Repeat
  82190. */
  82191. MIRRORED_REPEAT = 33648,
  82192. /**
  82193. * Repeat
  82194. */
  82195. REPEAT = 10497,
  82196. }
  82197. /**
  82198. * glTF Property
  82199. */
  82200. interface IProperty {
  82201. /**
  82202. * Dictionary object with extension-specific objects
  82203. */
  82204. extensions?: {
  82205. [key: string]: any;
  82206. };
  82207. /**
  82208. * Application-Specific data
  82209. */
  82210. extras?: any;
  82211. }
  82212. /**
  82213. * glTF Child of Root Property
  82214. */
  82215. interface IChildRootProperty extends IProperty {
  82216. /**
  82217. * The user-defined name of this object
  82218. */
  82219. name?: string;
  82220. }
  82221. /**
  82222. * Indices of those attributes that deviate from their initialization value
  82223. */
  82224. interface IAccessorSparseIndices extends IProperty {
  82225. /**
  82226. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82227. */
  82228. bufferView: number;
  82229. /**
  82230. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82231. */
  82232. byteOffset?: number;
  82233. /**
  82234. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82235. */
  82236. componentType: AccessorComponentType;
  82237. }
  82238. /**
  82239. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82240. */
  82241. interface IAccessorSparseValues extends IProperty {
  82242. /**
  82243. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82244. */
  82245. bufferView: number;
  82246. /**
  82247. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82248. */
  82249. byteOffset?: number;
  82250. }
  82251. /**
  82252. * Sparse storage of attributes that deviate from their initialization value
  82253. */
  82254. interface IAccessorSparse extends IProperty {
  82255. /**
  82256. * The number of attributes encoded in this sparse accessor
  82257. */
  82258. count: number;
  82259. /**
  82260. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82261. */
  82262. indices: IAccessorSparseIndices;
  82263. /**
  82264. * 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
  82265. */
  82266. values: IAccessorSparseValues;
  82267. }
  82268. /**
  82269. * 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
  82270. */
  82271. interface IAccessor extends IChildRootProperty {
  82272. /**
  82273. * The index of the bufferview
  82274. */
  82275. bufferView?: number;
  82276. /**
  82277. * The offset relative to the start of the bufferView in bytes
  82278. */
  82279. byteOffset?: number;
  82280. /**
  82281. * The datatype of components in the attribute
  82282. */
  82283. componentType: AccessorComponentType;
  82284. /**
  82285. * Specifies whether integer data values should be normalized
  82286. */
  82287. normalized?: boolean;
  82288. /**
  82289. * The number of attributes referenced by this accessor
  82290. */
  82291. count: number;
  82292. /**
  82293. * Specifies if the attribute is a scalar, vector, or matrix
  82294. */
  82295. type: AccessorType;
  82296. /**
  82297. * Maximum value of each component in this attribute
  82298. */
  82299. max?: number[];
  82300. /**
  82301. * Minimum value of each component in this attribute
  82302. */
  82303. min?: number[];
  82304. /**
  82305. * Sparse storage of attributes that deviate from their initialization value
  82306. */
  82307. sparse?: IAccessorSparse;
  82308. }
  82309. /**
  82310. * Targets an animation's sampler at a node's property
  82311. */
  82312. interface IAnimationChannel extends IProperty {
  82313. /**
  82314. * The index of a sampler in this animation used to compute the value for the target
  82315. */
  82316. sampler: number;
  82317. /**
  82318. * The index of the node and TRS property to target
  82319. */
  82320. target: IAnimationChannelTarget;
  82321. }
  82322. /**
  82323. * The index of the node and TRS property that an animation channel targets
  82324. */
  82325. interface IAnimationChannelTarget extends IProperty {
  82326. /**
  82327. * The index of the node to target
  82328. */
  82329. node: number;
  82330. /**
  82331. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82332. */
  82333. path: AnimationChannelTargetPath;
  82334. }
  82335. /**
  82336. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82337. */
  82338. interface IAnimationSampler extends IProperty {
  82339. /**
  82340. * The index of an accessor containing keyframe input values, e.g., time
  82341. */
  82342. input: number;
  82343. /**
  82344. * Interpolation algorithm
  82345. */
  82346. interpolation?: AnimationSamplerInterpolation;
  82347. /**
  82348. * The index of an accessor, containing keyframe output values
  82349. */
  82350. output: number;
  82351. }
  82352. /**
  82353. * A keyframe animation
  82354. */
  82355. interface IAnimation extends IChildRootProperty {
  82356. /**
  82357. * An array of channels, each of which targets an animation's sampler at a node's property
  82358. */
  82359. channels: IAnimationChannel[];
  82360. /**
  82361. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82362. */
  82363. samplers: IAnimationSampler[];
  82364. }
  82365. /**
  82366. * Metadata about the glTF asset
  82367. */
  82368. interface IAsset extends IChildRootProperty {
  82369. /**
  82370. * A copyright message suitable for display to credit the content creator
  82371. */
  82372. copyright?: string;
  82373. /**
  82374. * Tool that generated this glTF model. Useful for debugging
  82375. */
  82376. generator?: string;
  82377. /**
  82378. * The glTF version that this asset targets
  82379. */
  82380. version: string;
  82381. /**
  82382. * The minimum glTF version that this asset targets
  82383. */
  82384. minVersion?: string;
  82385. }
  82386. /**
  82387. * A buffer points to binary geometry, animation, or skins
  82388. */
  82389. interface IBuffer extends IChildRootProperty {
  82390. /**
  82391. * 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
  82392. */
  82393. uri?: string;
  82394. /**
  82395. * The length of the buffer in bytes
  82396. */
  82397. byteLength: number;
  82398. }
  82399. /**
  82400. * A view into a buffer generally representing a subset of the buffer
  82401. */
  82402. interface IBufferView extends IChildRootProperty {
  82403. /**
  82404. * The index of the buffer
  82405. */
  82406. buffer: number;
  82407. /**
  82408. * The offset into the buffer in bytes
  82409. */
  82410. byteOffset?: number;
  82411. /**
  82412. * The lenth of the bufferView in bytes
  82413. */
  82414. byteLength: number;
  82415. /**
  82416. * The stride, in bytes
  82417. */
  82418. byteStride?: number;
  82419. }
  82420. /**
  82421. * An orthographic camera containing properties to create an orthographic projection matrix
  82422. */
  82423. interface ICameraOrthographic extends IProperty {
  82424. /**
  82425. * The floating-point horizontal magnification of the view. Must not be zero
  82426. */
  82427. xmag: number;
  82428. /**
  82429. * The floating-point vertical magnification of the view. Must not be zero
  82430. */
  82431. ymag: number;
  82432. /**
  82433. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82434. */
  82435. zfar: number;
  82436. /**
  82437. * The floating-point distance to the near clipping plane
  82438. */
  82439. znear: number;
  82440. }
  82441. /**
  82442. * A perspective camera containing properties to create a perspective projection matrix
  82443. */
  82444. interface ICameraPerspective extends IProperty {
  82445. /**
  82446. * The floating-point aspect ratio of the field of view
  82447. */
  82448. aspectRatio?: number;
  82449. /**
  82450. * The floating-point vertical field of view in radians
  82451. */
  82452. yfov: number;
  82453. /**
  82454. * The floating-point distance to the far clipping plane
  82455. */
  82456. zfar?: number;
  82457. /**
  82458. * The floating-point distance to the near clipping plane
  82459. */
  82460. znear: number;
  82461. }
  82462. /**
  82463. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82464. */
  82465. interface ICamera extends IChildRootProperty {
  82466. /**
  82467. * An orthographic camera containing properties to create an orthographic projection matrix
  82468. */
  82469. orthographic?: ICameraOrthographic;
  82470. /**
  82471. * A perspective camera containing properties to create a perspective projection matrix
  82472. */
  82473. perspective?: ICameraPerspective;
  82474. /**
  82475. * Specifies if the camera uses a perspective or orthographic projection
  82476. */
  82477. type: CameraType;
  82478. }
  82479. /**
  82480. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82481. */
  82482. interface IImage extends IChildRootProperty {
  82483. /**
  82484. * 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
  82485. */
  82486. uri?: string;
  82487. /**
  82488. * The image's MIME type
  82489. */
  82490. mimeType?: ImageMimeType;
  82491. /**
  82492. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82493. */
  82494. bufferView?: number;
  82495. }
  82496. /**
  82497. * Material Normal Texture Info
  82498. */
  82499. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82500. /**
  82501. * The scalar multiplier applied to each normal vector of the normal texture
  82502. */
  82503. scale?: number;
  82504. }
  82505. /**
  82506. * Material Occlusion Texture Info
  82507. */
  82508. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82509. /**
  82510. * A scalar multiplier controlling the amount of occlusion applied
  82511. */
  82512. strength?: number;
  82513. }
  82514. /**
  82515. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  82516. */
  82517. interface IMaterialPbrMetallicRoughness {
  82518. /**
  82519. * The material's base color factor
  82520. */
  82521. baseColorFactor?: number[];
  82522. /**
  82523. * The base color texture
  82524. */
  82525. baseColorTexture?: ITextureInfo;
  82526. /**
  82527. * The metalness of the material
  82528. */
  82529. metallicFactor?: number;
  82530. /**
  82531. * The roughness of the material
  82532. */
  82533. roughnessFactor?: number;
  82534. /**
  82535. * The metallic-roughness texture
  82536. */
  82537. metallicRoughnessTexture?: ITextureInfo;
  82538. }
  82539. /**
  82540. * The material appearance of a primitive
  82541. */
  82542. interface IMaterial extends IChildRootProperty {
  82543. /**
  82544. * 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
  82545. */
  82546. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82547. /**
  82548. * The normal map texture
  82549. */
  82550. normalTexture?: IMaterialNormalTextureInfo;
  82551. /**
  82552. * The occlusion map texture
  82553. */
  82554. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82555. /**
  82556. * The emissive map texture
  82557. */
  82558. emissiveTexture?: ITextureInfo;
  82559. /**
  82560. * 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
  82561. */
  82562. emissiveFactor?: number[];
  82563. /**
  82564. * The alpha rendering mode of the material
  82565. */
  82566. alphaMode?: MaterialAlphaMode;
  82567. /**
  82568. * The alpha cutoff value of the material
  82569. */
  82570. alphaCutoff?: number;
  82571. /**
  82572. * Specifies whether the material is double sided
  82573. */
  82574. doubleSided?: boolean;
  82575. }
  82576. /**
  82577. * Geometry to be rendered with the given material
  82578. */
  82579. interface IMeshPrimitive extends IProperty {
  82580. /**
  82581. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82582. */
  82583. attributes: {
  82584. [name: string]: number;
  82585. };
  82586. /**
  82587. * The index of the accessor that contains the indices
  82588. */
  82589. indices?: number;
  82590. /**
  82591. * The index of the material to apply to this primitive when rendering
  82592. */
  82593. material?: number;
  82594. /**
  82595. * The type of primitives to render. All valid values correspond to WebGL enums
  82596. */
  82597. mode?: MeshPrimitiveMode;
  82598. /**
  82599. * 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
  82600. */
  82601. targets?: {
  82602. [name: string]: number;
  82603. }[];
  82604. }
  82605. /**
  82606. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82607. */
  82608. interface IMesh extends IChildRootProperty {
  82609. /**
  82610. * An array of primitives, each defining geometry to be rendered with a material
  82611. */
  82612. primitives: IMeshPrimitive[];
  82613. /**
  82614. * Array of weights to be applied to the Morph Targets
  82615. */
  82616. weights?: number[];
  82617. }
  82618. /**
  82619. * A node in the node hierarchy
  82620. */
  82621. interface INode extends IChildRootProperty {
  82622. /**
  82623. * The index of the camera referenced by this node
  82624. */
  82625. camera?: number;
  82626. /**
  82627. * The indices of this node's children
  82628. */
  82629. children?: number[];
  82630. /**
  82631. * The index of the skin referenced by this node
  82632. */
  82633. skin?: number;
  82634. /**
  82635. * A floating-point 4x4 transformation matrix stored in column-major order
  82636. */
  82637. matrix?: number[];
  82638. /**
  82639. * The index of the mesh in this node
  82640. */
  82641. mesh?: number;
  82642. /**
  82643. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82644. */
  82645. rotation?: number[];
  82646. /**
  82647. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82648. */
  82649. scale?: number[];
  82650. /**
  82651. * The node's translation along the x, y, and z axes
  82652. */
  82653. translation?: number[];
  82654. /**
  82655. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82656. */
  82657. weights?: number[];
  82658. }
  82659. /**
  82660. * Texture sampler properties for filtering and wrapping modes
  82661. */
  82662. interface ISampler extends IChildRootProperty {
  82663. /**
  82664. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82665. */
  82666. magFilter?: TextureMagFilter;
  82667. /**
  82668. * Minification filter. All valid values correspond to WebGL enums
  82669. */
  82670. minFilter?: TextureMinFilter;
  82671. /**
  82672. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82673. */
  82674. wrapS?: TextureWrapMode;
  82675. /**
  82676. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82677. */
  82678. wrapT?: TextureWrapMode;
  82679. }
  82680. /**
  82681. * The root nodes of a scene
  82682. */
  82683. interface IScene extends IChildRootProperty {
  82684. /**
  82685. * The indices of each root node
  82686. */
  82687. nodes: number[];
  82688. }
  82689. /**
  82690. * Joints and matrices defining a skin
  82691. */
  82692. interface ISkin extends IChildRootProperty {
  82693. /**
  82694. * 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
  82695. */
  82696. inverseBindMatrices?: number;
  82697. /**
  82698. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82699. */
  82700. skeleton?: number;
  82701. /**
  82702. * 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)
  82703. */
  82704. joints: number[];
  82705. }
  82706. /**
  82707. * A texture and its sampler
  82708. */
  82709. interface ITexture extends IChildRootProperty {
  82710. /**
  82711. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82712. */
  82713. sampler?: number;
  82714. /**
  82715. * The index of the image used by this texture
  82716. */
  82717. source: number;
  82718. }
  82719. /**
  82720. * Reference to a texture
  82721. */
  82722. interface ITextureInfo extends IProperty {
  82723. /**
  82724. * The index of the texture
  82725. */
  82726. index: number;
  82727. /**
  82728. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82729. */
  82730. texCoord?: number;
  82731. }
  82732. /**
  82733. * The root object for a glTF asset
  82734. */
  82735. interface IGLTF extends IProperty {
  82736. /**
  82737. * An array of accessors. An accessor is a typed view into a bufferView
  82738. */
  82739. accessors?: IAccessor[];
  82740. /**
  82741. * An array of keyframe animations
  82742. */
  82743. animations?: IAnimation[];
  82744. /**
  82745. * Metadata about the glTF asset
  82746. */
  82747. asset: IAsset;
  82748. /**
  82749. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82750. */
  82751. buffers?: IBuffer[];
  82752. /**
  82753. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82754. */
  82755. bufferViews?: IBufferView[];
  82756. /**
  82757. * An array of cameras
  82758. */
  82759. cameras?: ICamera[];
  82760. /**
  82761. * Names of glTF extensions used somewhere in this asset
  82762. */
  82763. extensionsUsed?: string[];
  82764. /**
  82765. * Names of glTF extensions required to properly load this asset
  82766. */
  82767. extensionsRequired?: string[];
  82768. /**
  82769. * An array of images. An image defines data used to create a texture
  82770. */
  82771. images?: IImage[];
  82772. /**
  82773. * An array of materials. A material defines the appearance of a primitive
  82774. */
  82775. materials?: IMaterial[];
  82776. /**
  82777. * An array of meshes. A mesh is a set of primitives to be rendered
  82778. */
  82779. meshes?: IMesh[];
  82780. /**
  82781. * An array of nodes
  82782. */
  82783. nodes?: INode[];
  82784. /**
  82785. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82786. */
  82787. samplers?: ISampler[];
  82788. /**
  82789. * The index of the default scene
  82790. */
  82791. scene?: number;
  82792. /**
  82793. * An array of scenes
  82794. */
  82795. scenes?: IScene[];
  82796. /**
  82797. * An array of skins. A skin is defined by joints and matrices
  82798. */
  82799. skins?: ISkin[];
  82800. /**
  82801. * An array of textures
  82802. */
  82803. textures?: ITexture[];
  82804. }
  82805. /**
  82806. * The glTF validation results
  82807. * @ignore
  82808. */
  82809. interface IGLTFValidationResults {
  82810. info: {
  82811. generator: string;
  82812. hasAnimations: boolean;
  82813. hasDefaultScene: boolean;
  82814. hasMaterials: boolean;
  82815. hasMorphTargets: boolean;
  82816. hasSkins: boolean;
  82817. hasTextures: boolean;
  82818. maxAttributesUsed: number;
  82819. primitivesCount: number
  82820. };
  82821. issues: {
  82822. messages: Array<string>;
  82823. numErrors: number;
  82824. numHints: number;
  82825. numInfos: number;
  82826. numWarnings: number;
  82827. truncated: boolean
  82828. };
  82829. mimeType: string;
  82830. uri: string;
  82831. validatedAt: string;
  82832. validatorVersion: string;
  82833. }
  82834. /**
  82835. * The glTF validation options
  82836. */
  82837. interface IGLTFValidationOptions {
  82838. /** Uri to use */
  82839. uri?: string;
  82840. /** Function used to load external resources */
  82841. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82842. /** Boolean indicating that we need to validate accessor data */
  82843. validateAccessorData?: boolean;
  82844. /** max number of issues allowed */
  82845. maxIssues?: number;
  82846. /** Ignored issues */
  82847. ignoredIssues?: Array<string>;
  82848. /** Value to override severy settings */
  82849. severityOverrides?: Object;
  82850. }
  82851. /**
  82852. * The glTF validator object
  82853. * @ignore
  82854. */
  82855. interface IGLTFValidator {
  82856. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82857. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82858. }
  82859. }
  82860. declare module BABYLON {
  82861. /** @hidden */
  82862. export var cellPixelShader: {
  82863. name: string;
  82864. shader: string;
  82865. };
  82866. }
  82867. declare module BABYLON {
  82868. /** @hidden */
  82869. export var cellVertexShader: {
  82870. name: string;
  82871. shader: string;
  82872. };
  82873. }
  82874. declare module BABYLON {
  82875. export class CellMaterial extends BABYLON.PushMaterial {
  82876. private _diffuseTexture;
  82877. diffuseTexture: BABYLON.BaseTexture;
  82878. diffuseColor: BABYLON.Color3;
  82879. _computeHighLevel: boolean;
  82880. computeHighLevel: boolean;
  82881. private _disableLighting;
  82882. disableLighting: boolean;
  82883. private _maxSimultaneousLights;
  82884. maxSimultaneousLights: number;
  82885. constructor(name: string, scene: BABYLON.Scene);
  82886. needAlphaBlending(): boolean;
  82887. needAlphaTesting(): boolean;
  82888. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82889. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82890. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82891. getAnimatables(): BABYLON.IAnimatable[];
  82892. getActiveTextures(): BABYLON.BaseTexture[];
  82893. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82894. dispose(forceDisposeEffect?: boolean): void;
  82895. getClassName(): string;
  82896. clone(name: string): CellMaterial;
  82897. serialize(): any;
  82898. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82899. }
  82900. }
  82901. declare module BABYLON {
  82902. export class CustomShaderStructure {
  82903. FragmentStore: string;
  82904. VertexStore: string;
  82905. constructor();
  82906. }
  82907. export class ShaderSpecialParts {
  82908. constructor();
  82909. Fragment_Begin: string;
  82910. Fragment_Definitions: string;
  82911. Fragment_MainBegin: string;
  82912. Fragment_Custom_Diffuse: string;
  82913. Fragment_Before_Lights: string;
  82914. Fragment_Before_Fog: string;
  82915. Fragment_Custom_Alpha: string;
  82916. Fragment_Before_FragColor: string;
  82917. Vertex_Begin: string;
  82918. Vertex_Definitions: string;
  82919. Vertex_MainBegin: string;
  82920. Vertex_Before_PositionUpdated: string;
  82921. Vertex_Before_NormalUpdated: string;
  82922. Vertex_After_WorldPosComputed: string;
  82923. Vertex_MainEnd: string;
  82924. }
  82925. export class CustomMaterial extends BABYLON.StandardMaterial {
  82926. static ShaderIndexer: number;
  82927. CustomParts: ShaderSpecialParts;
  82928. _isCreatedShader: boolean;
  82929. _createdShaderName: string;
  82930. _customUniform: string[];
  82931. _newUniforms: string[];
  82932. _newUniformInstances: {
  82933. [name: string]: any;
  82934. };
  82935. _newSamplerInstances: {
  82936. [name: string]: BABYLON.Texture;
  82937. };
  82938. _customAttributes: string[];
  82939. FragmentShader: string;
  82940. VertexShader: string;
  82941. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82942. ReviewUniform(name: string, arr: string[]): string[];
  82943. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82944. constructor(name: string, scene: BABYLON.Scene);
  82945. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82946. AddAttribute(name: string): CustomMaterial;
  82947. Fragment_Begin(shaderPart: string): CustomMaterial;
  82948. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82949. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82950. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82951. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82952. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82953. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82954. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82955. Vertex_Begin(shaderPart: string): CustomMaterial;
  82956. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82957. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82958. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82959. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82960. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82961. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82962. }
  82963. }
  82964. declare module BABYLON {
  82965. export class ShaderAlebdoParts {
  82966. constructor();
  82967. Fragment_Begin: string;
  82968. Fragment_Definitions: string;
  82969. Fragment_MainBegin: string;
  82970. Fragment_Custom_Albedo: string;
  82971. Fragment_Before_Lights: string;
  82972. Fragment_Custom_MetallicRoughness: string;
  82973. Fragment_Custom_MicroSurface: string;
  82974. Fragment_Before_Fog: string;
  82975. Fragment_Custom_Alpha: string;
  82976. Fragment_Before_FragColor: string;
  82977. Vertex_Begin: string;
  82978. Vertex_Definitions: string;
  82979. Vertex_MainBegin: string;
  82980. Vertex_Before_PositionUpdated: string;
  82981. Vertex_Before_NormalUpdated: string;
  82982. Vertex_After_WorldPosComputed: string;
  82983. Vertex_MainEnd: string;
  82984. }
  82985. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82986. static ShaderIndexer: number;
  82987. CustomParts: ShaderAlebdoParts;
  82988. _isCreatedShader: boolean;
  82989. _createdShaderName: string;
  82990. _customUniform: string[];
  82991. _newUniforms: string[];
  82992. _newUniformInstances: {
  82993. [name: string]: any;
  82994. };
  82995. _newSamplerInstances: {
  82996. [name: string]: BABYLON.Texture;
  82997. };
  82998. _customAttributes: string[];
  82999. FragmentShader: string;
  83000. VertexShader: string;
  83001. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83002. ReviewUniform(name: string, arr: string[]): string[];
  83003. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83004. constructor(name: string, scene: BABYLON.Scene);
  83005. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83006. AddAttribute(name: string): PBRCustomMaterial;
  83007. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83008. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83009. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83010. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83011. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83012. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83013. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83014. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83015. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83016. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83017. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83018. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83019. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83020. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83021. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83022. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83023. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83024. }
  83025. }
  83026. declare module BABYLON {
  83027. /** @hidden */
  83028. export var firePixelShader: {
  83029. name: string;
  83030. shader: string;
  83031. };
  83032. }
  83033. declare module BABYLON {
  83034. /** @hidden */
  83035. export var fireVertexShader: {
  83036. name: string;
  83037. shader: string;
  83038. };
  83039. }
  83040. declare module BABYLON {
  83041. export class FireMaterial extends BABYLON.PushMaterial {
  83042. private _diffuseTexture;
  83043. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83044. private _distortionTexture;
  83045. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83046. private _opacityTexture;
  83047. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83048. diffuseColor: BABYLON.Color3;
  83049. speed: number;
  83050. private _scaledDiffuse;
  83051. private _lastTime;
  83052. constructor(name: string, scene: BABYLON.Scene);
  83053. needAlphaBlending(): boolean;
  83054. needAlphaTesting(): boolean;
  83055. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83056. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83057. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83058. getAnimatables(): BABYLON.IAnimatable[];
  83059. getActiveTextures(): BABYLON.BaseTexture[];
  83060. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83061. getClassName(): string;
  83062. dispose(forceDisposeEffect?: boolean): void;
  83063. clone(name: string): FireMaterial;
  83064. serialize(): any;
  83065. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83066. }
  83067. }
  83068. declare module BABYLON {
  83069. /** @hidden */
  83070. export var furPixelShader: {
  83071. name: string;
  83072. shader: string;
  83073. };
  83074. }
  83075. declare module BABYLON {
  83076. /** @hidden */
  83077. export var furVertexShader: {
  83078. name: string;
  83079. shader: string;
  83080. };
  83081. }
  83082. declare module BABYLON {
  83083. export class FurMaterial extends BABYLON.PushMaterial {
  83084. private _diffuseTexture;
  83085. diffuseTexture: BABYLON.BaseTexture;
  83086. private _heightTexture;
  83087. heightTexture: BABYLON.BaseTexture;
  83088. diffuseColor: BABYLON.Color3;
  83089. furLength: number;
  83090. furAngle: number;
  83091. furColor: BABYLON.Color3;
  83092. furOffset: number;
  83093. furSpacing: number;
  83094. furGravity: BABYLON.Vector3;
  83095. furSpeed: number;
  83096. furDensity: number;
  83097. furOcclusion: number;
  83098. furTexture: BABYLON.DynamicTexture;
  83099. private _disableLighting;
  83100. disableLighting: boolean;
  83101. private _maxSimultaneousLights;
  83102. maxSimultaneousLights: number;
  83103. highLevelFur: boolean;
  83104. _meshes: BABYLON.AbstractMesh[];
  83105. private _furTime;
  83106. constructor(name: string, scene: BABYLON.Scene);
  83107. get furTime(): number;
  83108. set furTime(furTime: number);
  83109. needAlphaBlending(): boolean;
  83110. needAlphaTesting(): boolean;
  83111. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83112. updateFur(): void;
  83113. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83114. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83115. getAnimatables(): BABYLON.IAnimatable[];
  83116. getActiveTextures(): BABYLON.BaseTexture[];
  83117. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83118. dispose(forceDisposeEffect?: boolean): void;
  83119. clone(name: string): FurMaterial;
  83120. serialize(): any;
  83121. getClassName(): string;
  83122. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  83123. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  83124. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  83125. }
  83126. }
  83127. declare module BABYLON {
  83128. /** @hidden */
  83129. export var gradientPixelShader: {
  83130. name: string;
  83131. shader: string;
  83132. };
  83133. }
  83134. declare module BABYLON {
  83135. /** @hidden */
  83136. export var gradientVertexShader: {
  83137. name: string;
  83138. shader: string;
  83139. };
  83140. }
  83141. declare module BABYLON {
  83142. export class GradientMaterial extends BABYLON.PushMaterial {
  83143. private _maxSimultaneousLights;
  83144. maxSimultaneousLights: number;
  83145. topColor: BABYLON.Color3;
  83146. topColorAlpha: number;
  83147. bottomColor: BABYLON.Color3;
  83148. bottomColorAlpha: number;
  83149. offset: number;
  83150. scale: number;
  83151. smoothness: number;
  83152. private _disableLighting;
  83153. disableLighting: boolean;
  83154. constructor(name: string, scene: BABYLON.Scene);
  83155. needAlphaBlending(): boolean;
  83156. needAlphaTesting(): boolean;
  83157. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83158. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83159. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83160. getAnimatables(): BABYLON.IAnimatable[];
  83161. dispose(forceDisposeEffect?: boolean): void;
  83162. clone(name: string): GradientMaterial;
  83163. serialize(): any;
  83164. getClassName(): string;
  83165. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83166. }
  83167. }
  83168. declare module BABYLON {
  83169. /** @hidden */
  83170. export var gridPixelShader: {
  83171. name: string;
  83172. shader: string;
  83173. };
  83174. }
  83175. declare module BABYLON {
  83176. /** @hidden */
  83177. export var gridVertexShader: {
  83178. name: string;
  83179. shader: string;
  83180. };
  83181. }
  83182. declare module BABYLON {
  83183. /**
  83184. * The grid materials allows you to wrap any shape with a grid.
  83185. * Colors are customizable.
  83186. */
  83187. export class GridMaterial extends BABYLON.PushMaterial {
  83188. /**
  83189. * Main color of the grid (e.g. between lines)
  83190. */
  83191. mainColor: BABYLON.Color3;
  83192. /**
  83193. * Color of the grid lines.
  83194. */
  83195. lineColor: BABYLON.Color3;
  83196. /**
  83197. * The scale of the grid compared to unit.
  83198. */
  83199. gridRatio: number;
  83200. /**
  83201. * Allows setting an offset for the grid lines.
  83202. */
  83203. gridOffset: BABYLON.Vector3;
  83204. /**
  83205. * The frequency of thicker lines.
  83206. */
  83207. majorUnitFrequency: number;
  83208. /**
  83209. * The visibility of minor units in the grid.
  83210. */
  83211. minorUnitVisibility: number;
  83212. /**
  83213. * The grid opacity outside of the lines.
  83214. */
  83215. opacity: number;
  83216. /**
  83217. * Determine RBG output is premultiplied by alpha value.
  83218. */
  83219. preMultiplyAlpha: boolean;
  83220. private _opacityTexture;
  83221. opacityTexture: BABYLON.BaseTexture;
  83222. private _gridControl;
  83223. /**
  83224. * constructor
  83225. * @param name The name given to the material in order to identify it afterwards.
  83226. * @param scene The scene the material is used in.
  83227. */
  83228. constructor(name: string, scene: BABYLON.Scene);
  83229. /**
  83230. * Returns wehter or not the grid requires alpha blending.
  83231. */
  83232. needAlphaBlending(): boolean;
  83233. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83234. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83235. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83236. /**
  83237. * Dispose the material and its associated resources.
  83238. * @param forceDisposeEffect will also dispose the used effect when true
  83239. */
  83240. dispose(forceDisposeEffect?: boolean): void;
  83241. clone(name: string): GridMaterial;
  83242. serialize(): any;
  83243. getClassName(): string;
  83244. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83245. }
  83246. }
  83247. declare module BABYLON {
  83248. /** @hidden */
  83249. export var lavaPixelShader: {
  83250. name: string;
  83251. shader: string;
  83252. };
  83253. }
  83254. declare module BABYLON {
  83255. /** @hidden */
  83256. export var lavaVertexShader: {
  83257. name: string;
  83258. shader: string;
  83259. };
  83260. }
  83261. declare module BABYLON {
  83262. export class LavaMaterial extends BABYLON.PushMaterial {
  83263. private _diffuseTexture;
  83264. diffuseTexture: BABYLON.BaseTexture;
  83265. noiseTexture: BABYLON.BaseTexture;
  83266. fogColor: BABYLON.Color3;
  83267. speed: number;
  83268. movingSpeed: number;
  83269. lowFrequencySpeed: number;
  83270. fogDensity: number;
  83271. private _lastTime;
  83272. diffuseColor: BABYLON.Color3;
  83273. private _disableLighting;
  83274. disableLighting: boolean;
  83275. private _unlit;
  83276. unlit: boolean;
  83277. private _maxSimultaneousLights;
  83278. maxSimultaneousLights: number;
  83279. private _scaledDiffuse;
  83280. constructor(name: string, scene: BABYLON.Scene);
  83281. needAlphaBlending(): boolean;
  83282. needAlphaTesting(): boolean;
  83283. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83284. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83285. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83286. getAnimatables(): BABYLON.IAnimatable[];
  83287. getActiveTextures(): BABYLON.BaseTexture[];
  83288. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83289. dispose(forceDisposeEffect?: boolean): void;
  83290. clone(name: string): LavaMaterial;
  83291. serialize(): any;
  83292. getClassName(): string;
  83293. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  83294. }
  83295. }
  83296. declare module BABYLON {
  83297. /** @hidden */
  83298. export var mixPixelShader: {
  83299. name: string;
  83300. shader: string;
  83301. };
  83302. }
  83303. declare module BABYLON {
  83304. /** @hidden */
  83305. export var mixVertexShader: {
  83306. name: string;
  83307. shader: string;
  83308. };
  83309. }
  83310. declare module BABYLON {
  83311. export class MixMaterial extends BABYLON.PushMaterial {
  83312. /**
  83313. * Mix textures
  83314. */
  83315. private _mixTexture1;
  83316. mixTexture1: BABYLON.BaseTexture;
  83317. private _mixTexture2;
  83318. mixTexture2: BABYLON.BaseTexture;
  83319. /**
  83320. * Diffuse textures
  83321. */
  83322. private _diffuseTexture1;
  83323. diffuseTexture1: BABYLON.Texture;
  83324. private _diffuseTexture2;
  83325. diffuseTexture2: BABYLON.Texture;
  83326. private _diffuseTexture3;
  83327. diffuseTexture3: BABYLON.Texture;
  83328. private _diffuseTexture4;
  83329. diffuseTexture4: BABYLON.Texture;
  83330. private _diffuseTexture5;
  83331. diffuseTexture5: BABYLON.Texture;
  83332. private _diffuseTexture6;
  83333. diffuseTexture6: BABYLON.Texture;
  83334. private _diffuseTexture7;
  83335. diffuseTexture7: BABYLON.Texture;
  83336. private _diffuseTexture8;
  83337. diffuseTexture8: BABYLON.Texture;
  83338. /**
  83339. * Uniforms
  83340. */
  83341. diffuseColor: BABYLON.Color3;
  83342. specularColor: BABYLON.Color3;
  83343. specularPower: number;
  83344. private _disableLighting;
  83345. disableLighting: boolean;
  83346. private _maxSimultaneousLights;
  83347. maxSimultaneousLights: number;
  83348. constructor(name: string, scene: BABYLON.Scene);
  83349. needAlphaBlending(): boolean;
  83350. needAlphaTesting(): boolean;
  83351. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83352. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83353. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83354. getAnimatables(): BABYLON.IAnimatable[];
  83355. getActiveTextures(): BABYLON.BaseTexture[];
  83356. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83357. dispose(forceDisposeEffect?: boolean): void;
  83358. clone(name: string): MixMaterial;
  83359. serialize(): any;
  83360. getClassName(): string;
  83361. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  83362. }
  83363. }
  83364. declare module BABYLON {
  83365. /** @hidden */
  83366. export var normalPixelShader: {
  83367. name: string;
  83368. shader: string;
  83369. };
  83370. }
  83371. declare module BABYLON {
  83372. /** @hidden */
  83373. export var normalVertexShader: {
  83374. name: string;
  83375. shader: string;
  83376. };
  83377. }
  83378. declare module BABYLON {
  83379. export class NormalMaterial extends BABYLON.PushMaterial {
  83380. private _diffuseTexture;
  83381. diffuseTexture: BABYLON.BaseTexture;
  83382. diffuseColor: BABYLON.Color3;
  83383. private _disableLighting;
  83384. disableLighting: boolean;
  83385. private _maxSimultaneousLights;
  83386. maxSimultaneousLights: number;
  83387. constructor(name: string, scene: BABYLON.Scene);
  83388. needAlphaBlending(): boolean;
  83389. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83390. needAlphaTesting(): boolean;
  83391. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83392. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83393. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83394. getAnimatables(): BABYLON.IAnimatable[];
  83395. getActiveTextures(): BABYLON.BaseTexture[];
  83396. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83397. dispose(forceDisposeEffect?: boolean): void;
  83398. clone(name: string): NormalMaterial;
  83399. serialize(): any;
  83400. getClassName(): string;
  83401. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  83402. }
  83403. }
  83404. declare module BABYLON {
  83405. /** @hidden */
  83406. export var shadowOnlyPixelShader: {
  83407. name: string;
  83408. shader: string;
  83409. };
  83410. }
  83411. declare module BABYLON {
  83412. /** @hidden */
  83413. export var shadowOnlyVertexShader: {
  83414. name: string;
  83415. shader: string;
  83416. };
  83417. }
  83418. declare module BABYLON {
  83419. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  83420. private _activeLight;
  83421. private _needAlphaBlending;
  83422. constructor(name: string, scene: BABYLON.Scene);
  83423. shadowColor: BABYLON.Color3;
  83424. needAlphaBlending(): boolean;
  83425. needAlphaTesting(): boolean;
  83426. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83427. get activeLight(): BABYLON.IShadowLight;
  83428. set activeLight(light: BABYLON.IShadowLight);
  83429. private _getFirstShadowLightForMesh;
  83430. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83431. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83432. clone(name: string): ShadowOnlyMaterial;
  83433. serialize(): any;
  83434. getClassName(): string;
  83435. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  83436. }
  83437. }
  83438. declare module BABYLON {
  83439. /** @hidden */
  83440. export var simplePixelShader: {
  83441. name: string;
  83442. shader: string;
  83443. };
  83444. }
  83445. declare module BABYLON {
  83446. /** @hidden */
  83447. export var simpleVertexShader: {
  83448. name: string;
  83449. shader: string;
  83450. };
  83451. }
  83452. declare module BABYLON {
  83453. export class SimpleMaterial extends BABYLON.PushMaterial {
  83454. private _diffuseTexture;
  83455. diffuseTexture: BABYLON.BaseTexture;
  83456. diffuseColor: BABYLON.Color3;
  83457. private _disableLighting;
  83458. disableLighting: boolean;
  83459. private _maxSimultaneousLights;
  83460. maxSimultaneousLights: number;
  83461. constructor(name: string, scene: BABYLON.Scene);
  83462. needAlphaBlending(): boolean;
  83463. needAlphaTesting(): boolean;
  83464. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83465. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83466. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83467. getAnimatables(): BABYLON.IAnimatable[];
  83468. getActiveTextures(): BABYLON.BaseTexture[];
  83469. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83470. dispose(forceDisposeEffect?: boolean): void;
  83471. clone(name: string): SimpleMaterial;
  83472. serialize(): any;
  83473. getClassName(): string;
  83474. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  83475. }
  83476. }
  83477. declare module BABYLON {
  83478. /** @hidden */
  83479. export var skyPixelShader: {
  83480. name: string;
  83481. shader: string;
  83482. };
  83483. }
  83484. declare module BABYLON {
  83485. /** @hidden */
  83486. export var skyVertexShader: {
  83487. name: string;
  83488. shader: string;
  83489. };
  83490. }
  83491. declare module BABYLON {
  83492. /**
  83493. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83494. * @see https://doc.babylonjs.com/extensions/sky
  83495. */
  83496. export class SkyMaterial extends BABYLON.PushMaterial {
  83497. /**
  83498. * Defines the overall luminance of sky in interval ]0, 1[.
  83499. */
  83500. luminance: number;
  83501. /**
  83502. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83503. */
  83504. turbidity: number;
  83505. /**
  83506. * Defines the sky appearance (light intensity).
  83507. */
  83508. rayleigh: number;
  83509. /**
  83510. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83511. */
  83512. mieCoefficient: number;
  83513. /**
  83514. * Defines the amount of haze particles following the Mie scattering theory.
  83515. */
  83516. mieDirectionalG: number;
  83517. /**
  83518. * Defines the distance of the sun according to the active scene camera.
  83519. */
  83520. distance: number;
  83521. /**
  83522. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  83523. * "inclined".
  83524. */
  83525. inclination: number;
  83526. /**
  83527. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  83528. * an object direction and a reference direction.
  83529. */
  83530. azimuth: number;
  83531. /**
  83532. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  83533. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  83534. */
  83535. sunPosition: BABYLON.Vector3;
  83536. /**
  83537. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  83538. * .sunPosition property.
  83539. */
  83540. useSunPosition: boolean;
  83541. /**
  83542. * Defines an offset vector used to get a horizon offset.
  83543. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  83544. */
  83545. cameraOffset: BABYLON.Vector3;
  83546. private _cameraPosition;
  83547. /**
  83548. * Instantiates a new sky material.
  83549. * This material allows to create dynamic and texture free
  83550. * effects for skyboxes by taking care of the atmosphere state.
  83551. * @see https://doc.babylonjs.com/extensions/sky
  83552. * @param name Define the name of the material in the scene
  83553. * @param scene Define the scene the material belong to
  83554. */
  83555. constructor(name: string, scene: BABYLON.Scene);
  83556. /**
  83557. * Specifies if the material will require alpha blending
  83558. * @returns a boolean specifying if alpha blending is needed
  83559. */
  83560. needAlphaBlending(): boolean;
  83561. /**
  83562. * Specifies if this material should be rendered in alpha test mode
  83563. * @returns false as the sky material doesn't need alpha testing.
  83564. */
  83565. needAlphaTesting(): boolean;
  83566. /**
  83567. * Get the texture used for alpha test purpose.
  83568. * @returns null as the sky material has no texture.
  83569. */
  83570. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83571. /**
  83572. * Get if the submesh is ready to be used and all its information available.
  83573. * Child classes can use it to update shaders
  83574. * @param mesh defines the mesh to check
  83575. * @param subMesh defines which submesh to check
  83576. * @param useInstances specifies that instances should be used
  83577. * @returns a boolean indicating that the submesh is ready or not
  83578. */
  83579. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83580. /**
  83581. * Binds the submesh to this material by preparing the effect and shader to draw
  83582. * @param world defines the world transformation matrix
  83583. * @param mesh defines the mesh containing the submesh
  83584. * @param subMesh defines the submesh to bind the material to
  83585. */
  83586. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83587. /**
  83588. * Get the list of animatables in the material.
  83589. * @returns the list of animatables object used in the material
  83590. */
  83591. getAnimatables(): BABYLON.IAnimatable[];
  83592. /**
  83593. * Disposes the material
  83594. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83595. */
  83596. dispose(forceDisposeEffect?: boolean): void;
  83597. /**
  83598. * Makes a duplicate of the material, and gives it a new name
  83599. * @param name defines the new name for the duplicated material
  83600. * @returns the cloned material
  83601. */
  83602. clone(name: string): SkyMaterial;
  83603. /**
  83604. * Serializes this material in a JSON representation
  83605. * @returns the serialized material object
  83606. */
  83607. serialize(): any;
  83608. /**
  83609. * Gets the current class name of the material e.g. "SkyMaterial"
  83610. * Mainly use in serialization.
  83611. * @returns the class name
  83612. */
  83613. getClassName(): string;
  83614. /**
  83615. * Creates a sky material from parsed material data
  83616. * @param source defines the JSON representation of the material
  83617. * @param scene defines the hosting scene
  83618. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83619. * @returns a new sky material
  83620. */
  83621. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83622. }
  83623. }
  83624. declare module BABYLON {
  83625. /** @hidden */
  83626. export var terrainPixelShader: {
  83627. name: string;
  83628. shader: string;
  83629. };
  83630. }
  83631. declare module BABYLON {
  83632. /** @hidden */
  83633. export var terrainVertexShader: {
  83634. name: string;
  83635. shader: string;
  83636. };
  83637. }
  83638. declare module BABYLON {
  83639. export class TerrainMaterial extends BABYLON.PushMaterial {
  83640. private _mixTexture;
  83641. mixTexture: BABYLON.BaseTexture;
  83642. private _diffuseTexture1;
  83643. diffuseTexture1: BABYLON.Texture;
  83644. private _diffuseTexture2;
  83645. diffuseTexture2: BABYLON.Texture;
  83646. private _diffuseTexture3;
  83647. diffuseTexture3: BABYLON.Texture;
  83648. private _bumpTexture1;
  83649. bumpTexture1: BABYLON.Texture;
  83650. private _bumpTexture2;
  83651. bumpTexture2: BABYLON.Texture;
  83652. private _bumpTexture3;
  83653. bumpTexture3: BABYLON.Texture;
  83654. diffuseColor: BABYLON.Color3;
  83655. specularColor: BABYLON.Color3;
  83656. specularPower: number;
  83657. private _disableLighting;
  83658. disableLighting: boolean;
  83659. private _maxSimultaneousLights;
  83660. maxSimultaneousLights: number;
  83661. constructor(name: string, scene: BABYLON.Scene);
  83662. needAlphaBlending(): boolean;
  83663. needAlphaTesting(): boolean;
  83664. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83665. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83666. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83667. getAnimatables(): BABYLON.IAnimatable[];
  83668. getActiveTextures(): BABYLON.BaseTexture[];
  83669. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83670. dispose(forceDisposeEffect?: boolean): void;
  83671. clone(name: string): TerrainMaterial;
  83672. serialize(): any;
  83673. getClassName(): string;
  83674. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83675. }
  83676. }
  83677. declare module BABYLON {
  83678. /** @hidden */
  83679. export var triplanarPixelShader: {
  83680. name: string;
  83681. shader: string;
  83682. };
  83683. }
  83684. declare module BABYLON {
  83685. /** @hidden */
  83686. export var triplanarVertexShader: {
  83687. name: string;
  83688. shader: string;
  83689. };
  83690. }
  83691. declare module BABYLON {
  83692. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83693. mixTexture: BABYLON.BaseTexture;
  83694. private _diffuseTextureX;
  83695. diffuseTextureX: BABYLON.BaseTexture;
  83696. private _diffuseTextureY;
  83697. diffuseTextureY: BABYLON.BaseTexture;
  83698. private _diffuseTextureZ;
  83699. diffuseTextureZ: BABYLON.BaseTexture;
  83700. private _normalTextureX;
  83701. normalTextureX: BABYLON.BaseTexture;
  83702. private _normalTextureY;
  83703. normalTextureY: BABYLON.BaseTexture;
  83704. private _normalTextureZ;
  83705. normalTextureZ: BABYLON.BaseTexture;
  83706. tileSize: number;
  83707. diffuseColor: BABYLON.Color3;
  83708. specularColor: BABYLON.Color3;
  83709. specularPower: number;
  83710. private _disableLighting;
  83711. disableLighting: boolean;
  83712. private _maxSimultaneousLights;
  83713. maxSimultaneousLights: number;
  83714. constructor(name: string, scene: BABYLON.Scene);
  83715. needAlphaBlending(): boolean;
  83716. needAlphaTesting(): boolean;
  83717. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83718. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83719. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83720. getAnimatables(): BABYLON.IAnimatable[];
  83721. getActiveTextures(): BABYLON.BaseTexture[];
  83722. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83723. dispose(forceDisposeEffect?: boolean): void;
  83724. clone(name: string): TriPlanarMaterial;
  83725. serialize(): any;
  83726. getClassName(): string;
  83727. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83728. }
  83729. }
  83730. declare module BABYLON {
  83731. /** @hidden */
  83732. export var waterPixelShader: {
  83733. name: string;
  83734. shader: string;
  83735. };
  83736. }
  83737. declare module BABYLON {
  83738. /** @hidden */
  83739. export var waterVertexShader: {
  83740. name: string;
  83741. shader: string;
  83742. };
  83743. }
  83744. declare module BABYLON {
  83745. export class WaterMaterial extends BABYLON.PushMaterial {
  83746. renderTargetSize: BABYLON.Vector2;
  83747. private _bumpTexture;
  83748. bumpTexture: BABYLON.BaseTexture;
  83749. diffuseColor: BABYLON.Color3;
  83750. specularColor: BABYLON.Color3;
  83751. specularPower: number;
  83752. private _disableLighting;
  83753. disableLighting: boolean;
  83754. private _maxSimultaneousLights;
  83755. maxSimultaneousLights: number;
  83756. /**
  83757. * @param {number}: Represents the wind force
  83758. */
  83759. windForce: number;
  83760. /**
  83761. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83762. */
  83763. windDirection: BABYLON.Vector2;
  83764. /**
  83765. * @param {number}: Wave height, represents the height of the waves
  83766. */
  83767. waveHeight: number;
  83768. /**
  83769. * @param {number}: Bump height, represents the bump height related to the bump map
  83770. */
  83771. bumpHeight: number;
  83772. /**
  83773. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83774. */
  83775. private _bumpSuperimpose;
  83776. bumpSuperimpose: boolean;
  83777. /**
  83778. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83779. */
  83780. private _fresnelSeparate;
  83781. fresnelSeparate: boolean;
  83782. /**
  83783. * @param {boolean}: bump Waves modify the reflection.
  83784. */
  83785. private _bumpAffectsReflection;
  83786. bumpAffectsReflection: boolean;
  83787. /**
  83788. * @param {number}: The water color blended with the refraction (near)
  83789. */
  83790. waterColor: BABYLON.Color3;
  83791. /**
  83792. * @param {number}: The blend factor related to the water color
  83793. */
  83794. colorBlendFactor: number;
  83795. /**
  83796. * @param {number}: The water color blended with the reflection (far)
  83797. */
  83798. waterColor2: BABYLON.Color3;
  83799. /**
  83800. * @param {number}: The blend factor related to the water color (reflection, far)
  83801. */
  83802. colorBlendFactor2: number;
  83803. /**
  83804. * @param {number}: Represents the maximum length of a wave
  83805. */
  83806. waveLength: number;
  83807. /**
  83808. * @param {number}: Defines the waves speed
  83809. */
  83810. waveSpeed: number;
  83811. /**
  83812. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83813. * will avoid calculating useless pixels in the pixel shader of the water material.
  83814. */
  83815. disableClipPlane: boolean;
  83816. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83817. private _mesh;
  83818. private _refractionRTT;
  83819. private _reflectionRTT;
  83820. private _reflectionTransform;
  83821. private _lastTime;
  83822. private _lastDeltaTime;
  83823. private _useLogarithmicDepth;
  83824. private _waitingRenderList;
  83825. private _imageProcessingConfiguration;
  83826. private _imageProcessingObserver;
  83827. /**
  83828. * Gets a boolean indicating that current material needs to register RTT
  83829. */
  83830. get hasRenderTargetTextures(): boolean;
  83831. /**
  83832. * Constructor
  83833. */
  83834. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83835. get useLogarithmicDepth(): boolean;
  83836. set useLogarithmicDepth(value: boolean);
  83837. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83838. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83839. addToRenderList(node: any): void;
  83840. enableRenderTargets(enable: boolean): void;
  83841. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83842. get renderTargetsEnabled(): boolean;
  83843. needAlphaBlending(): boolean;
  83844. needAlphaTesting(): boolean;
  83845. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83846. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83847. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83848. private _createRenderTargets;
  83849. getAnimatables(): BABYLON.IAnimatable[];
  83850. getActiveTextures(): BABYLON.BaseTexture[];
  83851. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83852. dispose(forceDisposeEffect?: boolean): void;
  83853. clone(name: string): WaterMaterial;
  83854. serialize(): any;
  83855. getClassName(): string;
  83856. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83857. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83858. }
  83859. }
  83860. declare module BABYLON {
  83861. /** @hidden */
  83862. export var asciiartPixelShader: {
  83863. name: string;
  83864. shader: string;
  83865. };
  83866. }
  83867. declare module BABYLON {
  83868. /**
  83869. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83870. *
  83871. * It basically takes care rendering the font front the given font size to a texture.
  83872. * This is used later on in the postprocess.
  83873. */
  83874. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83875. private _font;
  83876. private _text;
  83877. private _charSize;
  83878. /**
  83879. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83880. */
  83881. get charSize(): number;
  83882. /**
  83883. * Create a new instance of the Ascii Art FontTexture class
  83884. * @param name the name of the texture
  83885. * @param font the font to use, use the W3C CSS notation
  83886. * @param text the caracter set to use in the rendering.
  83887. * @param scene the scene that owns the texture
  83888. */
  83889. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83890. /**
  83891. * Gets the max char width of a font.
  83892. * @param font the font to use, use the W3C CSS notation
  83893. * @return the max char width
  83894. */
  83895. private getFontWidth;
  83896. /**
  83897. * Gets the max char height of a font.
  83898. * @param font the font to use, use the W3C CSS notation
  83899. * @return the max char height
  83900. */
  83901. private getFontHeight;
  83902. /**
  83903. * Clones the current AsciiArtTexture.
  83904. * @return the clone of the texture.
  83905. */
  83906. clone(): AsciiArtFontTexture;
  83907. /**
  83908. * Parses a json object representing the texture and returns an instance of it.
  83909. * @param source the source JSON representation
  83910. * @param scene the scene to create the texture for
  83911. * @return the parsed texture
  83912. */
  83913. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83914. }
  83915. /**
  83916. * Option available in the Ascii Art Post Process.
  83917. */
  83918. export interface IAsciiArtPostProcessOptions {
  83919. /**
  83920. * The font to use following the w3c font definition.
  83921. */
  83922. font?: string;
  83923. /**
  83924. * The character set to use in the postprocess.
  83925. */
  83926. characterSet?: string;
  83927. /**
  83928. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83929. * This number is defined between 0 and 1;
  83930. */
  83931. mixToTile?: number;
  83932. /**
  83933. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83934. * This number is defined between 0 and 1;
  83935. */
  83936. mixToNormal?: number;
  83937. }
  83938. /**
  83939. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83940. *
  83941. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83942. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83943. */
  83944. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83945. /**
  83946. * The font texture used to render the char in the post process.
  83947. */
  83948. private _asciiArtFontTexture;
  83949. /**
  83950. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83951. * This number is defined between 0 and 1;
  83952. */
  83953. mixToTile: number;
  83954. /**
  83955. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83956. * This number is defined between 0 and 1;
  83957. */
  83958. mixToNormal: number;
  83959. /**
  83960. * Instantiates a new Ascii Art Post Process.
  83961. * @param name the name to give to the postprocess
  83962. * @camera the camera to apply the post process to.
  83963. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83964. */
  83965. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83966. }
  83967. }
  83968. declare module BABYLON {
  83969. /** @hidden */
  83970. export var digitalrainPixelShader: {
  83971. name: string;
  83972. shader: string;
  83973. };
  83974. }
  83975. declare module BABYLON {
  83976. /**
  83977. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83978. *
  83979. * It basically takes care rendering the font front the given font size to a texture.
  83980. * This is used later on in the postprocess.
  83981. */
  83982. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83983. private _font;
  83984. private _text;
  83985. private _charSize;
  83986. /**
  83987. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83988. */
  83989. get charSize(): number;
  83990. /**
  83991. * Create a new instance of the Digital Rain FontTexture class
  83992. * @param name the name of the texture
  83993. * @param font the font to use, use the W3C CSS notation
  83994. * @param text the caracter set to use in the rendering.
  83995. * @param scene the scene that owns the texture
  83996. */
  83997. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83998. /**
  83999. * Gets the max char width of a font.
  84000. * @param font the font to use, use the W3C CSS notation
  84001. * @return the max char width
  84002. */
  84003. private getFontWidth;
  84004. /**
  84005. * Gets the max char height of a font.
  84006. * @param font the font to use, use the W3C CSS notation
  84007. * @return the max char height
  84008. */
  84009. private getFontHeight;
  84010. /**
  84011. * Clones the current DigitalRainFontTexture.
  84012. * @return the clone of the texture.
  84013. */
  84014. clone(): DigitalRainFontTexture;
  84015. /**
  84016. * Parses a json object representing the texture and returns an instance of it.
  84017. * @param source the source JSON representation
  84018. * @param scene the scene to create the texture for
  84019. * @return the parsed texture
  84020. */
  84021. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84022. }
  84023. /**
  84024. * Option available in the Digital Rain Post Process.
  84025. */
  84026. export interface IDigitalRainPostProcessOptions {
  84027. /**
  84028. * The font to use following the w3c font definition.
  84029. */
  84030. font?: string;
  84031. /**
  84032. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84033. * This number is defined between 0 and 1;
  84034. */
  84035. mixToTile?: number;
  84036. /**
  84037. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84038. * This number is defined between 0 and 1;
  84039. */
  84040. mixToNormal?: number;
  84041. }
  84042. /**
  84043. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84044. *
  84045. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84046. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84047. */
  84048. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84049. /**
  84050. * The font texture used to render the char in the post process.
  84051. */
  84052. private _digitalRainFontTexture;
  84053. /**
  84054. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84055. * This number is defined between 0 and 1;
  84056. */
  84057. mixToTile: number;
  84058. /**
  84059. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84060. * This number is defined between 0 and 1;
  84061. */
  84062. mixToNormal: number;
  84063. /**
  84064. * Instantiates a new Digital Rain Post Process.
  84065. * @param name the name to give to the postprocess
  84066. * @camera the camera to apply the post process to.
  84067. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84068. */
  84069. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84070. }
  84071. }
  84072. declare module BABYLON {
  84073. /** @hidden */
  84074. export var brickProceduralTexturePixelShader: {
  84075. name: string;
  84076. shader: string;
  84077. };
  84078. }
  84079. declare module BABYLON {
  84080. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  84081. private _numberOfBricksHeight;
  84082. private _numberOfBricksWidth;
  84083. private _jointColor;
  84084. private _brickColor;
  84085. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84086. updateShaderUniforms(): void;
  84087. get numberOfBricksHeight(): number;
  84088. set numberOfBricksHeight(value: number);
  84089. get numberOfBricksWidth(): number;
  84090. set numberOfBricksWidth(value: number);
  84091. get jointColor(): BABYLON.Color3;
  84092. set jointColor(value: BABYLON.Color3);
  84093. get brickColor(): BABYLON.Color3;
  84094. set brickColor(value: BABYLON.Color3);
  84095. /**
  84096. * Serializes this brick procedural texture
  84097. * @returns a serialized brick procedural texture object
  84098. */
  84099. serialize(): any;
  84100. /**
  84101. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  84102. * @param parsedTexture defines parsed texture data
  84103. * @param scene defines the current scene
  84104. * @param rootUrl defines the root URL containing brick procedural texture information
  84105. * @returns a parsed Brick Procedural BABYLON.Texture
  84106. */
  84107. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  84108. }
  84109. }
  84110. declare module BABYLON {
  84111. /** @hidden */
  84112. export var cloudProceduralTexturePixelShader: {
  84113. name: string;
  84114. shader: string;
  84115. };
  84116. }
  84117. declare module BABYLON {
  84118. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  84119. private _skyColor;
  84120. private _cloudColor;
  84121. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84122. updateShaderUniforms(): void;
  84123. get skyColor(): BABYLON.Color4;
  84124. set skyColor(value: BABYLON.Color4);
  84125. get cloudColor(): BABYLON.Color4;
  84126. set cloudColor(value: BABYLON.Color4);
  84127. /**
  84128. * Serializes this cloud procedural texture
  84129. * @returns a serialized cloud procedural texture object
  84130. */
  84131. serialize(): any;
  84132. /**
  84133. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  84134. * @param parsedTexture defines parsed texture data
  84135. * @param scene defines the current scene
  84136. * @param rootUrl defines the root URL containing cloud procedural texture information
  84137. * @returns a parsed Cloud Procedural BABYLON.Texture
  84138. */
  84139. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  84140. }
  84141. }
  84142. declare module BABYLON {
  84143. /** @hidden */
  84144. export var fireProceduralTexturePixelShader: {
  84145. name: string;
  84146. shader: string;
  84147. };
  84148. }
  84149. declare module BABYLON {
  84150. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  84151. private _time;
  84152. private _speed;
  84153. private _autoGenerateTime;
  84154. private _fireColors;
  84155. private _alphaThreshold;
  84156. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84157. updateShaderUniforms(): void;
  84158. render(useCameraPostProcess?: boolean): void;
  84159. static get PurpleFireColors(): BABYLON.Color3[];
  84160. static get GreenFireColors(): BABYLON.Color3[];
  84161. static get RedFireColors(): BABYLON.Color3[];
  84162. static get BlueFireColors(): BABYLON.Color3[];
  84163. get autoGenerateTime(): boolean;
  84164. set autoGenerateTime(value: boolean);
  84165. get fireColors(): BABYLON.Color3[];
  84166. set fireColors(value: BABYLON.Color3[]);
  84167. get time(): number;
  84168. set time(value: number);
  84169. get speed(): BABYLON.Vector2;
  84170. set speed(value: BABYLON.Vector2);
  84171. get alphaThreshold(): number;
  84172. set alphaThreshold(value: number);
  84173. /**
  84174. * Serializes this fire procedural texture
  84175. * @returns a serialized fire procedural texture object
  84176. */
  84177. serialize(): any;
  84178. /**
  84179. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84180. * @param parsedTexture defines parsed texture data
  84181. * @param scene defines the current scene
  84182. * @param rootUrl defines the root URL containing fire procedural texture information
  84183. * @returns a parsed Fire Procedural BABYLON.Texture
  84184. */
  84185. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84186. }
  84187. }
  84188. declare module BABYLON {
  84189. /** @hidden */
  84190. export var grassProceduralTexturePixelShader: {
  84191. name: string;
  84192. shader: string;
  84193. };
  84194. }
  84195. declare module BABYLON {
  84196. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84197. private _grassColors;
  84198. private _groundColor;
  84199. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84200. updateShaderUniforms(): void;
  84201. get grassColors(): BABYLON.Color3[];
  84202. set grassColors(value: BABYLON.Color3[]);
  84203. get groundColor(): BABYLON.Color3;
  84204. set groundColor(value: BABYLON.Color3);
  84205. /**
  84206. * Serializes this grass procedural texture
  84207. * @returns a serialized grass procedural texture object
  84208. */
  84209. serialize(): any;
  84210. /**
  84211. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84212. * @param parsedTexture defines parsed texture data
  84213. * @param scene defines the current scene
  84214. * @param rootUrl defines the root URL containing grass procedural texture information
  84215. * @returns a parsed Grass Procedural BABYLON.Texture
  84216. */
  84217. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84218. }
  84219. }
  84220. declare module BABYLON {
  84221. /** @hidden */
  84222. export var marbleProceduralTexturePixelShader: {
  84223. name: string;
  84224. shader: string;
  84225. };
  84226. }
  84227. declare module BABYLON {
  84228. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84229. private _numberOfTilesHeight;
  84230. private _numberOfTilesWidth;
  84231. private _amplitude;
  84232. private _jointColor;
  84233. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84234. updateShaderUniforms(): void;
  84235. get numberOfTilesHeight(): number;
  84236. set numberOfTilesHeight(value: number);
  84237. get amplitude(): number;
  84238. set amplitude(value: number);
  84239. get numberOfTilesWidth(): number;
  84240. set numberOfTilesWidth(value: number);
  84241. get jointColor(): BABYLON.Color3;
  84242. set jointColor(value: BABYLON.Color3);
  84243. /**
  84244. * Serializes this marble procedural texture
  84245. * @returns a serialized marble procedural texture object
  84246. */
  84247. serialize(): any;
  84248. /**
  84249. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  84250. * @param parsedTexture defines parsed texture data
  84251. * @param scene defines the current scene
  84252. * @param rootUrl defines the root URL containing marble procedural texture information
  84253. * @returns a parsed Marble Procedural BABYLON.Texture
  84254. */
  84255. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  84256. }
  84257. }
  84258. declare module BABYLON {
  84259. /** @hidden */
  84260. export var normalMapProceduralTexturePixelShader: {
  84261. name: string;
  84262. shader: string;
  84263. };
  84264. }
  84265. declare module BABYLON {
  84266. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  84267. private _baseTexture;
  84268. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84269. updateShaderUniforms(): void;
  84270. render(useCameraPostProcess?: boolean): void;
  84271. resize(size: any, generateMipMaps: any): void;
  84272. get baseTexture(): BABYLON.Texture;
  84273. set baseTexture(texture: BABYLON.Texture);
  84274. /**
  84275. * Serializes this normal map procedural texture
  84276. * @returns a serialized normal map procedural texture object
  84277. */
  84278. serialize(): any;
  84279. /**
  84280. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  84281. * @param parsedTexture defines parsed texture data
  84282. * @param scene defines the current scene
  84283. * @param rootUrl defines the root URL containing normal map procedural texture information
  84284. * @returns a parsed Normal Map Procedural BABYLON.Texture
  84285. */
  84286. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  84287. }
  84288. }
  84289. declare module BABYLON {
  84290. /** @hidden */
  84291. export var perlinNoiseProceduralTexturePixelShader: {
  84292. name: string;
  84293. shader: string;
  84294. };
  84295. }
  84296. declare module BABYLON {
  84297. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  84298. time: number;
  84299. timeScale: number;
  84300. translationSpeed: number;
  84301. private _currentTranslation;
  84302. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84303. updateShaderUniforms(): void;
  84304. render(useCameraPostProcess?: boolean): void;
  84305. resize(size: any, generateMipMaps: any): void;
  84306. /**
  84307. * Serializes this perlin noise procedural texture
  84308. * @returns a serialized perlin noise procedural texture object
  84309. */
  84310. serialize(): any;
  84311. /**
  84312. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  84313. * @param parsedTexture defines parsed texture data
  84314. * @param scene defines the current scene
  84315. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  84316. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  84317. */
  84318. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  84319. }
  84320. }
  84321. declare module BABYLON {
  84322. /** @hidden */
  84323. export var roadProceduralTexturePixelShader: {
  84324. name: string;
  84325. shader: string;
  84326. };
  84327. }
  84328. declare module BABYLON {
  84329. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  84330. private _roadColor;
  84331. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84332. updateShaderUniforms(): void;
  84333. get roadColor(): BABYLON.Color3;
  84334. set roadColor(value: BABYLON.Color3);
  84335. /**
  84336. * Serializes this road procedural texture
  84337. * @returns a serialized road procedural texture object
  84338. */
  84339. serialize(): any;
  84340. /**
  84341. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  84342. * @param parsedTexture defines parsed texture data
  84343. * @param scene defines the current scene
  84344. * @param rootUrl defines the root URL containing road procedural texture information
  84345. * @returns a parsed Road Procedural BABYLON.Texture
  84346. */
  84347. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  84348. }
  84349. }
  84350. declare module BABYLON {
  84351. /** @hidden */
  84352. export var starfieldProceduralTexturePixelShader: {
  84353. name: string;
  84354. shader: string;
  84355. };
  84356. }
  84357. declare module BABYLON {
  84358. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  84359. private _time;
  84360. private _alpha;
  84361. private _beta;
  84362. private _zoom;
  84363. private _formuparam;
  84364. private _stepsize;
  84365. private _tile;
  84366. private _brightness;
  84367. private _darkmatter;
  84368. private _distfading;
  84369. private _saturation;
  84370. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84371. updateShaderUniforms(): void;
  84372. get time(): number;
  84373. set time(value: number);
  84374. get alpha(): number;
  84375. set alpha(value: number);
  84376. get beta(): number;
  84377. set beta(value: number);
  84378. get formuparam(): number;
  84379. set formuparam(value: number);
  84380. get stepsize(): number;
  84381. set stepsize(value: number);
  84382. get zoom(): number;
  84383. set zoom(value: number);
  84384. get tile(): number;
  84385. set tile(value: number);
  84386. get brightness(): number;
  84387. set brightness(value: number);
  84388. get darkmatter(): number;
  84389. set darkmatter(value: number);
  84390. get distfading(): number;
  84391. set distfading(value: number);
  84392. get saturation(): number;
  84393. set saturation(value: number);
  84394. /**
  84395. * Serializes this starfield procedural texture
  84396. * @returns a serialized starfield procedural texture object
  84397. */
  84398. serialize(): any;
  84399. /**
  84400. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  84401. * @param parsedTexture defines parsed texture data
  84402. * @param scene defines the current scene
  84403. * @param rootUrl defines the root URL containing startfield procedural texture information
  84404. * @returns a parsed Starfield Procedural BABYLON.Texture
  84405. */
  84406. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  84407. }
  84408. }
  84409. declare module BABYLON {
  84410. /** @hidden */
  84411. export var woodProceduralTexturePixelShader: {
  84412. name: string;
  84413. shader: string;
  84414. };
  84415. }
  84416. declare module BABYLON {
  84417. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  84418. private _ampScale;
  84419. private _woodColor;
  84420. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84421. updateShaderUniforms(): void;
  84422. get ampScale(): number;
  84423. set ampScale(value: number);
  84424. get woodColor(): BABYLON.Color3;
  84425. set woodColor(value: BABYLON.Color3);
  84426. /**
  84427. * Serializes this wood procedural texture
  84428. * @returns a serialized wood procedural texture object
  84429. */
  84430. serialize(): any;
  84431. /**
  84432. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  84433. * @param parsedTexture defines parsed texture data
  84434. * @param scene defines the current scene
  84435. * @param rootUrl defines the root URL containing wood procedural texture information
  84436. * @returns a parsed Wood Procedural BABYLON.Texture
  84437. */
  84438. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  84439. }
  84440. }