documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571
  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. /** @hidden */
  51442. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51443. private _genericAttributeLocation;
  51444. private _varyingLocationCount;
  51445. private _varyingLocationMap;
  51446. private _replacements;
  51447. private _textureCount;
  51448. private _uniforms;
  51449. lineProcessor(line: string): string;
  51450. attributeProcessor(attribute: string): string;
  51451. varyingProcessor(varying: string, isFragment: boolean): string;
  51452. uniformProcessor(uniform: string): string;
  51453. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51454. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51455. }
  51456. }
  51457. declare module BABYLON {
  51458. /**
  51459. * Class used to inline functions in shader code
  51460. */
  51461. export class ShaderCodeInliner {
  51462. private static readonly _RegexpFindFunctionNameAndType;
  51463. private _sourceCode;
  51464. private _functionDescr;
  51465. private _numMaxIterations;
  51466. /** Gets or sets the token used to mark the functions to inline */
  51467. inlineToken: string;
  51468. /** Gets or sets the debug mode */
  51469. debug: boolean;
  51470. /** Gets the code after the inlining process */
  51471. get code(): string;
  51472. /**
  51473. * Initializes the inliner
  51474. * @param sourceCode shader code source to inline
  51475. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51476. */
  51477. constructor(sourceCode: string, numMaxIterations?: number);
  51478. /**
  51479. * Start the processing of the shader code
  51480. */
  51481. processCode(): void;
  51482. private _collectFunctions;
  51483. private _processInlining;
  51484. private _extractBetweenMarkers;
  51485. private _skipWhitespaces;
  51486. private _removeComments;
  51487. private _replaceFunctionCallsByCode;
  51488. private _findBackward;
  51489. private _escapeRegExp;
  51490. private _replaceNames;
  51491. }
  51492. }
  51493. declare module BABYLON {
  51494. /**
  51495. * Container for accessors for natively-stored mesh data buffers.
  51496. */
  51497. class NativeDataBuffer extends DataBuffer {
  51498. /**
  51499. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51500. */
  51501. nativeIndexBuffer?: any;
  51502. /**
  51503. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51504. */
  51505. nativeVertexBuffer?: any;
  51506. }
  51507. /** @hidden */
  51508. class NativeTexture extends InternalTexture {
  51509. getInternalTexture(): InternalTexture;
  51510. getViewCount(): number;
  51511. }
  51512. /** @hidden */
  51513. export class NativeEngine extends Engine {
  51514. private readonly _native;
  51515. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51516. private readonly INVALID_HANDLE;
  51517. getHardwareScalingLevel(): number;
  51518. constructor();
  51519. dispose(): void;
  51520. /**
  51521. * Can be used to override the current requestAnimationFrame requester.
  51522. * @hidden
  51523. */
  51524. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51525. /**
  51526. * Override default engine behavior.
  51527. * @param color
  51528. * @param backBuffer
  51529. * @param depth
  51530. * @param stencil
  51531. */
  51532. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51533. /**
  51534. * Gets host document
  51535. * @returns the host document object
  51536. */
  51537. getHostDocument(): Nullable<Document>;
  51538. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51539. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51540. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51541. recordVertexArrayObject(vertexBuffers: {
  51542. [key: string]: VertexBuffer;
  51543. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51544. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51545. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51546. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51547. /**
  51548. * Draw a list of indexed primitives
  51549. * @param fillMode defines the primitive to use
  51550. * @param indexStart defines the starting index
  51551. * @param indexCount defines the number of index to draw
  51552. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51553. */
  51554. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51555. /**
  51556. * Draw a list of unindexed primitives
  51557. * @param fillMode defines the primitive to use
  51558. * @param verticesStart defines the index of first vertex to draw
  51559. * @param verticesCount defines the count of vertices to draw
  51560. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51561. */
  51562. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51563. createPipelineContext(): IPipelineContext;
  51564. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51565. /** @hidden */
  51566. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51567. /** @hidden */
  51568. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51569. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51570. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51571. protected _setProgram(program: WebGLProgram): void;
  51572. _releaseEffect(effect: Effect): void;
  51573. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51574. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51575. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51576. bindSamplers(effect: Effect): void;
  51577. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51578. getRenderWidth(useScreen?: boolean): number;
  51579. getRenderHeight(useScreen?: boolean): number;
  51580. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51581. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51582. /**
  51583. * Set the z offset to apply to current rendering
  51584. * @param value defines the offset to apply
  51585. */
  51586. setZOffset(value: number): void;
  51587. /**
  51588. * Gets the current value of the zOffset
  51589. * @returns the current zOffset state
  51590. */
  51591. getZOffset(): number;
  51592. /**
  51593. * Enable or disable depth buffering
  51594. * @param enable defines the state to set
  51595. */
  51596. setDepthBuffer(enable: boolean): void;
  51597. /**
  51598. * Gets a boolean indicating if depth writing is enabled
  51599. * @returns the current depth writing state
  51600. */
  51601. getDepthWrite(): boolean;
  51602. /**
  51603. * Enable or disable depth writing
  51604. * @param enable defines the state to set
  51605. */
  51606. setDepthWrite(enable: boolean): void;
  51607. /**
  51608. * Enable or disable color writing
  51609. * @param enable defines the state to set
  51610. */
  51611. setColorWrite(enable: boolean): void;
  51612. /**
  51613. * Gets a boolean indicating if color writing is enabled
  51614. * @returns the current color writing state
  51615. */
  51616. getColorWrite(): boolean;
  51617. /**
  51618. * Sets alpha constants used by some alpha blending modes
  51619. * @param r defines the red component
  51620. * @param g defines the green component
  51621. * @param b defines the blue component
  51622. * @param a defines the alpha component
  51623. */
  51624. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51625. /**
  51626. * Sets the current alpha mode
  51627. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51628. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51629. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51630. */
  51631. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51632. /**
  51633. * Gets the current alpha mode
  51634. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51635. * @returns the current alpha mode
  51636. */
  51637. getAlphaMode(): number;
  51638. setInt(uniform: WebGLUniformLocation, int: number): void;
  51639. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51640. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51641. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51642. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51643. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51644. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51645. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51646. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51647. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51648. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51649. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51650. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51651. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51652. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51653. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51654. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51655. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51656. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51657. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51658. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51659. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51660. wipeCaches(bruteForce?: boolean): void;
  51661. _createTexture(): WebGLTexture;
  51662. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51663. /**
  51664. * Usually called from Texture.ts.
  51665. * Passed information to create a WebGLTexture
  51666. * @param url defines a value which contains one of the following:
  51667. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51668. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51669. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51670. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51671. * @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)
  51672. * @param scene needed for loading to the correct scene
  51673. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51674. * @param onLoad optional callback to be called upon successful completion
  51675. * @param onError optional callback to be called upon failure
  51676. * @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
  51677. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51678. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51679. * @param forcedExtension defines the extension to use to pick the right loader
  51680. * @param mimeType defines an optional mime type
  51681. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51682. */
  51683. 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;
  51684. /**
  51685. * Creates a cube texture
  51686. * @param rootUrl defines the url where the files to load is located
  51687. * @param scene defines the current scene
  51688. * @param files defines the list of files to load (1 per face)
  51689. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51690. * @param onLoad defines an optional callback raised when the texture is loaded
  51691. * @param onError defines an optional callback raised if there is an issue to load the texture
  51692. * @param format defines the format of the data
  51693. * @param forcedExtension defines the extension to use to pick the right loader
  51694. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51695. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51696. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51697. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51698. * @returns the cube texture as an InternalTexture
  51699. */
  51700. 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;
  51701. private _getSamplingFilter;
  51702. private static _GetNativeTextureFormat;
  51703. createRenderTargetTexture(size: number | {
  51704. width: number;
  51705. height: number;
  51706. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51707. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51708. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51709. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51710. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51711. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51712. /**
  51713. * Updates a dynamic vertex buffer.
  51714. * @param vertexBuffer the vertex buffer to update
  51715. * @param data the data used to update the vertex buffer
  51716. * @param byteOffset the byte offset of the data (optional)
  51717. * @param byteLength the byte length of the data (optional)
  51718. */
  51719. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51720. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51721. private _updateAnisotropicLevel;
  51722. private _getAddressMode;
  51723. /** @hidden */
  51724. _bindTexture(channel: number, texture: InternalTexture): void;
  51725. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51726. releaseEffects(): void;
  51727. /** @hidden */
  51728. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51729. /** @hidden */
  51730. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51731. /** @hidden */
  51732. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51733. /** @hidden */
  51734. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51735. }
  51736. }
  51737. declare module BABYLON {
  51738. /**
  51739. * Gather the list of clipboard event types as constants.
  51740. */
  51741. export class ClipboardEventTypes {
  51742. /**
  51743. * The clipboard event is fired when a copy command is active (pressed).
  51744. */
  51745. static readonly COPY: number;
  51746. /**
  51747. * The clipboard event is fired when a cut command is active (pressed).
  51748. */
  51749. static readonly CUT: number;
  51750. /**
  51751. * The clipboard event is fired when a paste command is active (pressed).
  51752. */
  51753. static readonly PASTE: number;
  51754. }
  51755. /**
  51756. * This class is used to store clipboard related info for the onClipboardObservable event.
  51757. */
  51758. export class ClipboardInfo {
  51759. /**
  51760. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51761. */
  51762. type: number;
  51763. /**
  51764. * Defines the related dom event
  51765. */
  51766. event: ClipboardEvent;
  51767. /**
  51768. *Creates an instance of ClipboardInfo.
  51769. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51770. * @param event Defines the related dom event
  51771. */
  51772. constructor(
  51773. /**
  51774. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51775. */
  51776. type: number,
  51777. /**
  51778. * Defines the related dom event
  51779. */
  51780. event: ClipboardEvent);
  51781. /**
  51782. * Get the clipboard event's type from the keycode.
  51783. * @param keyCode Defines the keyCode for the current keyboard event.
  51784. * @return {number}
  51785. */
  51786. static GetTypeFromCharacter(keyCode: number): number;
  51787. }
  51788. }
  51789. declare module BABYLON {
  51790. /**
  51791. * Google Daydream controller
  51792. */
  51793. export class DaydreamController extends WebVRController {
  51794. /**
  51795. * Base Url for the controller model.
  51796. */
  51797. static MODEL_BASE_URL: string;
  51798. /**
  51799. * File name for the controller model.
  51800. */
  51801. static MODEL_FILENAME: string;
  51802. /**
  51803. * Gamepad Id prefix used to identify Daydream Controller.
  51804. */
  51805. static readonly GAMEPAD_ID_PREFIX: string;
  51806. /**
  51807. * Creates a new DaydreamController from a gamepad
  51808. * @param vrGamepad the gamepad that the controller should be created from
  51809. */
  51810. constructor(vrGamepad: any);
  51811. /**
  51812. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51813. * @param scene scene in which to add meshes
  51814. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51815. */
  51816. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51817. /**
  51818. * Called once for each button that changed state since the last frame
  51819. * @param buttonIdx Which button index changed
  51820. * @param state New state of the button
  51821. * @param changes Which properties on the state changed since last frame
  51822. */
  51823. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51824. }
  51825. }
  51826. declare module BABYLON {
  51827. /**
  51828. * Gear VR Controller
  51829. */
  51830. export class GearVRController extends WebVRController {
  51831. /**
  51832. * Base Url for the controller model.
  51833. */
  51834. static MODEL_BASE_URL: string;
  51835. /**
  51836. * File name for the controller model.
  51837. */
  51838. static MODEL_FILENAME: string;
  51839. /**
  51840. * Gamepad Id prefix used to identify this controller.
  51841. */
  51842. static readonly GAMEPAD_ID_PREFIX: string;
  51843. private readonly _buttonIndexToObservableNameMap;
  51844. /**
  51845. * Creates a new GearVRController from a gamepad
  51846. * @param vrGamepad the gamepad that the controller should be created from
  51847. */
  51848. constructor(vrGamepad: any);
  51849. /**
  51850. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51851. * @param scene scene in which to add meshes
  51852. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51853. */
  51854. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51855. /**
  51856. * Called once for each button that changed state since the last frame
  51857. * @param buttonIdx Which button index changed
  51858. * @param state New state of the button
  51859. * @param changes Which properties on the state changed since last frame
  51860. */
  51861. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51862. }
  51863. }
  51864. declare module BABYLON {
  51865. /**
  51866. * Generic Controller
  51867. */
  51868. export class GenericController extends WebVRController {
  51869. /**
  51870. * Base Url for the controller model.
  51871. */
  51872. static readonly MODEL_BASE_URL: string;
  51873. /**
  51874. * File name for the controller model.
  51875. */
  51876. static readonly MODEL_FILENAME: string;
  51877. /**
  51878. * Creates a new GenericController from a gamepad
  51879. * @param vrGamepad the gamepad that the controller should be created from
  51880. */
  51881. constructor(vrGamepad: any);
  51882. /**
  51883. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51884. * @param scene scene in which to add meshes
  51885. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51886. */
  51887. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51888. /**
  51889. * Called once for each button that changed state since the last frame
  51890. * @param buttonIdx Which button index changed
  51891. * @param state New state of the button
  51892. * @param changes Which properties on the state changed since last frame
  51893. */
  51894. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51895. }
  51896. }
  51897. declare module BABYLON {
  51898. /**
  51899. * Oculus Touch Controller
  51900. */
  51901. export class OculusTouchController extends WebVRController {
  51902. /**
  51903. * Base Url for the controller model.
  51904. */
  51905. static MODEL_BASE_URL: string;
  51906. /**
  51907. * File name for the left controller model.
  51908. */
  51909. static MODEL_LEFT_FILENAME: string;
  51910. /**
  51911. * File name for the right controller model.
  51912. */
  51913. static MODEL_RIGHT_FILENAME: string;
  51914. /**
  51915. * Base Url for the Quest controller model.
  51916. */
  51917. static QUEST_MODEL_BASE_URL: string;
  51918. /**
  51919. * @hidden
  51920. * If the controllers are running on a device that needs the updated Quest controller models
  51921. */
  51922. static _IsQuest: boolean;
  51923. /**
  51924. * Fired when the secondary trigger on this controller is modified
  51925. */
  51926. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51927. /**
  51928. * Fired when the thumb rest on this controller is modified
  51929. */
  51930. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51931. /**
  51932. * Creates a new OculusTouchController from a gamepad
  51933. * @param vrGamepad the gamepad that the controller should be created from
  51934. */
  51935. constructor(vrGamepad: any);
  51936. /**
  51937. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51938. * @param scene scene in which to add meshes
  51939. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51940. */
  51941. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51942. /**
  51943. * Fired when the A button on this controller is modified
  51944. */
  51945. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51946. /**
  51947. * Fired when the B button on this controller is modified
  51948. */
  51949. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51950. /**
  51951. * Fired when the X button on this controller is modified
  51952. */
  51953. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51954. /**
  51955. * Fired when the Y button on this controller is modified
  51956. */
  51957. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51958. /**
  51959. * Called once for each button that changed state since the last frame
  51960. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51961. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51962. * 2) secondary trigger (same)
  51963. * 3) A (right) X (left), touch, pressed = value
  51964. * 4) B / Y
  51965. * 5) thumb rest
  51966. * @param buttonIdx Which button index changed
  51967. * @param state New state of the button
  51968. * @param changes Which properties on the state changed since last frame
  51969. */
  51970. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51971. }
  51972. }
  51973. declare module BABYLON {
  51974. /**
  51975. * Vive Controller
  51976. */
  51977. export class ViveController extends WebVRController {
  51978. /**
  51979. * Base Url for the controller model.
  51980. */
  51981. static MODEL_BASE_URL: string;
  51982. /**
  51983. * File name for the controller model.
  51984. */
  51985. static MODEL_FILENAME: string;
  51986. /**
  51987. * Creates a new ViveController from a gamepad
  51988. * @param vrGamepad the gamepad that the controller should be created from
  51989. */
  51990. constructor(vrGamepad: any);
  51991. /**
  51992. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51993. * @param scene scene in which to add meshes
  51994. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51995. */
  51996. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51997. /**
  51998. * Fired when the left button on this controller is modified
  51999. */
  52000. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52001. /**
  52002. * Fired when the right button on this controller is modified
  52003. */
  52004. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52005. /**
  52006. * Fired when the menu button on this controller is modified
  52007. */
  52008. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52009. /**
  52010. * Called once for each button that changed state since the last frame
  52011. * Vive mapping:
  52012. * 0: touchpad
  52013. * 1: trigger
  52014. * 2: left AND right buttons
  52015. * 3: menu button
  52016. * @param buttonIdx Which button index changed
  52017. * @param state New state of the button
  52018. * @param changes Which properties on the state changed since last frame
  52019. */
  52020. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52021. }
  52022. }
  52023. declare module BABYLON {
  52024. /**
  52025. * Defines the WindowsMotionController object that the state of the windows motion controller
  52026. */
  52027. export class WindowsMotionController extends WebVRController {
  52028. /**
  52029. * The base url used to load the left and right controller models
  52030. */
  52031. static MODEL_BASE_URL: string;
  52032. /**
  52033. * The name of the left controller model file
  52034. */
  52035. static MODEL_LEFT_FILENAME: string;
  52036. /**
  52037. * The name of the right controller model file
  52038. */
  52039. static MODEL_RIGHT_FILENAME: string;
  52040. /**
  52041. * The controller name prefix for this controller type
  52042. */
  52043. static readonly GAMEPAD_ID_PREFIX: string;
  52044. /**
  52045. * The controller id pattern for this controller type
  52046. */
  52047. private static readonly GAMEPAD_ID_PATTERN;
  52048. private _loadedMeshInfo;
  52049. protected readonly _mapping: {
  52050. buttons: string[];
  52051. buttonMeshNames: {
  52052. trigger: string;
  52053. menu: string;
  52054. grip: string;
  52055. thumbstick: string;
  52056. trackpad: string;
  52057. };
  52058. buttonObservableNames: {
  52059. trigger: string;
  52060. menu: string;
  52061. grip: string;
  52062. thumbstick: string;
  52063. trackpad: string;
  52064. };
  52065. axisMeshNames: string[];
  52066. pointingPoseMeshName: string;
  52067. };
  52068. /**
  52069. * Fired when the trackpad on this controller is clicked
  52070. */
  52071. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52072. /**
  52073. * Fired when the trackpad on this controller is modified
  52074. */
  52075. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52076. /**
  52077. * The current x and y values of this controller's trackpad
  52078. */
  52079. trackpad: StickValues;
  52080. /**
  52081. * Creates a new WindowsMotionController from a gamepad
  52082. * @param vrGamepad the gamepad that the controller should be created from
  52083. */
  52084. constructor(vrGamepad: any);
  52085. /**
  52086. * Fired when the trigger on this controller is modified
  52087. */
  52088. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52089. /**
  52090. * Fired when the menu button on this controller is modified
  52091. */
  52092. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52093. /**
  52094. * Fired when the grip button on this controller is modified
  52095. */
  52096. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52097. /**
  52098. * Fired when the thumbstick button on this controller is modified
  52099. */
  52100. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52101. /**
  52102. * Fired when the touchpad button on this controller is modified
  52103. */
  52104. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52105. /**
  52106. * Fired when the touchpad values on this controller are modified
  52107. */
  52108. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52109. protected _updateTrackpad(): void;
  52110. /**
  52111. * Called once per frame by the engine.
  52112. */
  52113. update(): void;
  52114. /**
  52115. * Called once for each button that changed state since the last frame
  52116. * @param buttonIdx Which button index changed
  52117. * @param state New state of the button
  52118. * @param changes Which properties on the state changed since last frame
  52119. */
  52120. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52121. /**
  52122. * Moves the buttons on the controller mesh based on their current state
  52123. * @param buttonName the name of the button to move
  52124. * @param buttonValue the value of the button which determines the buttons new position
  52125. */
  52126. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52127. /**
  52128. * Moves the axis on the controller mesh based on its current state
  52129. * @param axis the index of the axis
  52130. * @param axisValue the value of the axis which determines the meshes new position
  52131. * @hidden
  52132. */
  52133. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52134. /**
  52135. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52136. * @param scene scene in which to add meshes
  52137. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52138. */
  52139. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52140. /**
  52141. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52142. * can be transformed by button presses and axes values, based on this._mapping.
  52143. *
  52144. * @param scene scene in which the meshes exist
  52145. * @param meshes list of meshes that make up the controller model to process
  52146. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52147. */
  52148. private processModel;
  52149. private createMeshInfo;
  52150. /**
  52151. * Gets the ray of the controller in the direction the controller is pointing
  52152. * @param length the length the resulting ray should be
  52153. * @returns a ray in the direction the controller is pointing
  52154. */
  52155. getForwardRay(length?: number): Ray;
  52156. /**
  52157. * Disposes of the controller
  52158. */
  52159. dispose(): void;
  52160. }
  52161. /**
  52162. * This class represents a new windows motion controller in XR.
  52163. */
  52164. export class XRWindowsMotionController extends WindowsMotionController {
  52165. /**
  52166. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52167. */
  52168. protected readonly _mapping: {
  52169. buttons: string[];
  52170. buttonMeshNames: {
  52171. trigger: string;
  52172. menu: string;
  52173. grip: string;
  52174. thumbstick: string;
  52175. trackpad: string;
  52176. };
  52177. buttonObservableNames: {
  52178. trigger: string;
  52179. menu: string;
  52180. grip: string;
  52181. thumbstick: string;
  52182. trackpad: string;
  52183. };
  52184. axisMeshNames: string[];
  52185. pointingPoseMeshName: string;
  52186. };
  52187. /**
  52188. * Construct a new XR-Based windows motion controller
  52189. *
  52190. * @param gamepadInfo the gamepad object from the browser
  52191. */
  52192. constructor(gamepadInfo: any);
  52193. /**
  52194. * holds the thumbstick values (X,Y)
  52195. */
  52196. thumbstickValues: StickValues;
  52197. /**
  52198. * Fired when the thumbstick on this controller is clicked
  52199. */
  52200. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52201. /**
  52202. * Fired when the thumbstick on this controller is modified
  52203. */
  52204. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52205. /**
  52206. * Fired when the touchpad button on this controller is modified
  52207. */
  52208. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52209. /**
  52210. * Fired when the touchpad values on this controller are modified
  52211. */
  52212. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52213. /**
  52214. * Fired when the thumbstick button on this controller is modified
  52215. * here to prevent breaking changes
  52216. */
  52217. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52218. /**
  52219. * updating the thumbstick(!) and not the trackpad.
  52220. * This is named this way due to the difference between WebVR and XR and to avoid
  52221. * changing the parent class.
  52222. */
  52223. protected _updateTrackpad(): void;
  52224. /**
  52225. * Disposes the class with joy
  52226. */
  52227. dispose(): void;
  52228. }
  52229. }
  52230. declare module BABYLON {
  52231. /**
  52232. * Class containing static functions to help procedurally build meshes
  52233. */
  52234. export class PolyhedronBuilder {
  52235. /**
  52236. * Creates a polyhedron mesh
  52237. * * 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
  52238. * * The parameter `size` (positive float, default 1) sets the polygon size
  52239. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52240. * * 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`
  52241. * * 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
  52242. * * 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)`)
  52243. * * 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
  52244. * * 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
  52245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52246. * * 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
  52247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52248. * @param name defines the name of the mesh
  52249. * @param options defines the options used to create the mesh
  52250. * @param scene defines the hosting scene
  52251. * @returns the polyhedron mesh
  52252. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52253. */
  52254. static CreatePolyhedron(name: string, options: {
  52255. type?: number;
  52256. size?: number;
  52257. sizeX?: number;
  52258. sizeY?: number;
  52259. sizeZ?: number;
  52260. custom?: any;
  52261. faceUV?: Vector4[];
  52262. faceColors?: Color4[];
  52263. flat?: boolean;
  52264. updatable?: boolean;
  52265. sideOrientation?: number;
  52266. frontUVs?: Vector4;
  52267. backUVs?: Vector4;
  52268. }, scene?: Nullable<Scene>): Mesh;
  52269. }
  52270. }
  52271. declare module BABYLON {
  52272. /**
  52273. * Gizmo that enables scaling a mesh along 3 axis
  52274. */
  52275. export class ScaleGizmo extends Gizmo {
  52276. /**
  52277. * Internal gizmo used for interactions on the x axis
  52278. */
  52279. xGizmo: AxisScaleGizmo;
  52280. /**
  52281. * Internal gizmo used for interactions on the y axis
  52282. */
  52283. yGizmo: AxisScaleGizmo;
  52284. /**
  52285. * Internal gizmo used for interactions on the z axis
  52286. */
  52287. zGizmo: AxisScaleGizmo;
  52288. /**
  52289. * Internal gizmo used to scale all axis equally
  52290. */
  52291. uniformScaleGizmo: AxisScaleGizmo;
  52292. private _meshAttached;
  52293. private _updateGizmoRotationToMatchAttachedMesh;
  52294. private _snapDistance;
  52295. private _scaleRatio;
  52296. private _uniformScalingMesh;
  52297. private _octahedron;
  52298. private _sensitivity;
  52299. /** Fires an event when any of it's sub gizmos are dragged */
  52300. onDragStartObservable: Observable<unknown>;
  52301. /** Fires an event when any of it's sub gizmos are released from dragging */
  52302. onDragEndObservable: Observable<unknown>;
  52303. get attachedMesh(): Nullable<AbstractMesh>;
  52304. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52305. /**
  52306. * Creates a ScaleGizmo
  52307. * @param gizmoLayer The utility layer the gizmo will be added to
  52308. */
  52309. constructor(gizmoLayer?: UtilityLayerRenderer);
  52310. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52311. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52312. /**
  52313. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52314. */
  52315. set snapDistance(value: number);
  52316. get snapDistance(): number;
  52317. /**
  52318. * Ratio for the scale of the gizmo (Default: 1)
  52319. */
  52320. set scaleRatio(value: number);
  52321. get scaleRatio(): number;
  52322. /**
  52323. * Sensitivity factor for dragging (Default: 1)
  52324. */
  52325. set sensitivity(value: number);
  52326. get sensitivity(): number;
  52327. /**
  52328. * Disposes of the gizmo
  52329. */
  52330. dispose(): void;
  52331. }
  52332. }
  52333. declare module BABYLON {
  52334. /**
  52335. * Single axis scale gizmo
  52336. */
  52337. export class AxisScaleGizmo extends Gizmo {
  52338. /**
  52339. * Drag behavior responsible for the gizmos dragging interactions
  52340. */
  52341. dragBehavior: PointerDragBehavior;
  52342. private _pointerObserver;
  52343. /**
  52344. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52345. */
  52346. snapDistance: number;
  52347. /**
  52348. * Event that fires each time the gizmo snaps to a new location.
  52349. * * snapDistance is the the change in distance
  52350. */
  52351. onSnapObservable: Observable<{
  52352. snapDistance: number;
  52353. }>;
  52354. /**
  52355. * If the scaling operation should be done on all axis (default: false)
  52356. */
  52357. uniformScaling: boolean;
  52358. /**
  52359. * Custom sensitivity value for the drag strength
  52360. */
  52361. sensitivity: number;
  52362. private _isEnabled;
  52363. private _parent;
  52364. private _arrow;
  52365. private _coloredMaterial;
  52366. private _hoverMaterial;
  52367. /**
  52368. * Creates an AxisScaleGizmo
  52369. * @param gizmoLayer The utility layer the gizmo will be added to
  52370. * @param dragAxis The axis which the gizmo will be able to scale on
  52371. * @param color The color of the gizmo
  52372. */
  52373. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52374. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52375. /**
  52376. * If the gizmo is enabled
  52377. */
  52378. set isEnabled(value: boolean);
  52379. get isEnabled(): boolean;
  52380. /**
  52381. * Disposes of the gizmo
  52382. */
  52383. dispose(): void;
  52384. /**
  52385. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52386. * @param mesh The mesh to replace the default mesh of the gizmo
  52387. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52388. */
  52389. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52390. }
  52391. }
  52392. declare module BABYLON {
  52393. /**
  52394. * Bounding box gizmo
  52395. */
  52396. export class BoundingBoxGizmo extends Gizmo {
  52397. private _lineBoundingBox;
  52398. private _rotateSpheresParent;
  52399. private _scaleBoxesParent;
  52400. private _boundingDimensions;
  52401. private _renderObserver;
  52402. private _pointerObserver;
  52403. private _scaleDragSpeed;
  52404. private _tmpQuaternion;
  52405. private _tmpVector;
  52406. private _tmpRotationMatrix;
  52407. /**
  52408. * 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)
  52409. */
  52410. ignoreChildren: boolean;
  52411. /**
  52412. * 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)
  52413. */
  52414. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52415. /**
  52416. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52417. */
  52418. rotationSphereSize: number;
  52419. /**
  52420. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52421. */
  52422. scaleBoxSize: number;
  52423. /**
  52424. * 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)
  52425. */
  52426. fixedDragMeshScreenSize: boolean;
  52427. /**
  52428. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52429. */
  52430. fixedDragMeshScreenSizeDistanceFactor: number;
  52431. /**
  52432. * Fired when a rotation sphere or scale box is dragged
  52433. */
  52434. onDragStartObservable: Observable<{}>;
  52435. /**
  52436. * Fired when a scale box is dragged
  52437. */
  52438. onScaleBoxDragObservable: Observable<{}>;
  52439. /**
  52440. * Fired when a scale box drag is ended
  52441. */
  52442. onScaleBoxDragEndObservable: Observable<{}>;
  52443. /**
  52444. * Fired when a rotation sphere is dragged
  52445. */
  52446. onRotationSphereDragObservable: Observable<{}>;
  52447. /**
  52448. * Fired when a rotation sphere drag is ended
  52449. */
  52450. onRotationSphereDragEndObservable: Observable<{}>;
  52451. /**
  52452. * 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)
  52453. */
  52454. scalePivot: Nullable<Vector3>;
  52455. /**
  52456. * Mesh used as a pivot to rotate the attached mesh
  52457. */
  52458. private _anchorMesh;
  52459. private _existingMeshScale;
  52460. private _dragMesh;
  52461. private pointerDragBehavior;
  52462. private coloredMaterial;
  52463. private hoverColoredMaterial;
  52464. /**
  52465. * Sets the color of the bounding box gizmo
  52466. * @param color the color to set
  52467. */
  52468. setColor(color: Color3): void;
  52469. /**
  52470. * Creates an BoundingBoxGizmo
  52471. * @param gizmoLayer The utility layer the gizmo will be added to
  52472. * @param color The color of the gizmo
  52473. */
  52474. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52475. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52476. private _selectNode;
  52477. /**
  52478. * Updates the bounding box information for the Gizmo
  52479. */
  52480. updateBoundingBox(): void;
  52481. private _updateRotationSpheres;
  52482. private _updateScaleBoxes;
  52483. /**
  52484. * Enables rotation on the specified axis and disables rotation on the others
  52485. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52486. */
  52487. setEnabledRotationAxis(axis: string): void;
  52488. /**
  52489. * Enables/disables scaling
  52490. * @param enable if scaling should be enabled
  52491. * @param homogeneousScaling defines if scaling should only be homogeneous
  52492. */
  52493. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52494. private _updateDummy;
  52495. /**
  52496. * Enables a pointer drag behavior on the bounding box of the gizmo
  52497. */
  52498. enableDragBehavior(): void;
  52499. /**
  52500. * Disposes of the gizmo
  52501. */
  52502. dispose(): void;
  52503. /**
  52504. * 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)
  52505. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52506. * @returns the bounding box mesh with the passed in mesh as a child
  52507. */
  52508. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52509. /**
  52510. * CustomMeshes are not supported by this gizmo
  52511. * @param mesh The mesh to replace the default mesh of the gizmo
  52512. */
  52513. setCustomMesh(mesh: Mesh): void;
  52514. }
  52515. }
  52516. declare module BABYLON {
  52517. /**
  52518. * Single plane rotation gizmo
  52519. */
  52520. export class PlaneRotationGizmo extends Gizmo {
  52521. /**
  52522. * Drag behavior responsible for the gizmos dragging interactions
  52523. */
  52524. dragBehavior: PointerDragBehavior;
  52525. private _pointerObserver;
  52526. /**
  52527. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52528. */
  52529. snapDistance: number;
  52530. /**
  52531. * Event that fires each time the gizmo snaps to a new location.
  52532. * * snapDistance is the the change in distance
  52533. */
  52534. onSnapObservable: Observable<{
  52535. snapDistance: number;
  52536. }>;
  52537. private _isEnabled;
  52538. private _parent;
  52539. /**
  52540. * Creates a PlaneRotationGizmo
  52541. * @param gizmoLayer The utility layer the gizmo will be added to
  52542. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52543. * @param color The color of the gizmo
  52544. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52545. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52546. */
  52547. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52548. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52549. /**
  52550. * If the gizmo is enabled
  52551. */
  52552. set isEnabled(value: boolean);
  52553. get isEnabled(): boolean;
  52554. /**
  52555. * Disposes of the gizmo
  52556. */
  52557. dispose(): void;
  52558. }
  52559. }
  52560. declare module BABYLON {
  52561. /**
  52562. * Gizmo that enables rotating a mesh along 3 axis
  52563. */
  52564. export class RotationGizmo extends Gizmo {
  52565. /**
  52566. * Internal gizmo used for interactions on the x axis
  52567. */
  52568. xGizmo: PlaneRotationGizmo;
  52569. /**
  52570. * Internal gizmo used for interactions on the y axis
  52571. */
  52572. yGizmo: PlaneRotationGizmo;
  52573. /**
  52574. * Internal gizmo used for interactions on the z axis
  52575. */
  52576. zGizmo: PlaneRotationGizmo;
  52577. /** Fires an event when any of it's sub gizmos are dragged */
  52578. onDragStartObservable: Observable<unknown>;
  52579. /** Fires an event when any of it's sub gizmos are released from dragging */
  52580. onDragEndObservable: Observable<unknown>;
  52581. private _meshAttached;
  52582. get attachedMesh(): Nullable<AbstractMesh>;
  52583. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52584. /**
  52585. * Creates a RotationGizmo
  52586. * @param gizmoLayer The utility layer the gizmo will be added to
  52587. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52588. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52589. */
  52590. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52591. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52592. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52593. /**
  52594. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52595. */
  52596. set snapDistance(value: number);
  52597. get snapDistance(): number;
  52598. /**
  52599. * Ratio for the scale of the gizmo (Default: 1)
  52600. */
  52601. set scaleRatio(value: number);
  52602. get scaleRatio(): number;
  52603. /**
  52604. * Disposes of the gizmo
  52605. */
  52606. dispose(): void;
  52607. /**
  52608. * CustomMeshes are not supported by this gizmo
  52609. * @param mesh The mesh to replace the default mesh of the gizmo
  52610. */
  52611. setCustomMesh(mesh: Mesh): void;
  52612. }
  52613. }
  52614. declare module BABYLON {
  52615. /**
  52616. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52617. */
  52618. export class GizmoManager implements IDisposable {
  52619. private scene;
  52620. /**
  52621. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52622. */
  52623. gizmos: {
  52624. positionGizmo: Nullable<PositionGizmo>;
  52625. rotationGizmo: Nullable<RotationGizmo>;
  52626. scaleGizmo: Nullable<ScaleGizmo>;
  52627. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52628. };
  52629. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52630. clearGizmoOnEmptyPointerEvent: boolean;
  52631. /** Fires an event when the manager is attached to a mesh */
  52632. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52633. private _gizmosEnabled;
  52634. private _pointerObserver;
  52635. private _attachedMesh;
  52636. private _boundingBoxColor;
  52637. private _defaultUtilityLayer;
  52638. private _defaultKeepDepthUtilityLayer;
  52639. /**
  52640. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52641. */
  52642. boundingBoxDragBehavior: SixDofDragBehavior;
  52643. /**
  52644. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52645. */
  52646. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52647. /**
  52648. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52649. */
  52650. usePointerToAttachGizmos: boolean;
  52651. /**
  52652. * Utility layer that the bounding box gizmo belongs to
  52653. */
  52654. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52655. /**
  52656. * Utility layer that all gizmos besides bounding box belong to
  52657. */
  52658. get utilityLayer(): UtilityLayerRenderer;
  52659. /**
  52660. * Instatiates a gizmo manager
  52661. * @param scene the scene to overlay the gizmos on top of
  52662. */
  52663. constructor(scene: Scene);
  52664. /**
  52665. * Attaches a set of gizmos to the specified mesh
  52666. * @param mesh The mesh the gizmo's should be attached to
  52667. */
  52668. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52669. /**
  52670. * If the position gizmo is enabled
  52671. */
  52672. set positionGizmoEnabled(value: boolean);
  52673. get positionGizmoEnabled(): boolean;
  52674. /**
  52675. * If the rotation gizmo is enabled
  52676. */
  52677. set rotationGizmoEnabled(value: boolean);
  52678. get rotationGizmoEnabled(): boolean;
  52679. /**
  52680. * If the scale gizmo is enabled
  52681. */
  52682. set scaleGizmoEnabled(value: boolean);
  52683. get scaleGizmoEnabled(): boolean;
  52684. /**
  52685. * If the boundingBox gizmo is enabled
  52686. */
  52687. set boundingBoxGizmoEnabled(value: boolean);
  52688. get boundingBoxGizmoEnabled(): boolean;
  52689. /**
  52690. * Disposes of the gizmo manager
  52691. */
  52692. dispose(): void;
  52693. }
  52694. }
  52695. declare module BABYLON {
  52696. /**
  52697. * A directional light is defined by a direction (what a surprise!).
  52698. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52699. * 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.
  52700. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52701. */
  52702. export class DirectionalLight extends ShadowLight {
  52703. private _shadowFrustumSize;
  52704. /**
  52705. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52706. */
  52707. get shadowFrustumSize(): number;
  52708. /**
  52709. * Specifies a fix frustum size for the shadow generation.
  52710. */
  52711. set shadowFrustumSize(value: number);
  52712. private _shadowOrthoScale;
  52713. /**
  52714. * Gets the shadow projection scale against the optimal computed one.
  52715. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52716. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52717. */
  52718. get shadowOrthoScale(): number;
  52719. /**
  52720. * Sets the shadow projection scale against the optimal computed one.
  52721. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52722. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52723. */
  52724. set shadowOrthoScale(value: number);
  52725. /**
  52726. * Automatically compute the projection matrix to best fit (including all the casters)
  52727. * on each frame.
  52728. */
  52729. autoUpdateExtends: boolean;
  52730. /**
  52731. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52732. * on each frame. autoUpdateExtends must be set to true for this to work
  52733. */
  52734. autoCalcShadowZBounds: boolean;
  52735. private _orthoLeft;
  52736. private _orthoRight;
  52737. private _orthoTop;
  52738. private _orthoBottom;
  52739. /**
  52740. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52741. * The directional light is emitted from everywhere in the given direction.
  52742. * It can cast shadows.
  52743. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52744. * @param name The friendly name of the light
  52745. * @param direction The direction of the light
  52746. * @param scene The scene the light belongs to
  52747. */
  52748. constructor(name: string, direction: Vector3, scene: Scene);
  52749. /**
  52750. * Returns the string "DirectionalLight".
  52751. * @return The class name
  52752. */
  52753. getClassName(): string;
  52754. /**
  52755. * Returns the integer 1.
  52756. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52757. */
  52758. getTypeID(): number;
  52759. /**
  52760. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52761. * Returns the DirectionalLight Shadow projection matrix.
  52762. */
  52763. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52764. /**
  52765. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52766. * Returns the DirectionalLight Shadow projection matrix.
  52767. */
  52768. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52769. /**
  52770. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52771. * Returns the DirectionalLight Shadow projection matrix.
  52772. */
  52773. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52774. protected _buildUniformLayout(): void;
  52775. /**
  52776. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52777. * @param effect The effect to update
  52778. * @param lightIndex The index of the light in the effect to update
  52779. * @returns The directional light
  52780. */
  52781. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52782. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52783. /**
  52784. * Gets the minZ used for shadow according to both the scene and the light.
  52785. *
  52786. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52787. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52788. * @param activeCamera The camera we are returning the min for
  52789. * @returns the depth min z
  52790. */
  52791. getDepthMinZ(activeCamera: Camera): number;
  52792. /**
  52793. * Gets the maxZ used for shadow according to both the scene and the light.
  52794. *
  52795. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52796. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52797. * @param activeCamera The camera we are returning the max for
  52798. * @returns the depth max z
  52799. */
  52800. getDepthMaxZ(activeCamera: Camera): number;
  52801. /**
  52802. * Prepares the list of defines specific to the light type.
  52803. * @param defines the list of defines
  52804. * @param lightIndex defines the index of the light for the effect
  52805. */
  52806. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52807. }
  52808. }
  52809. declare module BABYLON {
  52810. /**
  52811. * Class containing static functions to help procedurally build meshes
  52812. */
  52813. export class HemisphereBuilder {
  52814. /**
  52815. * Creates a hemisphere mesh
  52816. * @param name defines the name of the mesh
  52817. * @param options defines the options used to create the mesh
  52818. * @param scene defines the hosting scene
  52819. * @returns the hemisphere mesh
  52820. */
  52821. static CreateHemisphere(name: string, options: {
  52822. segments?: number;
  52823. diameter?: number;
  52824. sideOrientation?: number;
  52825. }, scene: any): Mesh;
  52826. }
  52827. }
  52828. declare module BABYLON {
  52829. /**
  52830. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52831. * These values define a cone of light starting from the position, emitting toward the direction.
  52832. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52833. * and the exponent defines the speed of the decay of the light with distance (reach).
  52834. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52835. */
  52836. export class SpotLight extends ShadowLight {
  52837. private _angle;
  52838. private _innerAngle;
  52839. private _cosHalfAngle;
  52840. private _lightAngleScale;
  52841. private _lightAngleOffset;
  52842. /**
  52843. * Gets the cone angle of the spot light in Radians.
  52844. */
  52845. get angle(): number;
  52846. /**
  52847. * Sets the cone angle of the spot light in Radians.
  52848. */
  52849. set angle(value: number);
  52850. /**
  52851. * Only used in gltf falloff mode, this defines the angle where
  52852. * the directional falloff will start before cutting at angle which could be seen
  52853. * as outer angle.
  52854. */
  52855. get innerAngle(): number;
  52856. /**
  52857. * Only used in gltf falloff mode, this defines the angle where
  52858. * the directional falloff will start before cutting at angle which could be seen
  52859. * as outer angle.
  52860. */
  52861. set innerAngle(value: number);
  52862. private _shadowAngleScale;
  52863. /**
  52864. * Allows scaling the angle of the light for shadow generation only.
  52865. */
  52866. get shadowAngleScale(): number;
  52867. /**
  52868. * Allows scaling the angle of the light for shadow generation only.
  52869. */
  52870. set shadowAngleScale(value: number);
  52871. /**
  52872. * The light decay speed with the distance from the emission spot.
  52873. */
  52874. exponent: number;
  52875. private _projectionTextureMatrix;
  52876. /**
  52877. * Allows reading the projecton texture
  52878. */
  52879. get projectionTextureMatrix(): Matrix;
  52880. protected _projectionTextureLightNear: number;
  52881. /**
  52882. * Gets the near clip of the Spotlight for texture projection.
  52883. */
  52884. get projectionTextureLightNear(): number;
  52885. /**
  52886. * Sets the near clip of the Spotlight for texture projection.
  52887. */
  52888. set projectionTextureLightNear(value: number);
  52889. protected _projectionTextureLightFar: number;
  52890. /**
  52891. * Gets the far clip of the Spotlight for texture projection.
  52892. */
  52893. get projectionTextureLightFar(): number;
  52894. /**
  52895. * Sets the far clip of the Spotlight for texture projection.
  52896. */
  52897. set projectionTextureLightFar(value: number);
  52898. protected _projectionTextureUpDirection: Vector3;
  52899. /**
  52900. * Gets the Up vector of the Spotlight for texture projection.
  52901. */
  52902. get projectionTextureUpDirection(): Vector3;
  52903. /**
  52904. * Sets the Up vector of the Spotlight for texture projection.
  52905. */
  52906. set projectionTextureUpDirection(value: Vector3);
  52907. private _projectionTexture;
  52908. /**
  52909. * Gets the projection texture of the light.
  52910. */
  52911. get projectionTexture(): Nullable<BaseTexture>;
  52912. /**
  52913. * Sets the projection texture of the light.
  52914. */
  52915. set projectionTexture(value: Nullable<BaseTexture>);
  52916. private _projectionTextureViewLightDirty;
  52917. private _projectionTextureProjectionLightDirty;
  52918. private _projectionTextureDirty;
  52919. private _projectionTextureViewTargetVector;
  52920. private _projectionTextureViewLightMatrix;
  52921. private _projectionTextureProjectionLightMatrix;
  52922. private _projectionTextureScalingMatrix;
  52923. /**
  52924. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52925. * It can cast shadows.
  52926. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52927. * @param name The light friendly name
  52928. * @param position The position of the spot light in the scene
  52929. * @param direction The direction of the light in the scene
  52930. * @param angle The cone angle of the light in Radians
  52931. * @param exponent The light decay speed with the distance from the emission spot
  52932. * @param scene The scene the lights belongs to
  52933. */
  52934. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52935. /**
  52936. * Returns the string "SpotLight".
  52937. * @returns the class name
  52938. */
  52939. getClassName(): string;
  52940. /**
  52941. * Returns the integer 2.
  52942. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52943. */
  52944. getTypeID(): number;
  52945. /**
  52946. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52947. */
  52948. protected _setDirection(value: Vector3): void;
  52949. /**
  52950. * Overrides the position setter to recompute the projection texture view light Matrix.
  52951. */
  52952. protected _setPosition(value: Vector3): void;
  52953. /**
  52954. * 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.
  52955. * Returns the SpotLight.
  52956. */
  52957. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52958. protected _computeProjectionTextureViewLightMatrix(): void;
  52959. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52960. /**
  52961. * Main function for light texture projection matrix computing.
  52962. */
  52963. protected _computeProjectionTextureMatrix(): void;
  52964. protected _buildUniformLayout(): void;
  52965. private _computeAngleValues;
  52966. /**
  52967. * Sets the passed Effect "effect" with the Light textures.
  52968. * @param effect The effect to update
  52969. * @param lightIndex The index of the light in the effect to update
  52970. * @returns The light
  52971. */
  52972. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52973. /**
  52974. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52975. * @param effect The effect to update
  52976. * @param lightIndex The index of the light in the effect to update
  52977. * @returns The spot light
  52978. */
  52979. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52980. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52981. /**
  52982. * Disposes the light and the associated resources.
  52983. */
  52984. dispose(): void;
  52985. /**
  52986. * Prepares the list of defines specific to the light type.
  52987. * @param defines the list of defines
  52988. * @param lightIndex defines the index of the light for the effect
  52989. */
  52990. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52991. }
  52992. }
  52993. declare module BABYLON {
  52994. /**
  52995. * Gizmo that enables viewing a light
  52996. */
  52997. export class LightGizmo extends Gizmo {
  52998. private _lightMesh;
  52999. private _material;
  53000. private _cachedPosition;
  53001. private _cachedForward;
  53002. private _attachedMeshParent;
  53003. /**
  53004. * Creates a LightGizmo
  53005. * @param gizmoLayer The utility layer the gizmo will be added to
  53006. */
  53007. constructor(gizmoLayer?: UtilityLayerRenderer);
  53008. private _light;
  53009. /**
  53010. * The light that the gizmo is attached to
  53011. */
  53012. set light(light: Nullable<Light>);
  53013. get light(): Nullable<Light>;
  53014. /**
  53015. * Gets the material used to render the light gizmo
  53016. */
  53017. get material(): StandardMaterial;
  53018. /**
  53019. * @hidden
  53020. * Updates the gizmo to match the attached mesh's position/rotation
  53021. */
  53022. protected _update(): void;
  53023. private static _Scale;
  53024. /**
  53025. * Creates the lines for a light mesh
  53026. */
  53027. private static _CreateLightLines;
  53028. /**
  53029. * Disposes of the light gizmo
  53030. */
  53031. dispose(): void;
  53032. private static _CreateHemisphericLightMesh;
  53033. private static _CreatePointLightMesh;
  53034. private static _CreateSpotLightMesh;
  53035. private static _CreateDirectionalLightMesh;
  53036. }
  53037. }
  53038. declare module BABYLON {
  53039. /** @hidden */
  53040. export var backgroundFragmentDeclaration: {
  53041. name: string;
  53042. shader: string;
  53043. };
  53044. }
  53045. declare module BABYLON {
  53046. /** @hidden */
  53047. export var backgroundUboDeclaration: {
  53048. name: string;
  53049. shader: string;
  53050. };
  53051. }
  53052. declare module BABYLON {
  53053. /** @hidden */
  53054. export var backgroundPixelShader: {
  53055. name: string;
  53056. shader: string;
  53057. };
  53058. }
  53059. declare module BABYLON {
  53060. /** @hidden */
  53061. export var backgroundVertexDeclaration: {
  53062. name: string;
  53063. shader: string;
  53064. };
  53065. }
  53066. declare module BABYLON {
  53067. /** @hidden */
  53068. export var backgroundVertexShader: {
  53069. name: string;
  53070. shader: string;
  53071. };
  53072. }
  53073. declare module BABYLON {
  53074. /**
  53075. * Background material used to create an efficient environement around your scene.
  53076. */
  53077. export class BackgroundMaterial extends PushMaterial {
  53078. /**
  53079. * Standard reflectance value at parallel view angle.
  53080. */
  53081. static StandardReflectance0: number;
  53082. /**
  53083. * Standard reflectance value at grazing angle.
  53084. */
  53085. static StandardReflectance90: number;
  53086. protected _primaryColor: Color3;
  53087. /**
  53088. * Key light Color (multiply against the environement texture)
  53089. */
  53090. primaryColor: Color3;
  53091. protected __perceptualColor: Nullable<Color3>;
  53092. /**
  53093. * Experimental Internal Use Only.
  53094. *
  53095. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53096. * This acts as a helper to set the primary color to a more "human friendly" value.
  53097. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53098. * output color as close as possible from the chosen value.
  53099. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53100. * part of lighting setup.)
  53101. */
  53102. get _perceptualColor(): Nullable<Color3>;
  53103. set _perceptualColor(value: Nullable<Color3>);
  53104. protected _primaryColorShadowLevel: float;
  53105. /**
  53106. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53107. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53108. */
  53109. get primaryColorShadowLevel(): float;
  53110. set primaryColorShadowLevel(value: float);
  53111. protected _primaryColorHighlightLevel: float;
  53112. /**
  53113. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53114. * The primary color is used at the level chosen to define what the white area would look.
  53115. */
  53116. get primaryColorHighlightLevel(): float;
  53117. set primaryColorHighlightLevel(value: float);
  53118. protected _reflectionTexture: Nullable<BaseTexture>;
  53119. /**
  53120. * Reflection Texture used in the material.
  53121. * Should be author in a specific way for the best result (refer to the documentation).
  53122. */
  53123. reflectionTexture: Nullable<BaseTexture>;
  53124. protected _reflectionBlur: float;
  53125. /**
  53126. * Reflection Texture level of blur.
  53127. *
  53128. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53129. * texture twice.
  53130. */
  53131. reflectionBlur: float;
  53132. protected _diffuseTexture: Nullable<BaseTexture>;
  53133. /**
  53134. * Diffuse Texture used in the material.
  53135. * Should be author in a specific way for the best result (refer to the documentation).
  53136. */
  53137. diffuseTexture: Nullable<BaseTexture>;
  53138. protected _shadowLights: Nullable<IShadowLight[]>;
  53139. /**
  53140. * Specify the list of lights casting shadow on the material.
  53141. * All scene shadow lights will be included if null.
  53142. */
  53143. shadowLights: Nullable<IShadowLight[]>;
  53144. protected _shadowLevel: float;
  53145. /**
  53146. * Helps adjusting the shadow to a softer level if required.
  53147. * 0 means black shadows and 1 means no shadows.
  53148. */
  53149. shadowLevel: float;
  53150. protected _sceneCenter: Vector3;
  53151. /**
  53152. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53153. * It is usually zero but might be interesting to modify according to your setup.
  53154. */
  53155. sceneCenter: Vector3;
  53156. protected _opacityFresnel: boolean;
  53157. /**
  53158. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53159. * This helps ensuring a nice transition when the camera goes under the ground.
  53160. */
  53161. opacityFresnel: boolean;
  53162. protected _reflectionFresnel: boolean;
  53163. /**
  53164. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53165. * This helps adding a mirror texture on the ground.
  53166. */
  53167. reflectionFresnel: boolean;
  53168. protected _reflectionFalloffDistance: number;
  53169. /**
  53170. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53171. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53172. */
  53173. reflectionFalloffDistance: number;
  53174. protected _reflectionAmount: number;
  53175. /**
  53176. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53177. */
  53178. reflectionAmount: number;
  53179. protected _reflectionReflectance0: number;
  53180. /**
  53181. * This specifies the weight of the reflection at grazing angle.
  53182. */
  53183. reflectionReflectance0: number;
  53184. protected _reflectionReflectance90: number;
  53185. /**
  53186. * This specifies the weight of the reflection at a perpendicular point of view.
  53187. */
  53188. reflectionReflectance90: number;
  53189. /**
  53190. * Sets the reflection reflectance fresnel values according to the default standard
  53191. * empirically know to work well :-)
  53192. */
  53193. set reflectionStandardFresnelWeight(value: number);
  53194. protected _useRGBColor: boolean;
  53195. /**
  53196. * Helps to directly use the maps channels instead of their level.
  53197. */
  53198. useRGBColor: boolean;
  53199. protected _enableNoise: boolean;
  53200. /**
  53201. * This helps reducing the banding effect that could occur on the background.
  53202. */
  53203. enableNoise: boolean;
  53204. /**
  53205. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53206. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53207. * Recommended to be keep at 1.0 except for special cases.
  53208. */
  53209. get fovMultiplier(): number;
  53210. set fovMultiplier(value: number);
  53211. private _fovMultiplier;
  53212. /**
  53213. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53214. */
  53215. useEquirectangularFOV: boolean;
  53216. private _maxSimultaneousLights;
  53217. /**
  53218. * Number of Simultaneous lights allowed on the material.
  53219. */
  53220. maxSimultaneousLights: int;
  53221. /**
  53222. * Default configuration related to image processing available in the Background Material.
  53223. */
  53224. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53225. /**
  53226. * Keep track of the image processing observer to allow dispose and replace.
  53227. */
  53228. private _imageProcessingObserver;
  53229. /**
  53230. * Attaches a new image processing configuration to the PBR Material.
  53231. * @param configuration (if null the scene configuration will be use)
  53232. */
  53233. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53234. /**
  53235. * Gets the image processing configuration used either in this material.
  53236. */
  53237. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53238. /**
  53239. * Sets the Default image processing configuration used either in the this material.
  53240. *
  53241. * If sets to null, the scene one is in use.
  53242. */
  53243. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53244. /**
  53245. * Gets wether the color curves effect is enabled.
  53246. */
  53247. get cameraColorCurvesEnabled(): boolean;
  53248. /**
  53249. * Sets wether the color curves effect is enabled.
  53250. */
  53251. set cameraColorCurvesEnabled(value: boolean);
  53252. /**
  53253. * Gets wether the color grading effect is enabled.
  53254. */
  53255. get cameraColorGradingEnabled(): boolean;
  53256. /**
  53257. * Gets wether the color grading effect is enabled.
  53258. */
  53259. set cameraColorGradingEnabled(value: boolean);
  53260. /**
  53261. * Gets wether tonemapping is enabled or not.
  53262. */
  53263. get cameraToneMappingEnabled(): boolean;
  53264. /**
  53265. * Sets wether tonemapping is enabled or not
  53266. */
  53267. set cameraToneMappingEnabled(value: boolean);
  53268. /**
  53269. * The camera exposure used on this material.
  53270. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53271. * This corresponds to a photographic exposure.
  53272. */
  53273. get cameraExposure(): float;
  53274. /**
  53275. * The camera exposure used on this material.
  53276. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53277. * This corresponds to a photographic exposure.
  53278. */
  53279. set cameraExposure(value: float);
  53280. /**
  53281. * Gets The camera contrast used on this material.
  53282. */
  53283. get cameraContrast(): float;
  53284. /**
  53285. * Sets The camera contrast used on this material.
  53286. */
  53287. set cameraContrast(value: float);
  53288. /**
  53289. * Gets the Color Grading 2D Lookup Texture.
  53290. */
  53291. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53292. /**
  53293. * Sets the Color Grading 2D Lookup Texture.
  53294. */
  53295. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53296. /**
  53297. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53298. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53299. * 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;
  53300. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53301. */
  53302. get cameraColorCurves(): Nullable<ColorCurves>;
  53303. /**
  53304. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53305. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53306. * 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;
  53307. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53308. */
  53309. set cameraColorCurves(value: Nullable<ColorCurves>);
  53310. /**
  53311. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53312. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53313. */
  53314. switchToBGR: boolean;
  53315. private _renderTargets;
  53316. private _reflectionControls;
  53317. private _white;
  53318. private _primaryShadowColor;
  53319. private _primaryHighlightColor;
  53320. /**
  53321. * Instantiates a Background Material in the given scene
  53322. * @param name The friendly name of the material
  53323. * @param scene The scene to add the material to
  53324. */
  53325. constructor(name: string, scene: Scene);
  53326. /**
  53327. * Gets a boolean indicating that current material needs to register RTT
  53328. */
  53329. get hasRenderTargetTextures(): boolean;
  53330. /**
  53331. * The entire material has been created in order to prevent overdraw.
  53332. * @returns false
  53333. */
  53334. needAlphaTesting(): boolean;
  53335. /**
  53336. * The entire material has been created in order to prevent overdraw.
  53337. * @returns true if blending is enable
  53338. */
  53339. needAlphaBlending(): boolean;
  53340. /**
  53341. * Checks wether the material is ready to be rendered for a given mesh.
  53342. * @param mesh The mesh to render
  53343. * @param subMesh The submesh to check against
  53344. * @param useInstances Specify wether or not the material is used with instances
  53345. * @returns true if all the dependencies are ready (Textures, Effects...)
  53346. */
  53347. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53348. /**
  53349. * Compute the primary color according to the chosen perceptual color.
  53350. */
  53351. private _computePrimaryColorFromPerceptualColor;
  53352. /**
  53353. * Compute the highlights and shadow colors according to their chosen levels.
  53354. */
  53355. private _computePrimaryColors;
  53356. /**
  53357. * Build the uniform buffer used in the material.
  53358. */
  53359. buildUniformLayout(): void;
  53360. /**
  53361. * Unbind the material.
  53362. */
  53363. unbind(): void;
  53364. /**
  53365. * Bind only the world matrix to the material.
  53366. * @param world The world matrix to bind.
  53367. */
  53368. bindOnlyWorldMatrix(world: Matrix): void;
  53369. /**
  53370. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53371. * @param world The world matrix to bind.
  53372. * @param subMesh The submesh to bind for.
  53373. */
  53374. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53375. /**
  53376. * Checks to see if a texture is used in the material.
  53377. * @param texture - Base texture to use.
  53378. * @returns - Boolean specifying if a texture is used in the material.
  53379. */
  53380. hasTexture(texture: BaseTexture): boolean;
  53381. /**
  53382. * Dispose the material.
  53383. * @param forceDisposeEffect Force disposal of the associated effect.
  53384. * @param forceDisposeTextures Force disposal of the associated textures.
  53385. */
  53386. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53387. /**
  53388. * Clones the material.
  53389. * @param name The cloned name.
  53390. * @returns The cloned material.
  53391. */
  53392. clone(name: string): BackgroundMaterial;
  53393. /**
  53394. * Serializes the current material to its JSON representation.
  53395. * @returns The JSON representation.
  53396. */
  53397. serialize(): any;
  53398. /**
  53399. * Gets the class name of the material
  53400. * @returns "BackgroundMaterial"
  53401. */
  53402. getClassName(): string;
  53403. /**
  53404. * Parse a JSON input to create back a background material.
  53405. * @param source The JSON data to parse
  53406. * @param scene The scene to create the parsed material in
  53407. * @param rootUrl The root url of the assets the material depends upon
  53408. * @returns the instantiated BackgroundMaterial.
  53409. */
  53410. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53411. }
  53412. }
  53413. declare module BABYLON {
  53414. /**
  53415. * Represents the different options available during the creation of
  53416. * a Environment helper.
  53417. *
  53418. * This can control the default ground, skybox and image processing setup of your scene.
  53419. */
  53420. export interface IEnvironmentHelperOptions {
  53421. /**
  53422. * Specifies whether or not to create a ground.
  53423. * True by default.
  53424. */
  53425. createGround: boolean;
  53426. /**
  53427. * Specifies the ground size.
  53428. * 15 by default.
  53429. */
  53430. groundSize: number;
  53431. /**
  53432. * The texture used on the ground for the main color.
  53433. * Comes from the BabylonJS CDN by default.
  53434. *
  53435. * Remarks: Can be either a texture or a url.
  53436. */
  53437. groundTexture: string | BaseTexture;
  53438. /**
  53439. * The color mixed in the ground texture by default.
  53440. * BabylonJS clearColor by default.
  53441. */
  53442. groundColor: Color3;
  53443. /**
  53444. * Specifies the ground opacity.
  53445. * 1 by default.
  53446. */
  53447. groundOpacity: number;
  53448. /**
  53449. * Enables the ground to receive shadows.
  53450. * True by default.
  53451. */
  53452. enableGroundShadow: boolean;
  53453. /**
  53454. * Helps preventing the shadow to be fully black on the ground.
  53455. * 0.5 by default.
  53456. */
  53457. groundShadowLevel: number;
  53458. /**
  53459. * Creates a mirror texture attach to the ground.
  53460. * false by default.
  53461. */
  53462. enableGroundMirror: boolean;
  53463. /**
  53464. * Specifies the ground mirror size ratio.
  53465. * 0.3 by default as the default kernel is 64.
  53466. */
  53467. groundMirrorSizeRatio: number;
  53468. /**
  53469. * Specifies the ground mirror blur kernel size.
  53470. * 64 by default.
  53471. */
  53472. groundMirrorBlurKernel: number;
  53473. /**
  53474. * Specifies the ground mirror visibility amount.
  53475. * 1 by default
  53476. */
  53477. groundMirrorAmount: number;
  53478. /**
  53479. * Specifies the ground mirror reflectance weight.
  53480. * This uses the standard weight of the background material to setup the fresnel effect
  53481. * of the mirror.
  53482. * 1 by default.
  53483. */
  53484. groundMirrorFresnelWeight: number;
  53485. /**
  53486. * Specifies the ground mirror Falloff distance.
  53487. * This can helps reducing the size of the reflection.
  53488. * 0 by Default.
  53489. */
  53490. groundMirrorFallOffDistance: number;
  53491. /**
  53492. * Specifies the ground mirror texture type.
  53493. * Unsigned Int by Default.
  53494. */
  53495. groundMirrorTextureType: number;
  53496. /**
  53497. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53498. * the shown objects.
  53499. */
  53500. groundYBias: number;
  53501. /**
  53502. * Specifies whether or not to create a skybox.
  53503. * True by default.
  53504. */
  53505. createSkybox: boolean;
  53506. /**
  53507. * Specifies the skybox size.
  53508. * 20 by default.
  53509. */
  53510. skyboxSize: number;
  53511. /**
  53512. * The texture used on the skybox for the main color.
  53513. * Comes from the BabylonJS CDN by default.
  53514. *
  53515. * Remarks: Can be either a texture or a url.
  53516. */
  53517. skyboxTexture: string | BaseTexture;
  53518. /**
  53519. * The color mixed in the skybox texture by default.
  53520. * BabylonJS clearColor by default.
  53521. */
  53522. skyboxColor: Color3;
  53523. /**
  53524. * The background rotation around the Y axis of the scene.
  53525. * This helps aligning the key lights of your scene with the background.
  53526. * 0 by default.
  53527. */
  53528. backgroundYRotation: number;
  53529. /**
  53530. * Compute automatically the size of the elements to best fit with the scene.
  53531. */
  53532. sizeAuto: boolean;
  53533. /**
  53534. * Default position of the rootMesh if autoSize is not true.
  53535. */
  53536. rootPosition: Vector3;
  53537. /**
  53538. * Sets up the image processing in the scene.
  53539. * true by default.
  53540. */
  53541. setupImageProcessing: boolean;
  53542. /**
  53543. * The texture used as your environment texture in the scene.
  53544. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53545. *
  53546. * Remarks: Can be either a texture or a url.
  53547. */
  53548. environmentTexture: string | BaseTexture;
  53549. /**
  53550. * The value of the exposure to apply to the scene.
  53551. * 0.6 by default if setupImageProcessing is true.
  53552. */
  53553. cameraExposure: number;
  53554. /**
  53555. * The value of the contrast to apply to the scene.
  53556. * 1.6 by default if setupImageProcessing is true.
  53557. */
  53558. cameraContrast: number;
  53559. /**
  53560. * Specifies whether or not tonemapping should be enabled in the scene.
  53561. * true by default if setupImageProcessing is true.
  53562. */
  53563. toneMappingEnabled: boolean;
  53564. }
  53565. /**
  53566. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53567. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53568. * It also helps with the default setup of your imageProcessing configuration.
  53569. */
  53570. export class EnvironmentHelper {
  53571. /**
  53572. * Default ground texture URL.
  53573. */
  53574. private static _groundTextureCDNUrl;
  53575. /**
  53576. * Default skybox texture URL.
  53577. */
  53578. private static _skyboxTextureCDNUrl;
  53579. /**
  53580. * Default environment texture URL.
  53581. */
  53582. private static _environmentTextureCDNUrl;
  53583. /**
  53584. * Creates the default options for the helper.
  53585. */
  53586. private static _getDefaultOptions;
  53587. private _rootMesh;
  53588. /**
  53589. * Gets the root mesh created by the helper.
  53590. */
  53591. get rootMesh(): Mesh;
  53592. private _skybox;
  53593. /**
  53594. * Gets the skybox created by the helper.
  53595. */
  53596. get skybox(): Nullable<Mesh>;
  53597. private _skyboxTexture;
  53598. /**
  53599. * Gets the skybox texture created by the helper.
  53600. */
  53601. get skyboxTexture(): Nullable<BaseTexture>;
  53602. private _skyboxMaterial;
  53603. /**
  53604. * Gets the skybox material created by the helper.
  53605. */
  53606. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53607. private _ground;
  53608. /**
  53609. * Gets the ground mesh created by the helper.
  53610. */
  53611. get ground(): Nullable<Mesh>;
  53612. private _groundTexture;
  53613. /**
  53614. * Gets the ground texture created by the helper.
  53615. */
  53616. get groundTexture(): Nullable<BaseTexture>;
  53617. private _groundMirror;
  53618. /**
  53619. * Gets the ground mirror created by the helper.
  53620. */
  53621. get groundMirror(): Nullable<MirrorTexture>;
  53622. /**
  53623. * Gets the ground mirror render list to helps pushing the meshes
  53624. * you wish in the ground reflection.
  53625. */
  53626. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53627. private _groundMaterial;
  53628. /**
  53629. * Gets the ground material created by the helper.
  53630. */
  53631. get groundMaterial(): Nullable<BackgroundMaterial>;
  53632. /**
  53633. * Stores the creation options.
  53634. */
  53635. private readonly _scene;
  53636. private _options;
  53637. /**
  53638. * This observable will be notified with any error during the creation of the environment,
  53639. * mainly texture creation errors.
  53640. */
  53641. onErrorObservable: Observable<{
  53642. message?: string;
  53643. exception?: any;
  53644. }>;
  53645. /**
  53646. * constructor
  53647. * @param options Defines the options we want to customize the helper
  53648. * @param scene The scene to add the material to
  53649. */
  53650. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53651. /**
  53652. * Updates the background according to the new options
  53653. * @param options
  53654. */
  53655. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53656. /**
  53657. * Sets the primary color of all the available elements.
  53658. * @param color the main color to affect to the ground and the background
  53659. */
  53660. setMainColor(color: Color3): void;
  53661. /**
  53662. * Setup the image processing according to the specified options.
  53663. */
  53664. private _setupImageProcessing;
  53665. /**
  53666. * Setup the environment texture according to the specified options.
  53667. */
  53668. private _setupEnvironmentTexture;
  53669. /**
  53670. * Setup the background according to the specified options.
  53671. */
  53672. private _setupBackground;
  53673. /**
  53674. * Get the scene sizes according to the setup.
  53675. */
  53676. private _getSceneSize;
  53677. /**
  53678. * Setup the ground according to the specified options.
  53679. */
  53680. private _setupGround;
  53681. /**
  53682. * Setup the ground material according to the specified options.
  53683. */
  53684. private _setupGroundMaterial;
  53685. /**
  53686. * Setup the ground diffuse texture according to the specified options.
  53687. */
  53688. private _setupGroundDiffuseTexture;
  53689. /**
  53690. * Setup the ground mirror texture according to the specified options.
  53691. */
  53692. private _setupGroundMirrorTexture;
  53693. /**
  53694. * Setup the ground to receive the mirror texture.
  53695. */
  53696. private _setupMirrorInGroundMaterial;
  53697. /**
  53698. * Setup the skybox according to the specified options.
  53699. */
  53700. private _setupSkybox;
  53701. /**
  53702. * Setup the skybox material according to the specified options.
  53703. */
  53704. private _setupSkyboxMaterial;
  53705. /**
  53706. * Setup the skybox reflection texture according to the specified options.
  53707. */
  53708. private _setupSkyboxReflectionTexture;
  53709. private _errorHandler;
  53710. /**
  53711. * Dispose all the elements created by the Helper.
  53712. */
  53713. dispose(): void;
  53714. }
  53715. }
  53716. declare module BABYLON {
  53717. /**
  53718. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53719. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53720. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53721. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53722. */
  53723. export class PhotoDome extends TransformNode {
  53724. /**
  53725. * Define the image as a Monoscopic panoramic 360 image.
  53726. */
  53727. static readonly MODE_MONOSCOPIC: number;
  53728. /**
  53729. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53730. */
  53731. static readonly MODE_TOPBOTTOM: number;
  53732. /**
  53733. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53734. */
  53735. static readonly MODE_SIDEBYSIDE: number;
  53736. private _useDirectMapping;
  53737. /**
  53738. * The texture being displayed on the sphere
  53739. */
  53740. protected _photoTexture: Texture;
  53741. /**
  53742. * Gets or sets the texture being displayed on the sphere
  53743. */
  53744. get photoTexture(): Texture;
  53745. set photoTexture(value: Texture);
  53746. /**
  53747. * Observable raised when an error occured while loading the 360 image
  53748. */
  53749. onLoadErrorObservable: Observable<string>;
  53750. /**
  53751. * The skybox material
  53752. */
  53753. protected _material: BackgroundMaterial;
  53754. /**
  53755. * The surface used for the skybox
  53756. */
  53757. protected _mesh: Mesh;
  53758. /**
  53759. * Gets the mesh used for the skybox.
  53760. */
  53761. get mesh(): Mesh;
  53762. /**
  53763. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53764. * Also see the options.resolution property.
  53765. */
  53766. get fovMultiplier(): number;
  53767. set fovMultiplier(value: number);
  53768. private _imageMode;
  53769. /**
  53770. * Gets or set the current video mode for the video. It can be:
  53771. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53772. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53773. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53774. */
  53775. get imageMode(): number;
  53776. set imageMode(value: number);
  53777. /**
  53778. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53779. * @param name Element's name, child elements will append suffixes for their own names.
  53780. * @param urlsOfPhoto defines the url of the photo to display
  53781. * @param options defines an object containing optional or exposed sub element properties
  53782. * @param onError defines a callback called when an error occured while loading the texture
  53783. */
  53784. constructor(name: string, urlOfPhoto: string, options: {
  53785. resolution?: number;
  53786. size?: number;
  53787. useDirectMapping?: boolean;
  53788. faceForward?: boolean;
  53789. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53790. private _onBeforeCameraRenderObserver;
  53791. private _changeImageMode;
  53792. /**
  53793. * Releases resources associated with this node.
  53794. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53795. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53796. */
  53797. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53798. }
  53799. }
  53800. declare module BABYLON {
  53801. /**
  53802. * Class used to host RGBD texture specific utilities
  53803. */
  53804. export class RGBDTextureTools {
  53805. /**
  53806. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53807. * @param texture the texture to expand.
  53808. */
  53809. static ExpandRGBDTexture(texture: Texture): void;
  53810. }
  53811. }
  53812. declare module BABYLON {
  53813. /**
  53814. * Class used to host texture specific utilities
  53815. */
  53816. export class BRDFTextureTools {
  53817. /**
  53818. * Prevents texture cache collision
  53819. */
  53820. private static _instanceNumber;
  53821. /**
  53822. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53823. * @param scene defines the hosting scene
  53824. * @returns the environment BRDF texture
  53825. */
  53826. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53827. private static _environmentBRDFBase64Texture;
  53828. }
  53829. }
  53830. declare module BABYLON {
  53831. /**
  53832. * @hidden
  53833. */
  53834. export interface IMaterialClearCoatDefines {
  53835. CLEARCOAT: boolean;
  53836. CLEARCOAT_DEFAULTIOR: boolean;
  53837. CLEARCOAT_TEXTURE: boolean;
  53838. CLEARCOAT_TEXTUREDIRECTUV: number;
  53839. CLEARCOAT_BUMP: boolean;
  53840. CLEARCOAT_BUMPDIRECTUV: number;
  53841. CLEARCOAT_TINT: boolean;
  53842. CLEARCOAT_TINT_TEXTURE: boolean;
  53843. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53844. /** @hidden */
  53845. _areTexturesDirty: boolean;
  53846. }
  53847. /**
  53848. * Define the code related to the clear coat parameters of the pbr material.
  53849. */
  53850. export class PBRClearCoatConfiguration {
  53851. /**
  53852. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53853. * The default fits with a polyurethane material.
  53854. */
  53855. private static readonly _DefaultIndexOfRefraction;
  53856. private _isEnabled;
  53857. /**
  53858. * Defines if the clear coat is enabled in the material.
  53859. */
  53860. isEnabled: boolean;
  53861. /**
  53862. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53863. */
  53864. intensity: number;
  53865. /**
  53866. * Defines the clear coat layer roughness.
  53867. */
  53868. roughness: number;
  53869. private _indexOfRefraction;
  53870. /**
  53871. * Defines the index of refraction of the clear coat.
  53872. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53873. * The default fits with a polyurethane material.
  53874. * Changing the default value is more performance intensive.
  53875. */
  53876. indexOfRefraction: number;
  53877. private _texture;
  53878. /**
  53879. * Stores the clear coat values in a texture.
  53880. */
  53881. texture: Nullable<BaseTexture>;
  53882. private _bumpTexture;
  53883. /**
  53884. * Define the clear coat specific bump texture.
  53885. */
  53886. bumpTexture: Nullable<BaseTexture>;
  53887. private _isTintEnabled;
  53888. /**
  53889. * Defines if the clear coat tint is enabled in the material.
  53890. */
  53891. isTintEnabled: boolean;
  53892. /**
  53893. * Defines the clear coat tint of the material.
  53894. * This is only use if tint is enabled
  53895. */
  53896. tintColor: Color3;
  53897. /**
  53898. * Defines the distance at which the tint color should be found in the
  53899. * clear coat media.
  53900. * This is only use if tint is enabled
  53901. */
  53902. tintColorAtDistance: number;
  53903. /**
  53904. * Defines the clear coat layer thickness.
  53905. * This is only use if tint is enabled
  53906. */
  53907. tintThickness: number;
  53908. private _tintTexture;
  53909. /**
  53910. * Stores the clear tint values in a texture.
  53911. * rgb is tint
  53912. * a is a thickness factor
  53913. */
  53914. tintTexture: Nullable<BaseTexture>;
  53915. /** @hidden */
  53916. private _internalMarkAllSubMeshesAsTexturesDirty;
  53917. /** @hidden */
  53918. _markAllSubMeshesAsTexturesDirty(): void;
  53919. /**
  53920. * Instantiate a new istance of clear coat configuration.
  53921. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53922. */
  53923. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53924. /**
  53925. * Gets wehter the submesh is ready to be used or not.
  53926. * @param defines the list of "defines" to update.
  53927. * @param scene defines the scene the material belongs to.
  53928. * @param engine defines the engine the material belongs to.
  53929. * @param disableBumpMap defines wether the material disables bump or not.
  53930. * @returns - boolean indicating that the submesh is ready or not.
  53931. */
  53932. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53933. /**
  53934. * Checks to see if a texture is used in the material.
  53935. * @param defines the list of "defines" to update.
  53936. * @param scene defines the scene to the material belongs to.
  53937. */
  53938. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53939. /**
  53940. * Binds the material data.
  53941. * @param uniformBuffer defines the Uniform buffer to fill in.
  53942. * @param scene defines the scene the material belongs to.
  53943. * @param engine defines the engine the material belongs to.
  53944. * @param disableBumpMap defines wether the material disables bump or not.
  53945. * @param isFrozen defines wether the material is frozen or not.
  53946. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53947. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53948. */
  53949. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53950. /**
  53951. * Checks to see if a texture is used in the material.
  53952. * @param texture - Base texture to use.
  53953. * @returns - Boolean specifying if a texture is used in the material.
  53954. */
  53955. hasTexture(texture: BaseTexture): boolean;
  53956. /**
  53957. * Returns an array of the actively used textures.
  53958. * @param activeTextures Array of BaseTextures
  53959. */
  53960. getActiveTextures(activeTextures: BaseTexture[]): void;
  53961. /**
  53962. * Returns the animatable textures.
  53963. * @param animatables Array of animatable textures.
  53964. */
  53965. getAnimatables(animatables: IAnimatable[]): void;
  53966. /**
  53967. * Disposes the resources of the material.
  53968. * @param forceDisposeTextures - Forces the disposal of all textures.
  53969. */
  53970. dispose(forceDisposeTextures?: boolean): void;
  53971. /**
  53972. * Get the current class name of the texture useful for serialization or dynamic coding.
  53973. * @returns "PBRClearCoatConfiguration"
  53974. */
  53975. getClassName(): string;
  53976. /**
  53977. * Add fallbacks to the effect fallbacks list.
  53978. * @param defines defines the Base texture to use.
  53979. * @param fallbacks defines the current fallback list.
  53980. * @param currentRank defines the current fallback rank.
  53981. * @returns the new fallback rank.
  53982. */
  53983. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53984. /**
  53985. * Add the required uniforms to the current list.
  53986. * @param uniforms defines the current uniform list.
  53987. */
  53988. static AddUniforms(uniforms: string[]): void;
  53989. /**
  53990. * Add the required samplers to the current list.
  53991. * @param samplers defines the current sampler list.
  53992. */
  53993. static AddSamplers(samplers: string[]): void;
  53994. /**
  53995. * Add the required uniforms to the current buffer.
  53996. * @param uniformBuffer defines the current uniform buffer.
  53997. */
  53998. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53999. /**
  54000. * Makes a duplicate of the current configuration into another one.
  54001. * @param clearCoatConfiguration define the config where to copy the info
  54002. */
  54003. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54004. /**
  54005. * Serializes this clear coat configuration.
  54006. * @returns - An object with the serialized config.
  54007. */
  54008. serialize(): any;
  54009. /**
  54010. * Parses a anisotropy Configuration from a serialized object.
  54011. * @param source - Serialized object.
  54012. * @param scene Defines the scene we are parsing for
  54013. * @param rootUrl Defines the rootUrl to load from
  54014. */
  54015. parse(source: any, scene: Scene, rootUrl: string): void;
  54016. }
  54017. }
  54018. declare module BABYLON {
  54019. /**
  54020. * @hidden
  54021. */
  54022. export interface IMaterialAnisotropicDefines {
  54023. ANISOTROPIC: boolean;
  54024. ANISOTROPIC_TEXTURE: boolean;
  54025. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54026. MAINUV1: boolean;
  54027. _areTexturesDirty: boolean;
  54028. _needUVs: boolean;
  54029. }
  54030. /**
  54031. * Define the code related to the anisotropic parameters of the pbr material.
  54032. */
  54033. export class PBRAnisotropicConfiguration {
  54034. private _isEnabled;
  54035. /**
  54036. * Defines if the anisotropy is enabled in the material.
  54037. */
  54038. isEnabled: boolean;
  54039. /**
  54040. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54041. */
  54042. intensity: number;
  54043. /**
  54044. * Defines if the effect is along the tangents, bitangents or in between.
  54045. * By default, the effect is "strectching" the highlights along the tangents.
  54046. */
  54047. direction: Vector2;
  54048. private _texture;
  54049. /**
  54050. * Stores the anisotropy values in a texture.
  54051. * rg is direction (like normal from -1 to 1)
  54052. * b is a intensity
  54053. */
  54054. texture: Nullable<BaseTexture>;
  54055. /** @hidden */
  54056. private _internalMarkAllSubMeshesAsTexturesDirty;
  54057. /** @hidden */
  54058. _markAllSubMeshesAsTexturesDirty(): void;
  54059. /**
  54060. * Instantiate a new istance of anisotropy configuration.
  54061. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54062. */
  54063. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54064. /**
  54065. * Specifies that the submesh is ready to be used.
  54066. * @param defines the list of "defines" to update.
  54067. * @param scene defines the scene the material belongs to.
  54068. * @returns - boolean indicating that the submesh is ready or not.
  54069. */
  54070. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54071. /**
  54072. * Checks to see if a texture is used in the material.
  54073. * @param defines the list of "defines" to update.
  54074. * @param mesh the mesh we are preparing the defines for.
  54075. * @param scene defines the scene the material belongs to.
  54076. */
  54077. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54078. /**
  54079. * Binds the material data.
  54080. * @param uniformBuffer defines the Uniform buffer to fill in.
  54081. * @param scene defines the scene the material belongs to.
  54082. * @param isFrozen defines wether the material is frozen or not.
  54083. */
  54084. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54085. /**
  54086. * Checks to see if a texture is used in the material.
  54087. * @param texture - Base texture to use.
  54088. * @returns - Boolean specifying if a texture is used in the material.
  54089. */
  54090. hasTexture(texture: BaseTexture): boolean;
  54091. /**
  54092. * Returns an array of the actively used textures.
  54093. * @param activeTextures Array of BaseTextures
  54094. */
  54095. getActiveTextures(activeTextures: BaseTexture[]): void;
  54096. /**
  54097. * Returns the animatable textures.
  54098. * @param animatables Array of animatable textures.
  54099. */
  54100. getAnimatables(animatables: IAnimatable[]): void;
  54101. /**
  54102. * Disposes the resources of the material.
  54103. * @param forceDisposeTextures - Forces the disposal of all textures.
  54104. */
  54105. dispose(forceDisposeTextures?: boolean): void;
  54106. /**
  54107. * Get the current class name of the texture useful for serialization or dynamic coding.
  54108. * @returns "PBRAnisotropicConfiguration"
  54109. */
  54110. getClassName(): string;
  54111. /**
  54112. * Add fallbacks to the effect fallbacks list.
  54113. * @param defines defines the Base texture to use.
  54114. * @param fallbacks defines the current fallback list.
  54115. * @param currentRank defines the current fallback rank.
  54116. * @returns the new fallback rank.
  54117. */
  54118. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54119. /**
  54120. * Add the required uniforms to the current list.
  54121. * @param uniforms defines the current uniform list.
  54122. */
  54123. static AddUniforms(uniforms: string[]): void;
  54124. /**
  54125. * Add the required uniforms to the current buffer.
  54126. * @param uniformBuffer defines the current uniform buffer.
  54127. */
  54128. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54129. /**
  54130. * Add the required samplers to the current list.
  54131. * @param samplers defines the current sampler list.
  54132. */
  54133. static AddSamplers(samplers: string[]): void;
  54134. /**
  54135. * Makes a duplicate of the current configuration into another one.
  54136. * @param anisotropicConfiguration define the config where to copy the info
  54137. */
  54138. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54139. /**
  54140. * Serializes this anisotropy configuration.
  54141. * @returns - An object with the serialized config.
  54142. */
  54143. serialize(): any;
  54144. /**
  54145. * Parses a anisotropy Configuration from a serialized object.
  54146. * @param source - Serialized object.
  54147. * @param scene Defines the scene we are parsing for
  54148. * @param rootUrl Defines the rootUrl to load from
  54149. */
  54150. parse(source: any, scene: Scene, rootUrl: string): void;
  54151. }
  54152. }
  54153. declare module BABYLON {
  54154. /**
  54155. * @hidden
  54156. */
  54157. export interface IMaterialBRDFDefines {
  54158. BRDF_V_HEIGHT_CORRELATED: boolean;
  54159. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54160. SPHERICAL_HARMONICS: boolean;
  54161. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54162. /** @hidden */
  54163. _areMiscDirty: boolean;
  54164. }
  54165. /**
  54166. * Define the code related to the BRDF parameters of the pbr material.
  54167. */
  54168. export class PBRBRDFConfiguration {
  54169. /**
  54170. * Default value used for the energy conservation.
  54171. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54172. */
  54173. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54174. /**
  54175. * Default value used for the Smith Visibility Height Correlated mode.
  54176. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54177. */
  54178. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54179. /**
  54180. * Default value used for the IBL diffuse part.
  54181. * This can help switching back to the polynomials mode globally which is a tiny bit
  54182. * less GPU intensive at the drawback of a lower quality.
  54183. */
  54184. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54185. /**
  54186. * Default value used for activating energy conservation for the specular workflow.
  54187. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54188. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54189. */
  54190. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54191. private _useEnergyConservation;
  54192. /**
  54193. * Defines if the material uses energy conservation.
  54194. */
  54195. useEnergyConservation: boolean;
  54196. private _useSmithVisibilityHeightCorrelated;
  54197. /**
  54198. * LEGACY Mode set to false
  54199. * Defines if the material uses height smith correlated visibility term.
  54200. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54201. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54202. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54203. * Not relying on height correlated will also disable energy conservation.
  54204. */
  54205. useSmithVisibilityHeightCorrelated: boolean;
  54206. private _useSphericalHarmonics;
  54207. /**
  54208. * LEGACY Mode set to false
  54209. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54210. * diffuse part of the IBL.
  54211. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54212. * to the ground truth.
  54213. */
  54214. useSphericalHarmonics: boolean;
  54215. private _useSpecularGlossinessInputEnergyConservation;
  54216. /**
  54217. * Defines if the material uses energy conservation, when the specular workflow is active.
  54218. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54219. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54220. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54221. */
  54222. useSpecularGlossinessInputEnergyConservation: boolean;
  54223. /** @hidden */
  54224. private _internalMarkAllSubMeshesAsMiscDirty;
  54225. /** @hidden */
  54226. _markAllSubMeshesAsMiscDirty(): void;
  54227. /**
  54228. * Instantiate a new istance of clear coat configuration.
  54229. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54230. */
  54231. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54232. /**
  54233. * Checks to see if a texture is used in the material.
  54234. * @param defines the list of "defines" to update.
  54235. */
  54236. prepareDefines(defines: IMaterialBRDFDefines): void;
  54237. /**
  54238. * Get the current class name of the texture useful for serialization or dynamic coding.
  54239. * @returns "PBRClearCoatConfiguration"
  54240. */
  54241. getClassName(): string;
  54242. /**
  54243. * Makes a duplicate of the current configuration into another one.
  54244. * @param brdfConfiguration define the config where to copy the info
  54245. */
  54246. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54247. /**
  54248. * Serializes this BRDF configuration.
  54249. * @returns - An object with the serialized config.
  54250. */
  54251. serialize(): any;
  54252. /**
  54253. * Parses a anisotropy Configuration from a serialized object.
  54254. * @param source - Serialized object.
  54255. * @param scene Defines the scene we are parsing for
  54256. * @param rootUrl Defines the rootUrl to load from
  54257. */
  54258. parse(source: any, scene: Scene, rootUrl: string): void;
  54259. }
  54260. }
  54261. declare module BABYLON {
  54262. /**
  54263. * @hidden
  54264. */
  54265. export interface IMaterialSheenDefines {
  54266. SHEEN: boolean;
  54267. SHEEN_TEXTURE: boolean;
  54268. SHEEN_TEXTUREDIRECTUV: number;
  54269. SHEEN_LINKWITHALBEDO: boolean;
  54270. SHEEN_ROUGHNESS: boolean;
  54271. SHEEN_ALBEDOSCALING: boolean;
  54272. /** @hidden */
  54273. _areTexturesDirty: boolean;
  54274. }
  54275. /**
  54276. * Define the code related to the Sheen parameters of the pbr material.
  54277. */
  54278. export class PBRSheenConfiguration {
  54279. private _isEnabled;
  54280. /**
  54281. * Defines if the material uses sheen.
  54282. */
  54283. isEnabled: boolean;
  54284. private _linkSheenWithAlbedo;
  54285. /**
  54286. * Defines if the sheen is linked to the sheen color.
  54287. */
  54288. linkSheenWithAlbedo: boolean;
  54289. /**
  54290. * Defines the sheen intensity.
  54291. */
  54292. intensity: number;
  54293. /**
  54294. * Defines the sheen color.
  54295. */
  54296. color: Color3;
  54297. private _texture;
  54298. /**
  54299. * Stores the sheen tint values in a texture.
  54300. * rgb is tint
  54301. * a is a intensity
  54302. */
  54303. texture: Nullable<BaseTexture>;
  54304. private _roughness;
  54305. /**
  54306. * Defines the sheen roughness.
  54307. * It is not taken into account if linkSheenWithAlbedo is true.
  54308. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54309. */
  54310. roughness: Nullable<number>;
  54311. private _albedoScaling;
  54312. /**
  54313. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54314. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54315. * making it easier to setup and tweak the effect
  54316. */
  54317. albedoScaling: boolean;
  54318. /** @hidden */
  54319. private _internalMarkAllSubMeshesAsTexturesDirty;
  54320. /** @hidden */
  54321. _markAllSubMeshesAsTexturesDirty(): void;
  54322. /**
  54323. * Instantiate a new istance of clear coat configuration.
  54324. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54325. */
  54326. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54327. /**
  54328. * Specifies that the submesh is ready to be used.
  54329. * @param defines the list of "defines" to update.
  54330. * @param scene defines the scene the material belongs to.
  54331. * @returns - boolean indicating that the submesh is ready or not.
  54332. */
  54333. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54334. /**
  54335. * Checks to see if a texture is used in the material.
  54336. * @param defines the list of "defines" to update.
  54337. * @param scene defines the scene the material belongs to.
  54338. */
  54339. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54340. /**
  54341. * Binds the material data.
  54342. * @param uniformBuffer defines the Uniform buffer to fill in.
  54343. * @param scene defines the scene the material belongs to.
  54344. * @param isFrozen defines wether the material is frozen or not.
  54345. */
  54346. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54347. /**
  54348. * Checks to see if a texture is used in the material.
  54349. * @param texture - Base texture to use.
  54350. * @returns - Boolean specifying if a texture is used in the material.
  54351. */
  54352. hasTexture(texture: BaseTexture): boolean;
  54353. /**
  54354. * Returns an array of the actively used textures.
  54355. * @param activeTextures Array of BaseTextures
  54356. */
  54357. getActiveTextures(activeTextures: BaseTexture[]): void;
  54358. /**
  54359. * Returns the animatable textures.
  54360. * @param animatables Array of animatable textures.
  54361. */
  54362. getAnimatables(animatables: IAnimatable[]): void;
  54363. /**
  54364. * Disposes the resources of the material.
  54365. * @param forceDisposeTextures - Forces the disposal of all textures.
  54366. */
  54367. dispose(forceDisposeTextures?: boolean): void;
  54368. /**
  54369. * Get the current class name of the texture useful for serialization or dynamic coding.
  54370. * @returns "PBRSheenConfiguration"
  54371. */
  54372. getClassName(): string;
  54373. /**
  54374. * Add fallbacks to the effect fallbacks list.
  54375. * @param defines defines the Base texture to use.
  54376. * @param fallbacks defines the current fallback list.
  54377. * @param currentRank defines the current fallback rank.
  54378. * @returns the new fallback rank.
  54379. */
  54380. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54381. /**
  54382. * Add the required uniforms to the current list.
  54383. * @param uniforms defines the current uniform list.
  54384. */
  54385. static AddUniforms(uniforms: string[]): void;
  54386. /**
  54387. * Add the required uniforms to the current buffer.
  54388. * @param uniformBuffer defines the current uniform buffer.
  54389. */
  54390. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54391. /**
  54392. * Add the required samplers to the current list.
  54393. * @param samplers defines the current sampler list.
  54394. */
  54395. static AddSamplers(samplers: string[]): void;
  54396. /**
  54397. * Makes a duplicate of the current configuration into another one.
  54398. * @param sheenConfiguration define the config where to copy the info
  54399. */
  54400. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54401. /**
  54402. * Serializes this BRDF configuration.
  54403. * @returns - An object with the serialized config.
  54404. */
  54405. serialize(): any;
  54406. /**
  54407. * Parses a anisotropy Configuration from a serialized object.
  54408. * @param source - Serialized object.
  54409. * @param scene Defines the scene we are parsing for
  54410. * @param rootUrl Defines the rootUrl to load from
  54411. */
  54412. parse(source: any, scene: Scene, rootUrl: string): void;
  54413. }
  54414. }
  54415. declare module BABYLON {
  54416. /**
  54417. * @hidden
  54418. */
  54419. export interface IMaterialSubSurfaceDefines {
  54420. SUBSURFACE: boolean;
  54421. SS_REFRACTION: boolean;
  54422. SS_TRANSLUCENCY: boolean;
  54423. SS_SCATTERING: boolean;
  54424. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54425. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54426. SS_REFRACTIONMAP_3D: boolean;
  54427. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54428. SS_LODINREFRACTIONALPHA: boolean;
  54429. SS_GAMMAREFRACTION: boolean;
  54430. SS_RGBDREFRACTION: boolean;
  54431. SS_LINEARSPECULARREFRACTION: boolean;
  54432. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54433. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54434. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54435. /** @hidden */
  54436. _areTexturesDirty: boolean;
  54437. }
  54438. /**
  54439. * Define the code related to the sub surface parameters of the pbr material.
  54440. */
  54441. export class PBRSubSurfaceConfiguration {
  54442. private _isRefractionEnabled;
  54443. /**
  54444. * Defines if the refraction is enabled in the material.
  54445. */
  54446. isRefractionEnabled: boolean;
  54447. private _isTranslucencyEnabled;
  54448. /**
  54449. * Defines if the translucency is enabled in the material.
  54450. */
  54451. isTranslucencyEnabled: boolean;
  54452. private _isScatteringEnabled;
  54453. /**
  54454. * Defines the refraction intensity of the material.
  54455. * The refraction when enabled replaces the Diffuse part of the material.
  54456. * The intensity helps transitionning between diffuse and refraction.
  54457. */
  54458. refractionIntensity: number;
  54459. /**
  54460. * Defines the translucency intensity of the material.
  54461. * When translucency has been enabled, this defines how much of the "translucency"
  54462. * is addded to the diffuse part of the material.
  54463. */
  54464. translucencyIntensity: number;
  54465. /**
  54466. * Defines the scattering intensity of the material.
  54467. * When scattering has been enabled, this defines how much of the "scattered light"
  54468. * is addded to the diffuse part of the material.
  54469. */
  54470. scatteringIntensity: number;
  54471. /**
  54472. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54473. */
  54474. useAlbedoToTintRefraction: boolean;
  54475. private _thicknessTexture;
  54476. /**
  54477. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54478. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54479. * 0 would mean minimumThickness
  54480. * 1 would mean maximumThickness
  54481. * The other channels might be use as a mask to vary the different effects intensity.
  54482. */
  54483. thicknessTexture: Nullable<BaseTexture>;
  54484. private _refractionTexture;
  54485. /**
  54486. * Defines the texture to use for refraction.
  54487. */
  54488. refractionTexture: Nullable<BaseTexture>;
  54489. private _indexOfRefraction;
  54490. /**
  54491. * Index of refraction of the material base layer.
  54492. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54493. *
  54494. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54495. *
  54496. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54497. */
  54498. indexOfRefraction: number;
  54499. private _volumeIndexOfRefraction;
  54500. /**
  54501. * Index of refraction of the material's volume.
  54502. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54503. *
  54504. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54505. * the volume will use the same IOR as the surface.
  54506. */
  54507. get volumeIndexOfRefraction(): number;
  54508. set volumeIndexOfRefraction(value: number);
  54509. private _invertRefractionY;
  54510. /**
  54511. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54512. */
  54513. invertRefractionY: boolean;
  54514. private _linkRefractionWithTransparency;
  54515. /**
  54516. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54517. * Materials half opaque for instance using refraction could benefit from this control.
  54518. */
  54519. linkRefractionWithTransparency: boolean;
  54520. /**
  54521. * Defines the minimum thickness stored in the thickness map.
  54522. * If no thickness map is defined, this value will be used to simulate thickness.
  54523. */
  54524. minimumThickness: number;
  54525. /**
  54526. * Defines the maximum thickness stored in the thickness map.
  54527. */
  54528. maximumThickness: number;
  54529. /**
  54530. * Defines the volume tint of the material.
  54531. * This is used for both translucency and scattering.
  54532. */
  54533. tintColor: Color3;
  54534. /**
  54535. * Defines the distance at which the tint color should be found in the media.
  54536. * This is used for refraction only.
  54537. */
  54538. tintColorAtDistance: number;
  54539. /**
  54540. * Defines how far each channel transmit through the media.
  54541. * It is defined as a color to simplify it selection.
  54542. */
  54543. diffusionDistance: Color3;
  54544. private _useMaskFromThicknessTexture;
  54545. /**
  54546. * Stores the intensity of the different subsurface effects in the thickness texture.
  54547. * * the green channel is the translucency intensity.
  54548. * * the blue channel is the scattering intensity.
  54549. * * the alpha channel is the refraction intensity.
  54550. */
  54551. useMaskFromThicknessTexture: boolean;
  54552. /** @hidden */
  54553. private _internalMarkAllSubMeshesAsTexturesDirty;
  54554. /** @hidden */
  54555. _markAllSubMeshesAsTexturesDirty(): void;
  54556. /**
  54557. * Instantiate a new istance of sub surface configuration.
  54558. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54559. */
  54560. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54561. /**
  54562. * Gets wehter the submesh is ready to be used or not.
  54563. * @param defines the list of "defines" to update.
  54564. * @param scene defines the scene the material belongs to.
  54565. * @returns - boolean indicating that the submesh is ready or not.
  54566. */
  54567. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54568. /**
  54569. * Checks to see if a texture is used in the material.
  54570. * @param defines the list of "defines" to update.
  54571. * @param scene defines the scene to the material belongs to.
  54572. */
  54573. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54574. /**
  54575. * Binds the material data.
  54576. * @param uniformBuffer defines the Uniform buffer to fill in.
  54577. * @param scene defines the scene the material belongs to.
  54578. * @param engine defines the engine the material belongs to.
  54579. * @param isFrozen defines whether the material is frozen or not.
  54580. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54581. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54582. */
  54583. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54584. /**
  54585. * Unbinds the material from the mesh.
  54586. * @param activeEffect defines the effect that should be unbound from.
  54587. * @returns true if unbound, otherwise false
  54588. */
  54589. unbind(activeEffect: Effect): boolean;
  54590. /**
  54591. * Returns the texture used for refraction or null if none is used.
  54592. * @param scene defines the scene the material belongs to.
  54593. * @returns - Refraction texture if present. If no refraction texture and refraction
  54594. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54595. */
  54596. private _getRefractionTexture;
  54597. /**
  54598. * Returns true if alpha blending should be disabled.
  54599. */
  54600. get disableAlphaBlending(): boolean;
  54601. /**
  54602. * Fills the list of render target textures.
  54603. * @param renderTargets the list of render targets to update
  54604. */
  54605. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54606. /**
  54607. * Checks to see if a texture is used in the material.
  54608. * @param texture - Base texture to use.
  54609. * @returns - Boolean specifying if a texture is used in the material.
  54610. */
  54611. hasTexture(texture: BaseTexture): boolean;
  54612. /**
  54613. * Gets a boolean indicating that current material needs to register RTT
  54614. * @returns true if this uses a render target otherwise false.
  54615. */
  54616. hasRenderTargetTextures(): boolean;
  54617. /**
  54618. * Returns an array of the actively used textures.
  54619. * @param activeTextures Array of BaseTextures
  54620. */
  54621. getActiveTextures(activeTextures: BaseTexture[]): void;
  54622. /**
  54623. * Returns the animatable textures.
  54624. * @param animatables Array of animatable textures.
  54625. */
  54626. getAnimatables(animatables: IAnimatable[]): void;
  54627. /**
  54628. * Disposes the resources of the material.
  54629. * @param forceDisposeTextures - Forces the disposal of all textures.
  54630. */
  54631. dispose(forceDisposeTextures?: boolean): void;
  54632. /**
  54633. * Get the current class name of the texture useful for serialization or dynamic coding.
  54634. * @returns "PBRSubSurfaceConfiguration"
  54635. */
  54636. getClassName(): string;
  54637. /**
  54638. * Add fallbacks to the effect fallbacks list.
  54639. * @param defines defines the Base texture to use.
  54640. * @param fallbacks defines the current fallback list.
  54641. * @param currentRank defines the current fallback rank.
  54642. * @returns the new fallback rank.
  54643. */
  54644. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54645. /**
  54646. * Add the required uniforms to the current list.
  54647. * @param uniforms defines the current uniform list.
  54648. */
  54649. static AddUniforms(uniforms: string[]): void;
  54650. /**
  54651. * Add the required samplers to the current list.
  54652. * @param samplers defines the current sampler list.
  54653. */
  54654. static AddSamplers(samplers: string[]): void;
  54655. /**
  54656. * Add the required uniforms to the current buffer.
  54657. * @param uniformBuffer defines the current uniform buffer.
  54658. */
  54659. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54660. /**
  54661. * Makes a duplicate of the current configuration into another one.
  54662. * @param configuration define the config where to copy the info
  54663. */
  54664. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54665. /**
  54666. * Serializes this Sub Surface configuration.
  54667. * @returns - An object with the serialized config.
  54668. */
  54669. serialize(): any;
  54670. /**
  54671. * Parses a anisotropy Configuration from a serialized object.
  54672. * @param source - Serialized object.
  54673. * @param scene Defines the scene we are parsing for
  54674. * @param rootUrl Defines the rootUrl to load from
  54675. */
  54676. parse(source: any, scene: Scene, rootUrl: string): void;
  54677. }
  54678. }
  54679. declare module BABYLON {
  54680. /** @hidden */
  54681. export var pbrFragmentDeclaration: {
  54682. name: string;
  54683. shader: string;
  54684. };
  54685. }
  54686. declare module BABYLON {
  54687. /** @hidden */
  54688. export var pbrUboDeclaration: {
  54689. name: string;
  54690. shader: string;
  54691. };
  54692. }
  54693. declare module BABYLON {
  54694. /** @hidden */
  54695. export var pbrFragmentExtraDeclaration: {
  54696. name: string;
  54697. shader: string;
  54698. };
  54699. }
  54700. declare module BABYLON {
  54701. /** @hidden */
  54702. export var pbrFragmentSamplersDeclaration: {
  54703. name: string;
  54704. shader: string;
  54705. };
  54706. }
  54707. declare module BABYLON {
  54708. /** @hidden */
  54709. export var importanceSampling: {
  54710. name: string;
  54711. shader: string;
  54712. };
  54713. }
  54714. declare module BABYLON {
  54715. /** @hidden */
  54716. export var pbrHelperFunctions: {
  54717. name: string;
  54718. shader: string;
  54719. };
  54720. }
  54721. declare module BABYLON {
  54722. /** @hidden */
  54723. export var harmonicsFunctions: {
  54724. name: string;
  54725. shader: string;
  54726. };
  54727. }
  54728. declare module BABYLON {
  54729. /** @hidden */
  54730. export var pbrDirectLightingSetupFunctions: {
  54731. name: string;
  54732. shader: string;
  54733. };
  54734. }
  54735. declare module BABYLON {
  54736. /** @hidden */
  54737. export var pbrDirectLightingFalloffFunctions: {
  54738. name: string;
  54739. shader: string;
  54740. };
  54741. }
  54742. declare module BABYLON {
  54743. /** @hidden */
  54744. export var pbrBRDFFunctions: {
  54745. name: string;
  54746. shader: string;
  54747. };
  54748. }
  54749. declare module BABYLON {
  54750. /** @hidden */
  54751. export var hdrFilteringFunctions: {
  54752. name: string;
  54753. shader: string;
  54754. };
  54755. }
  54756. declare module BABYLON {
  54757. /** @hidden */
  54758. export var pbrDirectLightingFunctions: {
  54759. name: string;
  54760. shader: string;
  54761. };
  54762. }
  54763. declare module BABYLON {
  54764. /** @hidden */
  54765. export var pbrIBLFunctions: {
  54766. name: string;
  54767. shader: string;
  54768. };
  54769. }
  54770. declare module BABYLON {
  54771. /** @hidden */
  54772. export var pbrBlockAlbedoOpacity: {
  54773. name: string;
  54774. shader: string;
  54775. };
  54776. }
  54777. declare module BABYLON {
  54778. /** @hidden */
  54779. export var pbrBlockReflectivity: {
  54780. name: string;
  54781. shader: string;
  54782. };
  54783. }
  54784. declare module BABYLON {
  54785. /** @hidden */
  54786. export var pbrBlockAmbientOcclusion: {
  54787. name: string;
  54788. shader: string;
  54789. };
  54790. }
  54791. declare module BABYLON {
  54792. /** @hidden */
  54793. export var pbrBlockAlphaFresnel: {
  54794. name: string;
  54795. shader: string;
  54796. };
  54797. }
  54798. declare module BABYLON {
  54799. /** @hidden */
  54800. export var pbrBlockAnisotropic: {
  54801. name: string;
  54802. shader: string;
  54803. };
  54804. }
  54805. declare module BABYLON {
  54806. /** @hidden */
  54807. export var pbrBlockReflection: {
  54808. name: string;
  54809. shader: string;
  54810. };
  54811. }
  54812. declare module BABYLON {
  54813. /** @hidden */
  54814. export var pbrBlockSheen: {
  54815. name: string;
  54816. shader: string;
  54817. };
  54818. }
  54819. declare module BABYLON {
  54820. /** @hidden */
  54821. export var pbrBlockClearcoat: {
  54822. name: string;
  54823. shader: string;
  54824. };
  54825. }
  54826. declare module BABYLON {
  54827. /** @hidden */
  54828. export var pbrBlockSubSurface: {
  54829. name: string;
  54830. shader: string;
  54831. };
  54832. }
  54833. declare module BABYLON {
  54834. /** @hidden */
  54835. export var pbrBlockNormalGeometric: {
  54836. name: string;
  54837. shader: string;
  54838. };
  54839. }
  54840. declare module BABYLON {
  54841. /** @hidden */
  54842. export var pbrBlockNormalFinal: {
  54843. name: string;
  54844. shader: string;
  54845. };
  54846. }
  54847. declare module BABYLON {
  54848. /** @hidden */
  54849. export var pbrBlockGeometryInfo: {
  54850. name: string;
  54851. shader: string;
  54852. };
  54853. }
  54854. declare module BABYLON {
  54855. /** @hidden */
  54856. export var pbrBlockReflectance0: {
  54857. name: string;
  54858. shader: string;
  54859. };
  54860. }
  54861. declare module BABYLON {
  54862. /** @hidden */
  54863. export var pbrBlockReflectance: {
  54864. name: string;
  54865. shader: string;
  54866. };
  54867. }
  54868. declare module BABYLON {
  54869. /** @hidden */
  54870. export var pbrBlockDirectLighting: {
  54871. name: string;
  54872. shader: string;
  54873. };
  54874. }
  54875. declare module BABYLON {
  54876. /** @hidden */
  54877. export var pbrBlockFinalLitComponents: {
  54878. name: string;
  54879. shader: string;
  54880. };
  54881. }
  54882. declare module BABYLON {
  54883. /** @hidden */
  54884. export var pbrBlockFinalUnlitComponents: {
  54885. name: string;
  54886. shader: string;
  54887. };
  54888. }
  54889. declare module BABYLON {
  54890. /** @hidden */
  54891. export var pbrBlockFinalColorComposition: {
  54892. name: string;
  54893. shader: string;
  54894. };
  54895. }
  54896. declare module BABYLON {
  54897. /** @hidden */
  54898. export var pbrBlockImageProcessing: {
  54899. name: string;
  54900. shader: string;
  54901. };
  54902. }
  54903. declare module BABYLON {
  54904. /** @hidden */
  54905. export var pbrDebug: {
  54906. name: string;
  54907. shader: string;
  54908. };
  54909. }
  54910. declare module BABYLON {
  54911. /** @hidden */
  54912. export var pbrPixelShader: {
  54913. name: string;
  54914. shader: string;
  54915. };
  54916. }
  54917. declare module BABYLON {
  54918. /** @hidden */
  54919. export var pbrVertexDeclaration: {
  54920. name: string;
  54921. shader: string;
  54922. };
  54923. }
  54924. declare module BABYLON {
  54925. /** @hidden */
  54926. export var pbrVertexShader: {
  54927. name: string;
  54928. shader: string;
  54929. };
  54930. }
  54931. declare module BABYLON {
  54932. /**
  54933. * Manages the defines for the PBR Material.
  54934. * @hidden
  54935. */
  54936. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  54937. PBR: boolean;
  54938. NUM_SAMPLES: string;
  54939. REALTIME_FILTERING: boolean;
  54940. MAINUV1: boolean;
  54941. MAINUV2: boolean;
  54942. UV1: boolean;
  54943. UV2: boolean;
  54944. ALBEDO: boolean;
  54945. GAMMAALBEDO: boolean;
  54946. ALBEDODIRECTUV: number;
  54947. VERTEXCOLOR: boolean;
  54948. DETAIL: boolean;
  54949. DETAILDIRECTUV: number;
  54950. DETAIL_NORMALBLENDMETHOD: number;
  54951. AMBIENT: boolean;
  54952. AMBIENTDIRECTUV: number;
  54953. AMBIENTINGRAYSCALE: boolean;
  54954. OPACITY: boolean;
  54955. VERTEXALPHA: boolean;
  54956. OPACITYDIRECTUV: number;
  54957. OPACITYRGB: boolean;
  54958. ALPHATEST: boolean;
  54959. DEPTHPREPASS: boolean;
  54960. ALPHABLEND: boolean;
  54961. ALPHAFROMALBEDO: boolean;
  54962. ALPHATESTVALUE: string;
  54963. SPECULAROVERALPHA: boolean;
  54964. RADIANCEOVERALPHA: boolean;
  54965. ALPHAFRESNEL: boolean;
  54966. LINEARALPHAFRESNEL: boolean;
  54967. PREMULTIPLYALPHA: boolean;
  54968. EMISSIVE: boolean;
  54969. EMISSIVEDIRECTUV: number;
  54970. REFLECTIVITY: boolean;
  54971. REFLECTIVITYDIRECTUV: number;
  54972. SPECULARTERM: boolean;
  54973. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54974. MICROSURFACEAUTOMATIC: boolean;
  54975. LODBASEDMICROSFURACE: boolean;
  54976. MICROSURFACEMAP: boolean;
  54977. MICROSURFACEMAPDIRECTUV: number;
  54978. METALLICWORKFLOW: boolean;
  54979. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54980. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54981. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54982. AOSTOREINMETALMAPRED: boolean;
  54983. METALLIC_REFLECTANCE: boolean;
  54984. METALLIC_REFLECTANCEDIRECTUV: number;
  54985. ENVIRONMENTBRDF: boolean;
  54986. ENVIRONMENTBRDF_RGBD: boolean;
  54987. NORMAL: boolean;
  54988. TANGENT: boolean;
  54989. BUMP: boolean;
  54990. BUMPDIRECTUV: number;
  54991. OBJECTSPACE_NORMALMAP: boolean;
  54992. PARALLAX: boolean;
  54993. PARALLAXOCCLUSION: boolean;
  54994. NORMALXYSCALE: boolean;
  54995. LIGHTMAP: boolean;
  54996. LIGHTMAPDIRECTUV: number;
  54997. USELIGHTMAPASSHADOWMAP: boolean;
  54998. GAMMALIGHTMAP: boolean;
  54999. RGBDLIGHTMAP: boolean;
  55000. REFLECTION: boolean;
  55001. REFLECTIONMAP_3D: boolean;
  55002. REFLECTIONMAP_SPHERICAL: boolean;
  55003. REFLECTIONMAP_PLANAR: boolean;
  55004. REFLECTIONMAP_CUBIC: boolean;
  55005. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55006. REFLECTIONMAP_PROJECTION: boolean;
  55007. REFLECTIONMAP_SKYBOX: boolean;
  55008. REFLECTIONMAP_EXPLICIT: boolean;
  55009. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55010. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55011. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55012. INVERTCUBICMAP: boolean;
  55013. USESPHERICALFROMREFLECTIONMAP: boolean;
  55014. USEIRRADIANCEMAP: boolean;
  55015. SPHERICAL_HARMONICS: boolean;
  55016. USESPHERICALINVERTEX: boolean;
  55017. REFLECTIONMAP_OPPOSITEZ: boolean;
  55018. LODINREFLECTIONALPHA: boolean;
  55019. GAMMAREFLECTION: boolean;
  55020. RGBDREFLECTION: boolean;
  55021. LINEARSPECULARREFLECTION: boolean;
  55022. RADIANCEOCCLUSION: boolean;
  55023. HORIZONOCCLUSION: boolean;
  55024. INSTANCES: boolean;
  55025. THIN_INSTANCES: boolean;
  55026. NUM_BONE_INFLUENCERS: number;
  55027. BonesPerMesh: number;
  55028. BONETEXTURE: boolean;
  55029. NONUNIFORMSCALING: boolean;
  55030. MORPHTARGETS: boolean;
  55031. MORPHTARGETS_NORMAL: boolean;
  55032. MORPHTARGETS_TANGENT: boolean;
  55033. MORPHTARGETS_UV: boolean;
  55034. NUM_MORPH_INFLUENCERS: number;
  55035. IMAGEPROCESSING: boolean;
  55036. VIGNETTE: boolean;
  55037. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55038. VIGNETTEBLENDMODEOPAQUE: boolean;
  55039. TONEMAPPING: boolean;
  55040. TONEMAPPING_ACES: boolean;
  55041. CONTRAST: boolean;
  55042. COLORCURVES: boolean;
  55043. COLORGRADING: boolean;
  55044. COLORGRADING3D: boolean;
  55045. SAMPLER3DGREENDEPTH: boolean;
  55046. SAMPLER3DBGRMAP: boolean;
  55047. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55048. EXPOSURE: boolean;
  55049. MULTIVIEW: boolean;
  55050. USEPHYSICALLIGHTFALLOFF: boolean;
  55051. USEGLTFLIGHTFALLOFF: boolean;
  55052. TWOSIDEDLIGHTING: boolean;
  55053. SHADOWFLOAT: boolean;
  55054. CLIPPLANE: boolean;
  55055. CLIPPLANE2: boolean;
  55056. CLIPPLANE3: boolean;
  55057. CLIPPLANE4: boolean;
  55058. CLIPPLANE5: boolean;
  55059. CLIPPLANE6: boolean;
  55060. POINTSIZE: boolean;
  55061. FOG: boolean;
  55062. LOGARITHMICDEPTH: boolean;
  55063. FORCENORMALFORWARD: boolean;
  55064. SPECULARAA: boolean;
  55065. CLEARCOAT: boolean;
  55066. CLEARCOAT_DEFAULTIOR: boolean;
  55067. CLEARCOAT_TEXTURE: boolean;
  55068. CLEARCOAT_TEXTUREDIRECTUV: number;
  55069. CLEARCOAT_BUMP: boolean;
  55070. CLEARCOAT_BUMPDIRECTUV: number;
  55071. CLEARCOAT_TINT: boolean;
  55072. CLEARCOAT_TINT_TEXTURE: boolean;
  55073. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55074. ANISOTROPIC: boolean;
  55075. ANISOTROPIC_TEXTURE: boolean;
  55076. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55077. BRDF_V_HEIGHT_CORRELATED: boolean;
  55078. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55079. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55080. SHEEN: boolean;
  55081. SHEEN_TEXTURE: boolean;
  55082. SHEEN_TEXTUREDIRECTUV: number;
  55083. SHEEN_LINKWITHALBEDO: boolean;
  55084. SHEEN_ROUGHNESS: boolean;
  55085. SHEEN_ALBEDOSCALING: boolean;
  55086. SUBSURFACE: boolean;
  55087. SS_REFRACTION: boolean;
  55088. SS_TRANSLUCENCY: boolean;
  55089. SS_SCATTERING: boolean;
  55090. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55091. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55092. SS_REFRACTIONMAP_3D: boolean;
  55093. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55094. SS_LODINREFRACTIONALPHA: boolean;
  55095. SS_GAMMAREFRACTION: boolean;
  55096. SS_RGBDREFRACTION: boolean;
  55097. SS_LINEARSPECULARREFRACTION: boolean;
  55098. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55099. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55100. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55101. UNLIT: boolean;
  55102. DEBUGMODE: number;
  55103. /**
  55104. * Initializes the PBR Material defines.
  55105. */
  55106. constructor();
  55107. /**
  55108. * Resets the PBR Material defines.
  55109. */
  55110. reset(): void;
  55111. }
  55112. /**
  55113. * The Physically based material base class of BJS.
  55114. *
  55115. * This offers the main features of a standard PBR material.
  55116. * For more information, please refer to the documentation :
  55117. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55118. */
  55119. export abstract class PBRBaseMaterial extends PushMaterial {
  55120. /**
  55121. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55122. */
  55123. static readonly PBRMATERIAL_OPAQUE: number;
  55124. /**
  55125. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55126. */
  55127. static readonly PBRMATERIAL_ALPHATEST: number;
  55128. /**
  55129. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55130. */
  55131. static readonly PBRMATERIAL_ALPHABLEND: number;
  55132. /**
  55133. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55134. * They are also discarded below the alpha cutoff threshold to improve performances.
  55135. */
  55136. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55137. /**
  55138. * Defines the default value of how much AO map is occluding the analytical lights
  55139. * (point spot...).
  55140. */
  55141. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55142. /**
  55143. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55144. */
  55145. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55146. /**
  55147. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55148. * to enhance interoperability with other engines.
  55149. */
  55150. static readonly LIGHTFALLOFF_GLTF: number;
  55151. /**
  55152. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55153. * to enhance interoperability with other materials.
  55154. */
  55155. static readonly LIGHTFALLOFF_STANDARD: number;
  55156. /**
  55157. * Intensity of the direct lights e.g. the four lights available in your scene.
  55158. * This impacts both the direct diffuse and specular highlights.
  55159. */
  55160. protected _directIntensity: number;
  55161. /**
  55162. * Intensity of the emissive part of the material.
  55163. * This helps controlling the emissive effect without modifying the emissive color.
  55164. */
  55165. protected _emissiveIntensity: number;
  55166. /**
  55167. * Intensity of the environment e.g. how much the environment will light the object
  55168. * either through harmonics for rough material or through the refelction for shiny ones.
  55169. */
  55170. protected _environmentIntensity: number;
  55171. /**
  55172. * This is a special control allowing the reduction of the specular highlights coming from the
  55173. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55174. */
  55175. protected _specularIntensity: number;
  55176. /**
  55177. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55178. */
  55179. private _lightingInfos;
  55180. /**
  55181. * Debug Control allowing disabling the bump map on this material.
  55182. */
  55183. protected _disableBumpMap: boolean;
  55184. /**
  55185. * AKA Diffuse Texture in standard nomenclature.
  55186. */
  55187. protected _albedoTexture: Nullable<BaseTexture>;
  55188. /**
  55189. * AKA Occlusion Texture in other nomenclature.
  55190. */
  55191. protected _ambientTexture: Nullable<BaseTexture>;
  55192. /**
  55193. * AKA Occlusion Texture Intensity in other nomenclature.
  55194. */
  55195. protected _ambientTextureStrength: number;
  55196. /**
  55197. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55198. * 1 means it completely occludes it
  55199. * 0 mean it has no impact
  55200. */
  55201. protected _ambientTextureImpactOnAnalyticalLights: number;
  55202. /**
  55203. * Stores the alpha values in a texture.
  55204. */
  55205. protected _opacityTexture: Nullable<BaseTexture>;
  55206. /**
  55207. * Stores the reflection values in a texture.
  55208. */
  55209. protected _reflectionTexture: Nullable<BaseTexture>;
  55210. /**
  55211. * Stores the emissive values in a texture.
  55212. */
  55213. protected _emissiveTexture: Nullable<BaseTexture>;
  55214. /**
  55215. * AKA Specular texture in other nomenclature.
  55216. */
  55217. protected _reflectivityTexture: Nullable<BaseTexture>;
  55218. /**
  55219. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55220. */
  55221. protected _metallicTexture: Nullable<BaseTexture>;
  55222. /**
  55223. * Specifies the metallic scalar of the metallic/roughness workflow.
  55224. * Can also be used to scale the metalness values of the metallic texture.
  55225. */
  55226. protected _metallic: Nullable<number>;
  55227. /**
  55228. * Specifies the roughness scalar of the metallic/roughness workflow.
  55229. * Can also be used to scale the roughness values of the metallic texture.
  55230. */
  55231. protected _roughness: Nullable<number>;
  55232. /**
  55233. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55234. * By default the indexOfrefraction is used to compute F0;
  55235. *
  55236. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55237. *
  55238. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55239. * F90 = metallicReflectanceColor;
  55240. */
  55241. protected _metallicF0Factor: number;
  55242. /**
  55243. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55244. * By default the F90 is always 1;
  55245. *
  55246. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55247. *
  55248. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55249. * F90 = metallicReflectanceColor;
  55250. */
  55251. protected _metallicReflectanceColor: Color3;
  55252. /**
  55253. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55254. * This is multiply against the scalar values defined in the material.
  55255. */
  55256. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55257. /**
  55258. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55259. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55260. */
  55261. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55262. /**
  55263. * Stores surface normal data used to displace a mesh in a texture.
  55264. */
  55265. protected _bumpTexture: Nullable<BaseTexture>;
  55266. /**
  55267. * Stores the pre-calculated light information of a mesh in a texture.
  55268. */
  55269. protected _lightmapTexture: Nullable<BaseTexture>;
  55270. /**
  55271. * The color of a material in ambient lighting.
  55272. */
  55273. protected _ambientColor: Color3;
  55274. /**
  55275. * AKA Diffuse Color in other nomenclature.
  55276. */
  55277. protected _albedoColor: Color3;
  55278. /**
  55279. * AKA Specular Color in other nomenclature.
  55280. */
  55281. protected _reflectivityColor: Color3;
  55282. /**
  55283. * The color applied when light is reflected from a material.
  55284. */
  55285. protected _reflectionColor: Color3;
  55286. /**
  55287. * The color applied when light is emitted from a material.
  55288. */
  55289. protected _emissiveColor: Color3;
  55290. /**
  55291. * AKA Glossiness in other nomenclature.
  55292. */
  55293. protected _microSurface: number;
  55294. /**
  55295. * Specifies that the material will use the light map as a show map.
  55296. */
  55297. protected _useLightmapAsShadowmap: boolean;
  55298. /**
  55299. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55300. * makes the reflect vector face the model (under horizon).
  55301. */
  55302. protected _useHorizonOcclusion: boolean;
  55303. /**
  55304. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55305. * too much the area relying on ambient texture to define their ambient occlusion.
  55306. */
  55307. protected _useRadianceOcclusion: boolean;
  55308. /**
  55309. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55310. */
  55311. protected _useAlphaFromAlbedoTexture: boolean;
  55312. /**
  55313. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55314. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55315. */
  55316. protected _useSpecularOverAlpha: boolean;
  55317. /**
  55318. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55319. */
  55320. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55321. /**
  55322. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55323. */
  55324. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55325. /**
  55326. * Specifies if the metallic texture contains the roughness information in its green channel.
  55327. */
  55328. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55329. /**
  55330. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55331. */
  55332. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55333. /**
  55334. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55335. */
  55336. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55337. /**
  55338. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55339. */
  55340. protected _useAmbientInGrayScale: boolean;
  55341. /**
  55342. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55343. * The material will try to infer what glossiness each pixel should be.
  55344. */
  55345. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55346. /**
  55347. * Defines the falloff type used in this material.
  55348. * It by default is Physical.
  55349. */
  55350. protected _lightFalloff: number;
  55351. /**
  55352. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55353. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55354. */
  55355. protected _useRadianceOverAlpha: boolean;
  55356. /**
  55357. * Allows using an object space normal map (instead of tangent space).
  55358. */
  55359. protected _useObjectSpaceNormalMap: boolean;
  55360. /**
  55361. * Allows using the bump map in parallax mode.
  55362. */
  55363. protected _useParallax: boolean;
  55364. /**
  55365. * Allows using the bump map in parallax occlusion mode.
  55366. */
  55367. protected _useParallaxOcclusion: boolean;
  55368. /**
  55369. * Controls the scale bias of the parallax mode.
  55370. */
  55371. protected _parallaxScaleBias: number;
  55372. /**
  55373. * If sets to true, disables all the lights affecting the material.
  55374. */
  55375. protected _disableLighting: boolean;
  55376. /**
  55377. * Number of Simultaneous lights allowed on the material.
  55378. */
  55379. protected _maxSimultaneousLights: number;
  55380. /**
  55381. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55382. */
  55383. protected _invertNormalMapX: boolean;
  55384. /**
  55385. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55386. */
  55387. protected _invertNormalMapY: boolean;
  55388. /**
  55389. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55390. */
  55391. protected _twoSidedLighting: boolean;
  55392. /**
  55393. * Defines the alpha limits in alpha test mode.
  55394. */
  55395. protected _alphaCutOff: number;
  55396. /**
  55397. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55398. */
  55399. protected _forceAlphaTest: boolean;
  55400. /**
  55401. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55402. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55403. */
  55404. protected _useAlphaFresnel: boolean;
  55405. /**
  55406. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55407. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55408. */
  55409. protected _useLinearAlphaFresnel: boolean;
  55410. /**
  55411. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55412. * from cos thetav and roughness:
  55413. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55414. */
  55415. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55416. /**
  55417. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55418. */
  55419. protected _forceIrradianceInFragment: boolean;
  55420. private _realTimeFiltering;
  55421. /**
  55422. * Enables realtime filtering on the texture.
  55423. */
  55424. get realTimeFiltering(): boolean;
  55425. set realTimeFiltering(b: boolean);
  55426. private _realTimeFilteringQuality;
  55427. /**
  55428. * Quality switch for realtime filtering
  55429. */
  55430. get realTimeFilteringQuality(): number;
  55431. set realTimeFilteringQuality(n: number);
  55432. /**
  55433. * Force normal to face away from face.
  55434. */
  55435. protected _forceNormalForward: boolean;
  55436. /**
  55437. * Enables specular anti aliasing in the PBR shader.
  55438. * It will both interacts on the Geometry for analytical and IBL lighting.
  55439. * It also prefilter the roughness map based on the bump values.
  55440. */
  55441. protected _enableSpecularAntiAliasing: boolean;
  55442. /**
  55443. * Default configuration related to image processing available in the PBR Material.
  55444. */
  55445. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55446. /**
  55447. * Keep track of the image processing observer to allow dispose and replace.
  55448. */
  55449. private _imageProcessingObserver;
  55450. /**
  55451. * Attaches a new image processing configuration to the PBR Material.
  55452. * @param configuration
  55453. */
  55454. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55455. /**
  55456. * Stores the available render targets.
  55457. */
  55458. private _renderTargets;
  55459. /**
  55460. * Sets the global ambient color for the material used in lighting calculations.
  55461. */
  55462. private _globalAmbientColor;
  55463. /**
  55464. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55465. */
  55466. private _useLogarithmicDepth;
  55467. /**
  55468. * If set to true, no lighting calculations will be applied.
  55469. */
  55470. private _unlit;
  55471. private _debugMode;
  55472. /**
  55473. * @hidden
  55474. * This is reserved for the inspector.
  55475. * Defines the material debug mode.
  55476. * It helps seeing only some components of the material while troubleshooting.
  55477. */
  55478. debugMode: number;
  55479. /**
  55480. * @hidden
  55481. * This is reserved for the inspector.
  55482. * Specify from where on screen the debug mode should start.
  55483. * The value goes from -1 (full screen) to 1 (not visible)
  55484. * It helps with side by side comparison against the final render
  55485. * This defaults to -1
  55486. */
  55487. private debugLimit;
  55488. /**
  55489. * @hidden
  55490. * This is reserved for the inspector.
  55491. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55492. * You can use the factor to better multiply the final value.
  55493. */
  55494. private debugFactor;
  55495. /**
  55496. * Defines the clear coat layer parameters for the material.
  55497. */
  55498. readonly clearCoat: PBRClearCoatConfiguration;
  55499. /**
  55500. * Defines the anisotropic parameters for the material.
  55501. */
  55502. readonly anisotropy: PBRAnisotropicConfiguration;
  55503. /**
  55504. * Defines the BRDF parameters for the material.
  55505. */
  55506. readonly brdf: PBRBRDFConfiguration;
  55507. /**
  55508. * Defines the Sheen parameters for the material.
  55509. */
  55510. readonly sheen: PBRSheenConfiguration;
  55511. /**
  55512. * Defines the SubSurface parameters for the material.
  55513. */
  55514. readonly subSurface: PBRSubSurfaceConfiguration;
  55515. /**
  55516. * Defines the detail map parameters for the material.
  55517. */
  55518. readonly detailMap: DetailMapConfiguration;
  55519. protected _rebuildInParallel: boolean;
  55520. /**
  55521. * Instantiates a new PBRMaterial instance.
  55522. *
  55523. * @param name The material name
  55524. * @param scene The scene the material will be use in.
  55525. */
  55526. constructor(name: string, scene: Scene);
  55527. /**
  55528. * Gets a boolean indicating that current material needs to register RTT
  55529. */
  55530. get hasRenderTargetTextures(): boolean;
  55531. /**
  55532. * Gets the name of the material class.
  55533. */
  55534. getClassName(): string;
  55535. /**
  55536. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55537. */
  55538. get useLogarithmicDepth(): boolean;
  55539. /**
  55540. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55541. */
  55542. set useLogarithmicDepth(value: boolean);
  55543. /**
  55544. * Returns true if alpha blending should be disabled.
  55545. */
  55546. protected get _disableAlphaBlending(): boolean;
  55547. /**
  55548. * Specifies whether or not this material should be rendered in alpha blend mode.
  55549. */
  55550. needAlphaBlending(): boolean;
  55551. /**
  55552. * Specifies whether or not this material should be rendered in alpha test mode.
  55553. */
  55554. needAlphaTesting(): boolean;
  55555. /**
  55556. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55557. */
  55558. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55559. /**
  55560. * Gets the texture used for the alpha test.
  55561. */
  55562. getAlphaTestTexture(): Nullable<BaseTexture>;
  55563. /**
  55564. * Specifies that the submesh is ready to be used.
  55565. * @param mesh - BJS mesh.
  55566. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55567. * @param useInstances - Specifies that instances should be used.
  55568. * @returns - boolean indicating that the submesh is ready or not.
  55569. */
  55570. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55571. /**
  55572. * Specifies if the material uses metallic roughness workflow.
  55573. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55574. */
  55575. isMetallicWorkflow(): boolean;
  55576. private _prepareEffect;
  55577. private _prepareDefines;
  55578. /**
  55579. * Force shader compilation
  55580. */
  55581. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55582. /**
  55583. * Initializes the uniform buffer layout for the shader.
  55584. */
  55585. buildUniformLayout(): void;
  55586. /**
  55587. * Unbinds the material from the mesh
  55588. */
  55589. unbind(): void;
  55590. /**
  55591. * Binds the submesh data.
  55592. * @param world - The world matrix.
  55593. * @param mesh - The BJS mesh.
  55594. * @param subMesh - A submesh of the BJS mesh.
  55595. */
  55596. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55597. /**
  55598. * Returns the animatable textures.
  55599. * @returns - Array of animatable textures.
  55600. */
  55601. getAnimatables(): IAnimatable[];
  55602. /**
  55603. * Returns the texture used for reflections.
  55604. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55605. */
  55606. private _getReflectionTexture;
  55607. /**
  55608. * Returns an array of the actively used textures.
  55609. * @returns - Array of BaseTextures
  55610. */
  55611. getActiveTextures(): BaseTexture[];
  55612. /**
  55613. * Checks to see if a texture is used in the material.
  55614. * @param texture - Base texture to use.
  55615. * @returns - Boolean specifying if a texture is used in the material.
  55616. */
  55617. hasTexture(texture: BaseTexture): boolean;
  55618. /**
  55619. * Disposes the resources of the material.
  55620. * @param forceDisposeEffect - Forces the disposal of effects.
  55621. * @param forceDisposeTextures - Forces the disposal of all textures.
  55622. */
  55623. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55624. }
  55625. }
  55626. declare module BABYLON {
  55627. /**
  55628. * The Physically based material of BJS.
  55629. *
  55630. * This offers the main features of a standard PBR material.
  55631. * For more information, please refer to the documentation :
  55632. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55633. */
  55634. export class PBRMaterial extends PBRBaseMaterial {
  55635. /**
  55636. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55637. */
  55638. static readonly PBRMATERIAL_OPAQUE: number;
  55639. /**
  55640. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55641. */
  55642. static readonly PBRMATERIAL_ALPHATEST: number;
  55643. /**
  55644. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55645. */
  55646. static readonly PBRMATERIAL_ALPHABLEND: number;
  55647. /**
  55648. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55649. * They are also discarded below the alpha cutoff threshold to improve performances.
  55650. */
  55651. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55652. /**
  55653. * Defines the default value of how much AO map is occluding the analytical lights
  55654. * (point spot...).
  55655. */
  55656. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55657. /**
  55658. * Intensity of the direct lights e.g. the four lights available in your scene.
  55659. * This impacts both the direct diffuse and specular highlights.
  55660. */
  55661. directIntensity: number;
  55662. /**
  55663. * Intensity of the emissive part of the material.
  55664. * This helps controlling the emissive effect without modifying the emissive color.
  55665. */
  55666. emissiveIntensity: number;
  55667. /**
  55668. * Intensity of the environment e.g. how much the environment will light the object
  55669. * either through harmonics for rough material or through the refelction for shiny ones.
  55670. */
  55671. environmentIntensity: number;
  55672. /**
  55673. * This is a special control allowing the reduction of the specular highlights coming from the
  55674. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55675. */
  55676. specularIntensity: number;
  55677. /**
  55678. * Debug Control allowing disabling the bump map on this material.
  55679. */
  55680. disableBumpMap: boolean;
  55681. /**
  55682. * AKA Diffuse Texture in standard nomenclature.
  55683. */
  55684. albedoTexture: BaseTexture;
  55685. /**
  55686. * AKA Occlusion Texture in other nomenclature.
  55687. */
  55688. ambientTexture: BaseTexture;
  55689. /**
  55690. * AKA Occlusion Texture Intensity in other nomenclature.
  55691. */
  55692. ambientTextureStrength: number;
  55693. /**
  55694. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55695. * 1 means it completely occludes it
  55696. * 0 mean it has no impact
  55697. */
  55698. ambientTextureImpactOnAnalyticalLights: number;
  55699. /**
  55700. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55701. */
  55702. opacityTexture: BaseTexture;
  55703. /**
  55704. * Stores the reflection values in a texture.
  55705. */
  55706. reflectionTexture: Nullable<BaseTexture>;
  55707. /**
  55708. * Stores the emissive values in a texture.
  55709. */
  55710. emissiveTexture: BaseTexture;
  55711. /**
  55712. * AKA Specular texture in other nomenclature.
  55713. */
  55714. reflectivityTexture: BaseTexture;
  55715. /**
  55716. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55717. */
  55718. metallicTexture: BaseTexture;
  55719. /**
  55720. * Specifies the metallic scalar of the metallic/roughness workflow.
  55721. * Can also be used to scale the metalness values of the metallic texture.
  55722. */
  55723. metallic: Nullable<number>;
  55724. /**
  55725. * Specifies the roughness scalar of the metallic/roughness workflow.
  55726. * Can also be used to scale the roughness values of the metallic texture.
  55727. */
  55728. roughness: Nullable<number>;
  55729. /**
  55730. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55731. * By default the indexOfrefraction is used to compute F0;
  55732. *
  55733. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55734. *
  55735. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55736. * F90 = metallicReflectanceColor;
  55737. */
  55738. metallicF0Factor: number;
  55739. /**
  55740. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55741. * By default the F90 is always 1;
  55742. *
  55743. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55744. *
  55745. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55746. * F90 = metallicReflectanceColor;
  55747. */
  55748. metallicReflectanceColor: Color3;
  55749. /**
  55750. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55751. * This is multiply against the scalar values defined in the material.
  55752. */
  55753. metallicReflectanceTexture: Nullable<BaseTexture>;
  55754. /**
  55755. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55756. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55757. */
  55758. microSurfaceTexture: BaseTexture;
  55759. /**
  55760. * Stores surface normal data used to displace a mesh in a texture.
  55761. */
  55762. bumpTexture: BaseTexture;
  55763. /**
  55764. * Stores the pre-calculated light information of a mesh in a texture.
  55765. */
  55766. lightmapTexture: BaseTexture;
  55767. /**
  55768. * Stores the refracted light information in a texture.
  55769. */
  55770. get refractionTexture(): Nullable<BaseTexture>;
  55771. set refractionTexture(value: Nullable<BaseTexture>);
  55772. /**
  55773. * The color of a material in ambient lighting.
  55774. */
  55775. ambientColor: Color3;
  55776. /**
  55777. * AKA Diffuse Color in other nomenclature.
  55778. */
  55779. albedoColor: Color3;
  55780. /**
  55781. * AKA Specular Color in other nomenclature.
  55782. */
  55783. reflectivityColor: Color3;
  55784. /**
  55785. * The color reflected from the material.
  55786. */
  55787. reflectionColor: Color3;
  55788. /**
  55789. * The color emitted from the material.
  55790. */
  55791. emissiveColor: Color3;
  55792. /**
  55793. * AKA Glossiness in other nomenclature.
  55794. */
  55795. microSurface: number;
  55796. /**
  55797. * Index of refraction of the material base layer.
  55798. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55799. *
  55800. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55801. *
  55802. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55803. */
  55804. get indexOfRefraction(): number;
  55805. set indexOfRefraction(value: number);
  55806. /**
  55807. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55808. */
  55809. get invertRefractionY(): boolean;
  55810. set invertRefractionY(value: boolean);
  55811. /**
  55812. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55813. * Materials half opaque for instance using refraction could benefit from this control.
  55814. */
  55815. get linkRefractionWithTransparency(): boolean;
  55816. set linkRefractionWithTransparency(value: boolean);
  55817. /**
  55818. * If true, the light map contains occlusion information instead of lighting info.
  55819. */
  55820. useLightmapAsShadowmap: boolean;
  55821. /**
  55822. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55823. */
  55824. useAlphaFromAlbedoTexture: boolean;
  55825. /**
  55826. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55827. */
  55828. forceAlphaTest: boolean;
  55829. /**
  55830. * Defines the alpha limits in alpha test mode.
  55831. */
  55832. alphaCutOff: number;
  55833. /**
  55834. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55835. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55836. */
  55837. useSpecularOverAlpha: boolean;
  55838. /**
  55839. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55840. */
  55841. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55842. /**
  55843. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55844. */
  55845. useRoughnessFromMetallicTextureAlpha: boolean;
  55846. /**
  55847. * Specifies if the metallic texture contains the roughness information in its green channel.
  55848. */
  55849. useRoughnessFromMetallicTextureGreen: boolean;
  55850. /**
  55851. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55852. */
  55853. useMetallnessFromMetallicTextureBlue: boolean;
  55854. /**
  55855. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55856. */
  55857. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55858. /**
  55859. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55860. */
  55861. useAmbientInGrayScale: boolean;
  55862. /**
  55863. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55864. * The material will try to infer what glossiness each pixel should be.
  55865. */
  55866. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55867. /**
  55868. * BJS is using an harcoded light falloff based on a manually sets up range.
  55869. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55870. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55871. */
  55872. get usePhysicalLightFalloff(): boolean;
  55873. /**
  55874. * BJS is using an harcoded light falloff based on a manually sets up range.
  55875. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55876. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55877. */
  55878. set usePhysicalLightFalloff(value: boolean);
  55879. /**
  55880. * In order to support the falloff compatibility with gltf, a special mode has been added
  55881. * to reproduce the gltf light falloff.
  55882. */
  55883. get useGLTFLightFalloff(): boolean;
  55884. /**
  55885. * In order to support the falloff compatibility with gltf, a special mode has been added
  55886. * to reproduce the gltf light falloff.
  55887. */
  55888. set useGLTFLightFalloff(value: boolean);
  55889. /**
  55890. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55891. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55892. */
  55893. useRadianceOverAlpha: boolean;
  55894. /**
  55895. * Allows using an object space normal map (instead of tangent space).
  55896. */
  55897. useObjectSpaceNormalMap: boolean;
  55898. /**
  55899. * Allows using the bump map in parallax mode.
  55900. */
  55901. useParallax: boolean;
  55902. /**
  55903. * Allows using the bump map in parallax occlusion mode.
  55904. */
  55905. useParallaxOcclusion: boolean;
  55906. /**
  55907. * Controls the scale bias of the parallax mode.
  55908. */
  55909. parallaxScaleBias: number;
  55910. /**
  55911. * If sets to true, disables all the lights affecting the material.
  55912. */
  55913. disableLighting: boolean;
  55914. /**
  55915. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55916. */
  55917. forceIrradianceInFragment: boolean;
  55918. /**
  55919. * Number of Simultaneous lights allowed on the material.
  55920. */
  55921. maxSimultaneousLights: number;
  55922. /**
  55923. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55924. */
  55925. invertNormalMapX: boolean;
  55926. /**
  55927. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55928. */
  55929. invertNormalMapY: boolean;
  55930. /**
  55931. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55932. */
  55933. twoSidedLighting: boolean;
  55934. /**
  55935. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55936. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55937. */
  55938. useAlphaFresnel: boolean;
  55939. /**
  55940. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55941. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55942. */
  55943. useLinearAlphaFresnel: boolean;
  55944. /**
  55945. * Let user defines the brdf lookup texture used for IBL.
  55946. * A default 8bit version is embedded but you could point at :
  55947. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55948. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55949. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55950. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55951. */
  55952. environmentBRDFTexture: Nullable<BaseTexture>;
  55953. /**
  55954. * Force normal to face away from face.
  55955. */
  55956. forceNormalForward: boolean;
  55957. /**
  55958. * Enables specular anti aliasing in the PBR shader.
  55959. * It will both interacts on the Geometry for analytical and IBL lighting.
  55960. * It also prefilter the roughness map based on the bump values.
  55961. */
  55962. enableSpecularAntiAliasing: boolean;
  55963. /**
  55964. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55965. * makes the reflect vector face the model (under horizon).
  55966. */
  55967. useHorizonOcclusion: boolean;
  55968. /**
  55969. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55970. * too much the area relying on ambient texture to define their ambient occlusion.
  55971. */
  55972. useRadianceOcclusion: boolean;
  55973. /**
  55974. * If set to true, no lighting calculations will be applied.
  55975. */
  55976. unlit: boolean;
  55977. /**
  55978. * Gets the image processing configuration used either in this material.
  55979. */
  55980. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55981. /**
  55982. * Sets the Default image processing configuration used either in the this material.
  55983. *
  55984. * If sets to null, the scene one is in use.
  55985. */
  55986. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55987. /**
  55988. * Gets wether the color curves effect is enabled.
  55989. */
  55990. get cameraColorCurvesEnabled(): boolean;
  55991. /**
  55992. * Sets wether the color curves effect is enabled.
  55993. */
  55994. set cameraColorCurvesEnabled(value: boolean);
  55995. /**
  55996. * Gets wether the color grading effect is enabled.
  55997. */
  55998. get cameraColorGradingEnabled(): boolean;
  55999. /**
  56000. * Gets wether the color grading effect is enabled.
  56001. */
  56002. set cameraColorGradingEnabled(value: boolean);
  56003. /**
  56004. * Gets wether tonemapping is enabled or not.
  56005. */
  56006. get cameraToneMappingEnabled(): boolean;
  56007. /**
  56008. * Sets wether tonemapping is enabled or not
  56009. */
  56010. set cameraToneMappingEnabled(value: boolean);
  56011. /**
  56012. * The camera exposure used on this material.
  56013. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56014. * This corresponds to a photographic exposure.
  56015. */
  56016. get cameraExposure(): number;
  56017. /**
  56018. * The camera exposure used on this material.
  56019. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56020. * This corresponds to a photographic exposure.
  56021. */
  56022. set cameraExposure(value: number);
  56023. /**
  56024. * Gets The camera contrast used on this material.
  56025. */
  56026. get cameraContrast(): number;
  56027. /**
  56028. * Sets The camera contrast used on this material.
  56029. */
  56030. set cameraContrast(value: number);
  56031. /**
  56032. * Gets the Color Grading 2D Lookup Texture.
  56033. */
  56034. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56035. /**
  56036. * Sets the Color Grading 2D Lookup Texture.
  56037. */
  56038. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56039. /**
  56040. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56041. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56042. * 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;
  56043. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56044. */
  56045. get cameraColorCurves(): Nullable<ColorCurves>;
  56046. /**
  56047. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56048. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56049. * 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;
  56050. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56051. */
  56052. set cameraColorCurves(value: Nullable<ColorCurves>);
  56053. /**
  56054. * Instantiates a new PBRMaterial instance.
  56055. *
  56056. * @param name The material name
  56057. * @param scene The scene the material will be use in.
  56058. */
  56059. constructor(name: string, scene: Scene);
  56060. /**
  56061. * Returns the name of this material class.
  56062. */
  56063. getClassName(): string;
  56064. /**
  56065. * Makes a duplicate of the current material.
  56066. * @param name - name to use for the new material.
  56067. */
  56068. clone(name: string): PBRMaterial;
  56069. /**
  56070. * Serializes this PBR Material.
  56071. * @returns - An object with the serialized material.
  56072. */
  56073. serialize(): any;
  56074. /**
  56075. * Parses a PBR Material from a serialized object.
  56076. * @param source - Serialized object.
  56077. * @param scene - BJS scene instance.
  56078. * @param rootUrl - url for the scene object
  56079. * @returns - PBRMaterial
  56080. */
  56081. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56082. }
  56083. }
  56084. declare module BABYLON {
  56085. /**
  56086. * Direct draw surface info
  56087. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56088. */
  56089. export interface DDSInfo {
  56090. /**
  56091. * Width of the texture
  56092. */
  56093. width: number;
  56094. /**
  56095. * Width of the texture
  56096. */
  56097. height: number;
  56098. /**
  56099. * Number of Mipmaps for the texture
  56100. * @see https://en.wikipedia.org/wiki/Mipmap
  56101. */
  56102. mipmapCount: number;
  56103. /**
  56104. * If the textures format is a known fourCC format
  56105. * @see https://www.fourcc.org/
  56106. */
  56107. isFourCC: boolean;
  56108. /**
  56109. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56110. */
  56111. isRGB: boolean;
  56112. /**
  56113. * If the texture is a lumincance format
  56114. */
  56115. isLuminance: boolean;
  56116. /**
  56117. * If this is a cube texture
  56118. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56119. */
  56120. isCube: boolean;
  56121. /**
  56122. * If the texture is a compressed format eg. FOURCC_DXT1
  56123. */
  56124. isCompressed: boolean;
  56125. /**
  56126. * The dxgiFormat of the texture
  56127. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56128. */
  56129. dxgiFormat: number;
  56130. /**
  56131. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56132. */
  56133. textureType: number;
  56134. /**
  56135. * Sphericle polynomial created for the dds texture
  56136. */
  56137. sphericalPolynomial?: SphericalPolynomial;
  56138. }
  56139. /**
  56140. * Class used to provide DDS decompression tools
  56141. */
  56142. export class DDSTools {
  56143. /**
  56144. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56145. */
  56146. static StoreLODInAlphaChannel: boolean;
  56147. /**
  56148. * Gets DDS information from an array buffer
  56149. * @param data defines the array buffer view to read data from
  56150. * @returns the DDS information
  56151. */
  56152. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56153. private static _FloatView;
  56154. private static _Int32View;
  56155. private static _ToHalfFloat;
  56156. private static _FromHalfFloat;
  56157. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56158. private static _GetHalfFloatRGBAArrayBuffer;
  56159. private static _GetFloatRGBAArrayBuffer;
  56160. private static _GetFloatAsUIntRGBAArrayBuffer;
  56161. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56162. private static _GetRGBAArrayBuffer;
  56163. private static _ExtractLongWordOrder;
  56164. private static _GetRGBArrayBuffer;
  56165. private static _GetLuminanceArrayBuffer;
  56166. /**
  56167. * Uploads DDS Levels to a Babylon Texture
  56168. * @hidden
  56169. */
  56170. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56171. }
  56172. interface ThinEngine {
  56173. /**
  56174. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56175. * @param rootUrl defines the url where the file to load is located
  56176. * @param scene defines the current scene
  56177. * @param lodScale defines scale to apply to the mip map selection
  56178. * @param lodOffset defines offset to apply to the mip map selection
  56179. * @param onLoad defines an optional callback raised when the texture is loaded
  56180. * @param onError defines an optional callback raised if there is an issue to load the texture
  56181. * @param format defines the format of the data
  56182. * @param forcedExtension defines the extension to use to pick the right loader
  56183. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56184. * @returns the cube texture as an InternalTexture
  56185. */
  56186. 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;
  56187. }
  56188. }
  56189. declare module BABYLON {
  56190. /**
  56191. * Implementation of the DDS Texture Loader.
  56192. * @hidden
  56193. */
  56194. export class _DDSTextureLoader implements IInternalTextureLoader {
  56195. /**
  56196. * Defines wether the loader supports cascade loading the different faces.
  56197. */
  56198. readonly supportCascades: boolean;
  56199. /**
  56200. * This returns if the loader support the current file information.
  56201. * @param extension defines the file extension of the file being loaded
  56202. * @returns true if the loader can load the specified file
  56203. */
  56204. canLoad(extension: string): boolean;
  56205. /**
  56206. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56207. * @param data contains the texture data
  56208. * @param texture defines the BabylonJS internal texture
  56209. * @param createPolynomials will be true if polynomials have been requested
  56210. * @param onLoad defines the callback to trigger once the texture is ready
  56211. * @param onError defines the callback to trigger in case of error
  56212. */
  56213. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56214. /**
  56215. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56216. * @param data contains the texture data
  56217. * @param texture defines the BabylonJS internal texture
  56218. * @param callback defines the method to call once ready to upload
  56219. */
  56220. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56221. }
  56222. }
  56223. declare module BABYLON {
  56224. /**
  56225. * Implementation of the ENV Texture Loader.
  56226. * @hidden
  56227. */
  56228. export class _ENVTextureLoader implements IInternalTextureLoader {
  56229. /**
  56230. * Defines wether the loader supports cascade loading the different faces.
  56231. */
  56232. readonly supportCascades: boolean;
  56233. /**
  56234. * This returns if the loader support the current file information.
  56235. * @param extension defines the file extension of the file being loaded
  56236. * @returns true if the loader can load the specified file
  56237. */
  56238. canLoad(extension: string): boolean;
  56239. /**
  56240. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56241. * @param data contains the texture data
  56242. * @param texture defines the BabylonJS internal texture
  56243. * @param createPolynomials will be true if polynomials have been requested
  56244. * @param onLoad defines the callback to trigger once the texture is ready
  56245. * @param onError defines the callback to trigger in case of error
  56246. */
  56247. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56248. /**
  56249. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56250. * @param data contains the texture data
  56251. * @param texture defines the BabylonJS internal texture
  56252. * @param callback defines the method to call once ready to upload
  56253. */
  56254. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56255. }
  56256. }
  56257. declare module BABYLON {
  56258. /**
  56259. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56260. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56261. */
  56262. export class KhronosTextureContainer {
  56263. /** contents of the KTX container file */
  56264. data: ArrayBufferView;
  56265. private static HEADER_LEN;
  56266. private static COMPRESSED_2D;
  56267. private static COMPRESSED_3D;
  56268. private static TEX_2D;
  56269. private static TEX_3D;
  56270. /**
  56271. * Gets the openGL type
  56272. */
  56273. glType: number;
  56274. /**
  56275. * Gets the openGL type size
  56276. */
  56277. glTypeSize: number;
  56278. /**
  56279. * Gets the openGL format
  56280. */
  56281. glFormat: number;
  56282. /**
  56283. * Gets the openGL internal format
  56284. */
  56285. glInternalFormat: number;
  56286. /**
  56287. * Gets the base internal format
  56288. */
  56289. glBaseInternalFormat: number;
  56290. /**
  56291. * Gets image width in pixel
  56292. */
  56293. pixelWidth: number;
  56294. /**
  56295. * Gets image height in pixel
  56296. */
  56297. pixelHeight: number;
  56298. /**
  56299. * Gets image depth in pixels
  56300. */
  56301. pixelDepth: number;
  56302. /**
  56303. * Gets the number of array elements
  56304. */
  56305. numberOfArrayElements: number;
  56306. /**
  56307. * Gets the number of faces
  56308. */
  56309. numberOfFaces: number;
  56310. /**
  56311. * Gets the number of mipmap levels
  56312. */
  56313. numberOfMipmapLevels: number;
  56314. /**
  56315. * Gets the bytes of key value data
  56316. */
  56317. bytesOfKeyValueData: number;
  56318. /**
  56319. * Gets the load type
  56320. */
  56321. loadType: number;
  56322. /**
  56323. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56324. */
  56325. isInvalid: boolean;
  56326. /**
  56327. * Creates a new KhronosTextureContainer
  56328. * @param data contents of the KTX container file
  56329. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56330. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56331. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56332. */
  56333. constructor(
  56334. /** contents of the KTX container file */
  56335. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56336. /**
  56337. * Uploads KTX content to a Babylon Texture.
  56338. * It is assumed that the texture has already been created & is currently bound
  56339. * @hidden
  56340. */
  56341. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56342. private _upload2DCompressedLevels;
  56343. /**
  56344. * Checks if the given data starts with a KTX file identifier.
  56345. * @param data the data to check
  56346. * @returns true if the data is a KTX file or false otherwise
  56347. */
  56348. static IsValid(data: ArrayBufferView): boolean;
  56349. }
  56350. }
  56351. declare module BABYLON {
  56352. /**
  56353. * Class for loading KTX2 files
  56354. * !!! Experimental Extension Subject to Changes !!!
  56355. * @hidden
  56356. */
  56357. export class KhronosTextureContainer2 {
  56358. private static _ModulePromise;
  56359. private static _TranscodeFormat;
  56360. constructor(engine: ThinEngine);
  56361. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56362. private _determineTranscodeFormat;
  56363. /**
  56364. * Checks if the given data starts with a KTX2 file identifier.
  56365. * @param data the data to check
  56366. * @returns true if the data is a KTX2 file or false otherwise
  56367. */
  56368. static IsValid(data: ArrayBufferView): boolean;
  56369. }
  56370. }
  56371. declare module BABYLON {
  56372. /**
  56373. * Implementation of the KTX Texture Loader.
  56374. * @hidden
  56375. */
  56376. export class _KTXTextureLoader implements IInternalTextureLoader {
  56377. /**
  56378. * Defines wether the loader supports cascade loading the different faces.
  56379. */
  56380. readonly supportCascades: boolean;
  56381. /**
  56382. * This returns if the loader support the current file information.
  56383. * @param extension defines the file extension of the file being loaded
  56384. * @returns true if the loader can load the specified file
  56385. */
  56386. canLoad(extension: string): boolean;
  56387. /**
  56388. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56389. * @param data contains the texture data
  56390. * @param texture defines the BabylonJS internal texture
  56391. * @param createPolynomials will be true if polynomials have been requested
  56392. * @param onLoad defines the callback to trigger once the texture is ready
  56393. * @param onError defines the callback to trigger in case of error
  56394. */
  56395. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56396. /**
  56397. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56398. * @param data contains the texture data
  56399. * @param texture defines the BabylonJS internal texture
  56400. * @param callback defines the method to call once ready to upload
  56401. */
  56402. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56403. }
  56404. }
  56405. declare module BABYLON {
  56406. /** @hidden */
  56407. export var _forceSceneHelpersToBundle: boolean;
  56408. interface Scene {
  56409. /**
  56410. * Creates a default light for the scene.
  56411. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56412. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56413. */
  56414. createDefaultLight(replace?: boolean): void;
  56415. /**
  56416. * Creates a default camera for the scene.
  56417. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56418. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56419. * @param replace has default false, when true replaces the active camera in the scene
  56420. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56421. */
  56422. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56423. /**
  56424. * Creates a default camera and a default light.
  56425. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56426. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56427. * @param replace has the default false, when true replaces the active camera/light in the scene
  56428. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56429. */
  56430. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56431. /**
  56432. * Creates a new sky box
  56433. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56434. * @param environmentTexture defines the texture to use as environment texture
  56435. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56436. * @param scale defines the overall scale of the skybox
  56437. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56438. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56439. * @returns a new mesh holding the sky box
  56440. */
  56441. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56442. /**
  56443. * Creates a new environment
  56444. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56445. * @param options defines the options you can use to configure the environment
  56446. * @returns the new EnvironmentHelper
  56447. */
  56448. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56449. /**
  56450. * Creates a new VREXperienceHelper
  56451. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56452. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56453. * @returns a new VREXperienceHelper
  56454. */
  56455. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56456. /**
  56457. * Creates a new WebXRDefaultExperience
  56458. * @see http://doc.babylonjs.com/how_to/webxr
  56459. * @param options experience options
  56460. * @returns a promise for a new WebXRDefaultExperience
  56461. */
  56462. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56463. }
  56464. }
  56465. declare module BABYLON {
  56466. /**
  56467. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56468. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56469. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56470. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56471. */
  56472. export class VideoDome extends TransformNode {
  56473. /**
  56474. * Define the video source as a Monoscopic panoramic 360 video.
  56475. */
  56476. static readonly MODE_MONOSCOPIC: number;
  56477. /**
  56478. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56479. */
  56480. static readonly MODE_TOPBOTTOM: number;
  56481. /**
  56482. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56483. */
  56484. static readonly MODE_SIDEBYSIDE: number;
  56485. private _halfDome;
  56486. private _useDirectMapping;
  56487. /**
  56488. * The video texture being displayed on the sphere
  56489. */
  56490. protected _videoTexture: VideoTexture;
  56491. /**
  56492. * Gets the video texture being displayed on the sphere
  56493. */
  56494. get videoTexture(): VideoTexture;
  56495. /**
  56496. * The skybox material
  56497. */
  56498. protected _material: BackgroundMaterial;
  56499. /**
  56500. * The surface used for the skybox
  56501. */
  56502. protected _mesh: Mesh;
  56503. /**
  56504. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56505. */
  56506. private _halfDomeMask;
  56507. /**
  56508. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56509. * Also see the options.resolution property.
  56510. */
  56511. get fovMultiplier(): number;
  56512. set fovMultiplier(value: number);
  56513. private _videoMode;
  56514. /**
  56515. * Gets or set the current video mode for the video. It can be:
  56516. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56517. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56518. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56519. */
  56520. get videoMode(): number;
  56521. set videoMode(value: number);
  56522. /**
  56523. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56524. *
  56525. */
  56526. get halfDome(): boolean;
  56527. /**
  56528. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56529. */
  56530. set halfDome(enabled: boolean);
  56531. /**
  56532. * Oberserver used in Stereoscopic VR Mode.
  56533. */
  56534. private _onBeforeCameraRenderObserver;
  56535. /**
  56536. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56537. * @param name Element's name, child elements will append suffixes for their own names.
  56538. * @param urlsOrVideo defines the url(s) or the video element to use
  56539. * @param options An object containing optional or exposed sub element properties
  56540. */
  56541. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56542. resolution?: number;
  56543. clickToPlay?: boolean;
  56544. autoPlay?: boolean;
  56545. loop?: boolean;
  56546. size?: number;
  56547. poster?: string;
  56548. faceForward?: boolean;
  56549. useDirectMapping?: boolean;
  56550. halfDomeMode?: boolean;
  56551. }, scene: Scene);
  56552. private _changeVideoMode;
  56553. /**
  56554. * Releases resources associated with this node.
  56555. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56556. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56557. */
  56558. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56559. }
  56560. }
  56561. declare module BABYLON {
  56562. /**
  56563. * This class can be used to get instrumentation data from a Babylon engine
  56564. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56565. */
  56566. export class EngineInstrumentation implements IDisposable {
  56567. /**
  56568. * Define the instrumented engine.
  56569. */
  56570. engine: Engine;
  56571. private _captureGPUFrameTime;
  56572. private _gpuFrameTimeToken;
  56573. private _gpuFrameTime;
  56574. private _captureShaderCompilationTime;
  56575. private _shaderCompilationTime;
  56576. private _onBeginFrameObserver;
  56577. private _onEndFrameObserver;
  56578. private _onBeforeShaderCompilationObserver;
  56579. private _onAfterShaderCompilationObserver;
  56580. /**
  56581. * Gets the perf counter used for GPU frame time
  56582. */
  56583. get gpuFrameTimeCounter(): PerfCounter;
  56584. /**
  56585. * Gets the GPU frame time capture status
  56586. */
  56587. get captureGPUFrameTime(): boolean;
  56588. /**
  56589. * Enable or disable the GPU frame time capture
  56590. */
  56591. set captureGPUFrameTime(value: boolean);
  56592. /**
  56593. * Gets the perf counter used for shader compilation time
  56594. */
  56595. get shaderCompilationTimeCounter(): PerfCounter;
  56596. /**
  56597. * Gets the shader compilation time capture status
  56598. */
  56599. get captureShaderCompilationTime(): boolean;
  56600. /**
  56601. * Enable or disable the shader compilation time capture
  56602. */
  56603. set captureShaderCompilationTime(value: boolean);
  56604. /**
  56605. * Instantiates a new engine instrumentation.
  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#engineinstrumentation
  56608. * @param engine Defines the engine to instrument
  56609. */
  56610. constructor(
  56611. /**
  56612. * Define the instrumented engine.
  56613. */
  56614. engine: Engine);
  56615. /**
  56616. * Dispose and release associated resources.
  56617. */
  56618. dispose(): void;
  56619. }
  56620. }
  56621. declare module BABYLON {
  56622. /**
  56623. * This class can be used to get instrumentation data from a Babylon engine
  56624. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56625. */
  56626. export class SceneInstrumentation implements IDisposable {
  56627. /**
  56628. * Defines the scene to instrument
  56629. */
  56630. scene: Scene;
  56631. private _captureActiveMeshesEvaluationTime;
  56632. private _activeMeshesEvaluationTime;
  56633. private _captureRenderTargetsRenderTime;
  56634. private _renderTargetsRenderTime;
  56635. private _captureFrameTime;
  56636. private _frameTime;
  56637. private _captureRenderTime;
  56638. private _renderTime;
  56639. private _captureInterFrameTime;
  56640. private _interFrameTime;
  56641. private _captureParticlesRenderTime;
  56642. private _particlesRenderTime;
  56643. private _captureSpritesRenderTime;
  56644. private _spritesRenderTime;
  56645. private _capturePhysicsTime;
  56646. private _physicsTime;
  56647. private _captureAnimationsTime;
  56648. private _animationsTime;
  56649. private _captureCameraRenderTime;
  56650. private _cameraRenderTime;
  56651. private _onBeforeActiveMeshesEvaluationObserver;
  56652. private _onAfterActiveMeshesEvaluationObserver;
  56653. private _onBeforeRenderTargetsRenderObserver;
  56654. private _onAfterRenderTargetsRenderObserver;
  56655. private _onAfterRenderObserver;
  56656. private _onBeforeDrawPhaseObserver;
  56657. private _onAfterDrawPhaseObserver;
  56658. private _onBeforeAnimationsObserver;
  56659. private _onBeforeParticlesRenderingObserver;
  56660. private _onAfterParticlesRenderingObserver;
  56661. private _onBeforeSpritesRenderingObserver;
  56662. private _onAfterSpritesRenderingObserver;
  56663. private _onBeforePhysicsObserver;
  56664. private _onAfterPhysicsObserver;
  56665. private _onAfterAnimationsObserver;
  56666. private _onBeforeCameraRenderObserver;
  56667. private _onAfterCameraRenderObserver;
  56668. /**
  56669. * Gets the perf counter used for active meshes evaluation time
  56670. */
  56671. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56672. /**
  56673. * Gets the active meshes evaluation time capture status
  56674. */
  56675. get captureActiveMeshesEvaluationTime(): boolean;
  56676. /**
  56677. * Enable or disable the active meshes evaluation time capture
  56678. */
  56679. set captureActiveMeshesEvaluationTime(value: boolean);
  56680. /**
  56681. * Gets the perf counter used for render targets render time
  56682. */
  56683. get renderTargetsRenderTimeCounter(): PerfCounter;
  56684. /**
  56685. * Gets the render targets render time capture status
  56686. */
  56687. get captureRenderTargetsRenderTime(): boolean;
  56688. /**
  56689. * Enable or disable the render targets render time capture
  56690. */
  56691. set captureRenderTargetsRenderTime(value: boolean);
  56692. /**
  56693. * Gets the perf counter used for particles render time
  56694. */
  56695. get particlesRenderTimeCounter(): PerfCounter;
  56696. /**
  56697. * Gets the particles render time capture status
  56698. */
  56699. get captureParticlesRenderTime(): boolean;
  56700. /**
  56701. * Enable or disable the particles render time capture
  56702. */
  56703. set captureParticlesRenderTime(value: boolean);
  56704. /**
  56705. * Gets the perf counter used for sprites render time
  56706. */
  56707. get spritesRenderTimeCounter(): PerfCounter;
  56708. /**
  56709. * Gets the sprites render time capture status
  56710. */
  56711. get captureSpritesRenderTime(): boolean;
  56712. /**
  56713. * Enable or disable the sprites render time capture
  56714. */
  56715. set captureSpritesRenderTime(value: boolean);
  56716. /**
  56717. * Gets the perf counter used for physics time
  56718. */
  56719. get physicsTimeCounter(): PerfCounter;
  56720. /**
  56721. * Gets the physics time capture status
  56722. */
  56723. get capturePhysicsTime(): boolean;
  56724. /**
  56725. * Enable or disable the physics time capture
  56726. */
  56727. set capturePhysicsTime(value: boolean);
  56728. /**
  56729. * Gets the perf counter used for animations time
  56730. */
  56731. get animationsTimeCounter(): PerfCounter;
  56732. /**
  56733. * Gets the animations time capture status
  56734. */
  56735. get captureAnimationsTime(): boolean;
  56736. /**
  56737. * Enable or disable the animations time capture
  56738. */
  56739. set captureAnimationsTime(value: boolean);
  56740. /**
  56741. * Gets the perf counter used for frame time capture
  56742. */
  56743. get frameTimeCounter(): PerfCounter;
  56744. /**
  56745. * Gets the frame time capture status
  56746. */
  56747. get captureFrameTime(): boolean;
  56748. /**
  56749. * Enable or disable the frame time capture
  56750. */
  56751. set captureFrameTime(value: boolean);
  56752. /**
  56753. * Gets the perf counter used for inter-frames time capture
  56754. */
  56755. get interFrameTimeCounter(): PerfCounter;
  56756. /**
  56757. * Gets the inter-frames time capture status
  56758. */
  56759. get captureInterFrameTime(): boolean;
  56760. /**
  56761. * Enable or disable the inter-frames time capture
  56762. */
  56763. set captureInterFrameTime(value: boolean);
  56764. /**
  56765. * Gets the perf counter used for render time capture
  56766. */
  56767. get renderTimeCounter(): PerfCounter;
  56768. /**
  56769. * Gets the render time capture status
  56770. */
  56771. get captureRenderTime(): boolean;
  56772. /**
  56773. * Enable or disable the render time capture
  56774. */
  56775. set captureRenderTime(value: boolean);
  56776. /**
  56777. * Gets the perf counter used for camera render time capture
  56778. */
  56779. get cameraRenderTimeCounter(): PerfCounter;
  56780. /**
  56781. * Gets the camera render time capture status
  56782. */
  56783. get captureCameraRenderTime(): boolean;
  56784. /**
  56785. * Enable or disable the camera render time capture
  56786. */
  56787. set captureCameraRenderTime(value: boolean);
  56788. /**
  56789. * Gets the perf counter used for draw calls
  56790. */
  56791. get drawCallsCounter(): PerfCounter;
  56792. /**
  56793. * Instantiates a new scene instrumentation.
  56794. * This class can be used to get instrumentation data from a Babylon engine
  56795. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56796. * @param scene Defines the scene to instrument
  56797. */
  56798. constructor(
  56799. /**
  56800. * Defines the scene to instrument
  56801. */
  56802. scene: Scene);
  56803. /**
  56804. * Dispose and release associated resources.
  56805. */
  56806. dispose(): void;
  56807. }
  56808. }
  56809. declare module BABYLON {
  56810. /** @hidden */
  56811. export var glowMapGenerationPixelShader: {
  56812. name: string;
  56813. shader: string;
  56814. };
  56815. }
  56816. declare module BABYLON {
  56817. /** @hidden */
  56818. export var glowMapGenerationVertexShader: {
  56819. name: string;
  56820. shader: string;
  56821. };
  56822. }
  56823. declare module BABYLON {
  56824. /**
  56825. * Effect layer options. This helps customizing the behaviour
  56826. * of the effect layer.
  56827. */
  56828. export interface IEffectLayerOptions {
  56829. /**
  56830. * Multiplication factor apply to the canvas size to compute the render target size
  56831. * used to generated the objects (the smaller the faster).
  56832. */
  56833. mainTextureRatio: number;
  56834. /**
  56835. * Enforces a fixed size texture to ensure effect stability across devices.
  56836. */
  56837. mainTextureFixedSize?: number;
  56838. /**
  56839. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56840. */
  56841. alphaBlendingMode: number;
  56842. /**
  56843. * The camera attached to the layer.
  56844. */
  56845. camera: Nullable<Camera>;
  56846. /**
  56847. * The rendering group to draw the layer in.
  56848. */
  56849. renderingGroupId: number;
  56850. }
  56851. /**
  56852. * The effect layer Helps adding post process effect blended with the main pass.
  56853. *
  56854. * This can be for instance use to generate glow or higlight effects on the scene.
  56855. *
  56856. * The effect layer class can not be used directly and is intented to inherited from to be
  56857. * customized per effects.
  56858. */
  56859. export abstract class EffectLayer {
  56860. private _vertexBuffers;
  56861. private _indexBuffer;
  56862. private _cachedDefines;
  56863. private _effectLayerMapGenerationEffect;
  56864. private _effectLayerOptions;
  56865. private _mergeEffect;
  56866. protected _scene: Scene;
  56867. protected _engine: Engine;
  56868. protected _maxSize: number;
  56869. protected _mainTextureDesiredSize: ISize;
  56870. protected _mainTexture: RenderTargetTexture;
  56871. protected _shouldRender: boolean;
  56872. protected _postProcesses: PostProcess[];
  56873. protected _textures: BaseTexture[];
  56874. protected _emissiveTextureAndColor: {
  56875. texture: Nullable<BaseTexture>;
  56876. color: Color4;
  56877. };
  56878. /**
  56879. * The name of the layer
  56880. */
  56881. name: string;
  56882. /**
  56883. * The clear color of the texture used to generate the glow map.
  56884. */
  56885. neutralColor: Color4;
  56886. /**
  56887. * Specifies whether the highlight layer is enabled or not.
  56888. */
  56889. isEnabled: boolean;
  56890. /**
  56891. * Gets the camera attached to the layer.
  56892. */
  56893. get camera(): Nullable<Camera>;
  56894. /**
  56895. * Gets the rendering group id the layer should render in.
  56896. */
  56897. get renderingGroupId(): number;
  56898. set renderingGroupId(renderingGroupId: number);
  56899. /**
  56900. * An event triggered when the effect layer has been disposed.
  56901. */
  56902. onDisposeObservable: Observable<EffectLayer>;
  56903. /**
  56904. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56905. */
  56906. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56907. /**
  56908. * An event triggered when the generated texture is being merged in the scene.
  56909. */
  56910. onBeforeComposeObservable: Observable<EffectLayer>;
  56911. /**
  56912. * An event triggered when the mesh is rendered into the effect render target.
  56913. */
  56914. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56915. /**
  56916. * An event triggered after the mesh has been rendered into the effect render target.
  56917. */
  56918. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56919. /**
  56920. * An event triggered when the generated texture has been merged in the scene.
  56921. */
  56922. onAfterComposeObservable: Observable<EffectLayer>;
  56923. /**
  56924. * An event triggered when the efffect layer changes its size.
  56925. */
  56926. onSizeChangedObservable: Observable<EffectLayer>;
  56927. /** @hidden */
  56928. static _SceneComponentInitialization: (scene: Scene) => void;
  56929. /**
  56930. * Instantiates a new effect Layer and references it in the scene.
  56931. * @param name The name of the layer
  56932. * @param scene The scene to use the layer in
  56933. */
  56934. constructor(
  56935. /** The Friendly of the effect in the scene */
  56936. name: string, scene: Scene);
  56937. /**
  56938. * Get the effect name of the layer.
  56939. * @return The effect name
  56940. */
  56941. abstract getEffectName(): string;
  56942. /**
  56943. * Checks for the readiness of the element composing the layer.
  56944. * @param subMesh the mesh to check for
  56945. * @param useInstances specify whether or not to use instances to render the mesh
  56946. * @return true if ready otherwise, false
  56947. */
  56948. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56949. /**
  56950. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56951. * @returns true if the effect requires stencil during the main canvas render pass.
  56952. */
  56953. abstract needStencil(): boolean;
  56954. /**
  56955. * Create the merge effect. This is the shader use to blit the information back
  56956. * to the main canvas at the end of the scene rendering.
  56957. * @returns The effect containing the shader used to merge the effect on the main canvas
  56958. */
  56959. protected abstract _createMergeEffect(): Effect;
  56960. /**
  56961. * Creates the render target textures and post processes used in the effect layer.
  56962. */
  56963. protected abstract _createTextureAndPostProcesses(): void;
  56964. /**
  56965. * Implementation specific of rendering the generating effect on the main canvas.
  56966. * @param effect The effect used to render through
  56967. */
  56968. protected abstract _internalRender(effect: Effect): void;
  56969. /**
  56970. * Sets the required values for both the emissive texture and and the main color.
  56971. */
  56972. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56973. /**
  56974. * Free any resources and references associated to a mesh.
  56975. * Internal use
  56976. * @param mesh The mesh to free.
  56977. */
  56978. abstract _disposeMesh(mesh: Mesh): void;
  56979. /**
  56980. * Serializes this layer (Glow or Highlight for example)
  56981. * @returns a serialized layer object
  56982. */
  56983. abstract serialize?(): any;
  56984. /**
  56985. * Initializes the effect layer with the required options.
  56986. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56987. */
  56988. protected _init(options: Partial<IEffectLayerOptions>): void;
  56989. /**
  56990. * Generates the index buffer of the full screen quad blending to the main canvas.
  56991. */
  56992. private _generateIndexBuffer;
  56993. /**
  56994. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56995. */
  56996. private _generateVertexBuffer;
  56997. /**
  56998. * Sets the main texture desired size which is the closest power of two
  56999. * of the engine canvas size.
  57000. */
  57001. private _setMainTextureSize;
  57002. /**
  57003. * Creates the main texture for the effect layer.
  57004. */
  57005. protected _createMainTexture(): void;
  57006. /**
  57007. * Adds specific effects defines.
  57008. * @param defines The defines to add specifics to.
  57009. */
  57010. protected _addCustomEffectDefines(defines: string[]): void;
  57011. /**
  57012. * Checks for the readiness of the element composing the layer.
  57013. * @param subMesh the mesh to check for
  57014. * @param useInstances specify whether or not to use instances to render the mesh
  57015. * @param emissiveTexture the associated emissive texture used to generate the glow
  57016. * @return true if ready otherwise, false
  57017. */
  57018. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57019. /**
  57020. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57021. */
  57022. render(): void;
  57023. /**
  57024. * Determine if a given mesh will be used in the current effect.
  57025. * @param mesh mesh to test
  57026. * @returns true if the mesh will be used
  57027. */
  57028. hasMesh(mesh: AbstractMesh): boolean;
  57029. /**
  57030. * Returns true if the layer contains information to display, otherwise false.
  57031. * @returns true if the glow layer should be rendered
  57032. */
  57033. shouldRender(): boolean;
  57034. /**
  57035. * Returns true if the mesh should render, otherwise false.
  57036. * @param mesh The mesh to render
  57037. * @returns true if it should render otherwise false
  57038. */
  57039. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57040. /**
  57041. * Returns true if the mesh can be rendered, otherwise false.
  57042. * @param mesh The mesh to render
  57043. * @param material The material used on the mesh
  57044. * @returns true if it can be rendered otherwise false
  57045. */
  57046. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57047. /**
  57048. * Returns true if the mesh should render, otherwise false.
  57049. * @param mesh The mesh to render
  57050. * @returns true if it should render otherwise false
  57051. */
  57052. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57053. /**
  57054. * Renders the submesh passed in parameter to the generation map.
  57055. */
  57056. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57057. /**
  57058. * Defines whether the current material of the mesh should be use to render the effect.
  57059. * @param mesh defines the current mesh to render
  57060. */
  57061. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57062. /**
  57063. * Rebuild the required buffers.
  57064. * @hidden Internal use only.
  57065. */
  57066. _rebuild(): void;
  57067. /**
  57068. * Dispose only the render target textures and post process.
  57069. */
  57070. private _disposeTextureAndPostProcesses;
  57071. /**
  57072. * Dispose the highlight layer and free resources.
  57073. */
  57074. dispose(): void;
  57075. /**
  57076. * Gets the class name of the effect layer
  57077. * @returns the string with the class name of the effect layer
  57078. */
  57079. getClassName(): string;
  57080. /**
  57081. * Creates an effect layer from parsed effect layer data
  57082. * @param parsedEffectLayer defines effect layer data
  57083. * @param scene defines the current scene
  57084. * @param rootUrl defines the root URL containing the effect layer information
  57085. * @returns a parsed effect Layer
  57086. */
  57087. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57088. }
  57089. }
  57090. declare module BABYLON {
  57091. interface AbstractScene {
  57092. /**
  57093. * The list of effect layers (highlights/glow) added to the scene
  57094. * @see http://doc.babylonjs.com/how_to/highlight_layer
  57095. * @see http://doc.babylonjs.com/how_to/glow_layer
  57096. */
  57097. effectLayers: Array<EffectLayer>;
  57098. /**
  57099. * Removes the given effect layer from this scene.
  57100. * @param toRemove defines the effect layer to remove
  57101. * @returns the index of the removed effect layer
  57102. */
  57103. removeEffectLayer(toRemove: EffectLayer): number;
  57104. /**
  57105. * Adds the given effect layer to this scene
  57106. * @param newEffectLayer defines the effect layer to add
  57107. */
  57108. addEffectLayer(newEffectLayer: EffectLayer): void;
  57109. }
  57110. /**
  57111. * Defines the layer scene component responsible to manage any effect layers
  57112. * in a given scene.
  57113. */
  57114. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57115. /**
  57116. * The component name helpfull to identify the component in the list of scene components.
  57117. */
  57118. readonly name: string;
  57119. /**
  57120. * The scene the component belongs to.
  57121. */
  57122. scene: Scene;
  57123. private _engine;
  57124. private _renderEffects;
  57125. private _needStencil;
  57126. private _previousStencilState;
  57127. /**
  57128. * Creates a new instance of the component for the given scene
  57129. * @param scene Defines the scene to register the component in
  57130. */
  57131. constructor(scene: Scene);
  57132. /**
  57133. * Registers the component in a given scene
  57134. */
  57135. register(): void;
  57136. /**
  57137. * Rebuilds the elements related to this component in case of
  57138. * context lost for instance.
  57139. */
  57140. rebuild(): void;
  57141. /**
  57142. * Serializes the component data to the specified json object
  57143. * @param serializationObject The object to serialize to
  57144. */
  57145. serialize(serializationObject: any): void;
  57146. /**
  57147. * Adds all the elements from the container to the scene
  57148. * @param container the container holding the elements
  57149. */
  57150. addFromContainer(container: AbstractScene): void;
  57151. /**
  57152. * Removes all the elements in the container from the scene
  57153. * @param container contains the elements to remove
  57154. * @param dispose if the removed element should be disposed (default: false)
  57155. */
  57156. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57157. /**
  57158. * Disposes the component and the associated ressources.
  57159. */
  57160. dispose(): void;
  57161. private _isReadyForMesh;
  57162. private _renderMainTexture;
  57163. private _setStencil;
  57164. private _setStencilBack;
  57165. private _draw;
  57166. private _drawCamera;
  57167. private _drawRenderingGroup;
  57168. }
  57169. }
  57170. declare module BABYLON {
  57171. /** @hidden */
  57172. export var glowMapMergePixelShader: {
  57173. name: string;
  57174. shader: string;
  57175. };
  57176. }
  57177. declare module BABYLON {
  57178. /** @hidden */
  57179. export var glowMapMergeVertexShader: {
  57180. name: string;
  57181. shader: string;
  57182. };
  57183. }
  57184. declare module BABYLON {
  57185. interface AbstractScene {
  57186. /**
  57187. * Return a the first highlight layer of the scene with a given name.
  57188. * @param name The name of the highlight layer to look for.
  57189. * @return The highlight layer if found otherwise null.
  57190. */
  57191. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57192. }
  57193. /**
  57194. * Glow layer options. This helps customizing the behaviour
  57195. * of the glow layer.
  57196. */
  57197. export interface IGlowLayerOptions {
  57198. /**
  57199. * Multiplication factor apply to the canvas size to compute the render target size
  57200. * used to generated the glowing objects (the smaller the faster).
  57201. */
  57202. mainTextureRatio: number;
  57203. /**
  57204. * Enforces a fixed size texture to ensure resize independant blur.
  57205. */
  57206. mainTextureFixedSize?: number;
  57207. /**
  57208. * How big is the kernel of the blur texture.
  57209. */
  57210. blurKernelSize: number;
  57211. /**
  57212. * The camera attached to the layer.
  57213. */
  57214. camera: Nullable<Camera>;
  57215. /**
  57216. * Enable MSAA by chosing the number of samples.
  57217. */
  57218. mainTextureSamples?: number;
  57219. /**
  57220. * The rendering group to draw the layer in.
  57221. */
  57222. renderingGroupId: number;
  57223. }
  57224. /**
  57225. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57226. *
  57227. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57228. *
  57229. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57230. */
  57231. export class GlowLayer extends EffectLayer {
  57232. /**
  57233. * Effect Name of the layer.
  57234. */
  57235. static readonly EffectName: string;
  57236. /**
  57237. * The default blur kernel size used for the glow.
  57238. */
  57239. static DefaultBlurKernelSize: number;
  57240. /**
  57241. * The default texture size ratio used for the glow.
  57242. */
  57243. static DefaultTextureRatio: number;
  57244. /**
  57245. * Sets the kernel size of the blur.
  57246. */
  57247. set blurKernelSize(value: number);
  57248. /**
  57249. * Gets the kernel size of the blur.
  57250. */
  57251. get blurKernelSize(): number;
  57252. /**
  57253. * Sets the glow intensity.
  57254. */
  57255. set intensity(value: number);
  57256. /**
  57257. * Gets the glow intensity.
  57258. */
  57259. get intensity(): number;
  57260. private _options;
  57261. private _intensity;
  57262. private _horizontalBlurPostprocess1;
  57263. private _verticalBlurPostprocess1;
  57264. private _horizontalBlurPostprocess2;
  57265. private _verticalBlurPostprocess2;
  57266. private _blurTexture1;
  57267. private _blurTexture2;
  57268. private _postProcesses1;
  57269. private _postProcesses2;
  57270. private _includedOnlyMeshes;
  57271. private _excludedMeshes;
  57272. private _meshesUsingTheirOwnMaterials;
  57273. /**
  57274. * Callback used to let the user override the color selection on a per mesh basis
  57275. */
  57276. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57277. /**
  57278. * Callback used to let the user override the texture selection on a per mesh basis
  57279. */
  57280. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57281. /**
  57282. * Instantiates a new glow Layer and references it to the scene.
  57283. * @param name The name of the layer
  57284. * @param scene The scene to use the layer in
  57285. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57286. */
  57287. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57288. /**
  57289. * Get the effect name of the layer.
  57290. * @return The effect name
  57291. */
  57292. getEffectName(): string;
  57293. /**
  57294. * Create the merge effect. This is the shader use to blit the information back
  57295. * to the main canvas at the end of the scene rendering.
  57296. */
  57297. protected _createMergeEffect(): Effect;
  57298. /**
  57299. * Creates the render target textures and post processes used in the glow layer.
  57300. */
  57301. protected _createTextureAndPostProcesses(): void;
  57302. /**
  57303. * Checks for the readiness of the element composing the layer.
  57304. * @param subMesh the mesh to check for
  57305. * @param useInstances specify wether or not to use instances to render the mesh
  57306. * @param emissiveTexture the associated emissive texture used to generate the glow
  57307. * @return true if ready otherwise, false
  57308. */
  57309. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57310. /**
  57311. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57312. */
  57313. needStencil(): boolean;
  57314. /**
  57315. * Returns true if the mesh can be rendered, otherwise false.
  57316. * @param mesh The mesh to render
  57317. * @param material The material used on the mesh
  57318. * @returns true if it can be rendered otherwise false
  57319. */
  57320. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57321. /**
  57322. * Implementation specific of rendering the generating effect on the main canvas.
  57323. * @param effect The effect used to render through
  57324. */
  57325. protected _internalRender(effect: Effect): void;
  57326. /**
  57327. * Sets the required values for both the emissive texture and and the main color.
  57328. */
  57329. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57330. /**
  57331. * Returns true if the mesh should render, otherwise false.
  57332. * @param mesh The mesh to render
  57333. * @returns true if it should render otherwise false
  57334. */
  57335. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57336. /**
  57337. * Adds specific effects defines.
  57338. * @param defines The defines to add specifics to.
  57339. */
  57340. protected _addCustomEffectDefines(defines: string[]): void;
  57341. /**
  57342. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57343. * @param mesh The mesh to exclude from the glow layer
  57344. */
  57345. addExcludedMesh(mesh: Mesh): void;
  57346. /**
  57347. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57348. * @param mesh The mesh to remove
  57349. */
  57350. removeExcludedMesh(mesh: Mesh): void;
  57351. /**
  57352. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57353. * @param mesh The mesh to include in the glow layer
  57354. */
  57355. addIncludedOnlyMesh(mesh: Mesh): void;
  57356. /**
  57357. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57358. * @param mesh The mesh to remove
  57359. */
  57360. removeIncludedOnlyMesh(mesh: Mesh): void;
  57361. /**
  57362. * Determine if a given mesh will be used in the glow layer
  57363. * @param mesh The mesh to test
  57364. * @returns true if the mesh will be highlighted by the current glow layer
  57365. */
  57366. hasMesh(mesh: AbstractMesh): boolean;
  57367. /**
  57368. * Defines whether the current material of the mesh should be use to render the effect.
  57369. * @param mesh defines the current mesh to render
  57370. */
  57371. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57372. /**
  57373. * Add a mesh to be rendered through its own material and not with emissive only.
  57374. * @param mesh The mesh for which we need to use its material
  57375. */
  57376. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57377. /**
  57378. * Remove a mesh from being rendered through its own material and not with emissive only.
  57379. * @param mesh The mesh for which we need to not use its material
  57380. */
  57381. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57382. /**
  57383. * Free any resources and references associated to a mesh.
  57384. * Internal use
  57385. * @param mesh The mesh to free.
  57386. * @hidden
  57387. */
  57388. _disposeMesh(mesh: Mesh): void;
  57389. /**
  57390. * Gets the class name of the effect layer
  57391. * @returns the string with the class name of the effect layer
  57392. */
  57393. getClassName(): string;
  57394. /**
  57395. * Serializes this glow layer
  57396. * @returns a serialized glow layer object
  57397. */
  57398. serialize(): any;
  57399. /**
  57400. * Creates a Glow Layer from parsed glow layer data
  57401. * @param parsedGlowLayer defines glow layer data
  57402. * @param scene defines the current scene
  57403. * @param rootUrl defines the root URL containing the glow layer information
  57404. * @returns a parsed Glow Layer
  57405. */
  57406. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57407. }
  57408. }
  57409. declare module BABYLON {
  57410. /** @hidden */
  57411. export var glowBlurPostProcessPixelShader: {
  57412. name: string;
  57413. shader: string;
  57414. };
  57415. }
  57416. declare module BABYLON {
  57417. interface AbstractScene {
  57418. /**
  57419. * Return a the first highlight layer of the scene with a given name.
  57420. * @param name The name of the highlight layer to look for.
  57421. * @return The highlight layer if found otherwise null.
  57422. */
  57423. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57424. }
  57425. /**
  57426. * Highlight layer options. This helps customizing the behaviour
  57427. * of the highlight layer.
  57428. */
  57429. export interface IHighlightLayerOptions {
  57430. /**
  57431. * Multiplication factor apply to the canvas size to compute the render target size
  57432. * used to generated the glowing objects (the smaller the faster).
  57433. */
  57434. mainTextureRatio: number;
  57435. /**
  57436. * Enforces a fixed size texture to ensure resize independant blur.
  57437. */
  57438. mainTextureFixedSize?: number;
  57439. /**
  57440. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57441. * of the picture to blur (the smaller the faster).
  57442. */
  57443. blurTextureSizeRatio: number;
  57444. /**
  57445. * How big in texel of the blur texture is the vertical blur.
  57446. */
  57447. blurVerticalSize: number;
  57448. /**
  57449. * How big in texel of the blur texture is the horizontal blur.
  57450. */
  57451. blurHorizontalSize: number;
  57452. /**
  57453. * Alpha blending mode used to apply the blur. Default is combine.
  57454. */
  57455. alphaBlendingMode: number;
  57456. /**
  57457. * The camera attached to the layer.
  57458. */
  57459. camera: Nullable<Camera>;
  57460. /**
  57461. * Should we display highlight as a solid stroke?
  57462. */
  57463. isStroke?: boolean;
  57464. /**
  57465. * The rendering group to draw the layer in.
  57466. */
  57467. renderingGroupId: number;
  57468. }
  57469. /**
  57470. * The highlight layer Helps adding a glow effect around a mesh.
  57471. *
  57472. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57473. * glowy meshes to your scene.
  57474. *
  57475. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57476. */
  57477. export class HighlightLayer extends EffectLayer {
  57478. name: string;
  57479. /**
  57480. * Effect Name of the highlight layer.
  57481. */
  57482. static readonly EffectName: string;
  57483. /**
  57484. * The neutral color used during the preparation of the glow effect.
  57485. * This is black by default as the blend operation is a blend operation.
  57486. */
  57487. static NeutralColor: Color4;
  57488. /**
  57489. * Stencil value used for glowing meshes.
  57490. */
  57491. static GlowingMeshStencilReference: number;
  57492. /**
  57493. * Stencil value used for the other meshes in the scene.
  57494. */
  57495. static NormalMeshStencilReference: number;
  57496. /**
  57497. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57498. */
  57499. innerGlow: boolean;
  57500. /**
  57501. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57502. */
  57503. outerGlow: boolean;
  57504. /**
  57505. * Specifies the horizontal size of the blur.
  57506. */
  57507. set blurHorizontalSize(value: number);
  57508. /**
  57509. * Specifies the vertical size of the blur.
  57510. */
  57511. set blurVerticalSize(value: number);
  57512. /**
  57513. * Gets the horizontal size of the blur.
  57514. */
  57515. get blurHorizontalSize(): number;
  57516. /**
  57517. * Gets the vertical size of the blur.
  57518. */
  57519. get blurVerticalSize(): number;
  57520. /**
  57521. * An event triggered when the highlight layer is being blurred.
  57522. */
  57523. onBeforeBlurObservable: Observable<HighlightLayer>;
  57524. /**
  57525. * An event triggered when the highlight layer has been blurred.
  57526. */
  57527. onAfterBlurObservable: Observable<HighlightLayer>;
  57528. private _instanceGlowingMeshStencilReference;
  57529. private _options;
  57530. private _downSamplePostprocess;
  57531. private _horizontalBlurPostprocess;
  57532. private _verticalBlurPostprocess;
  57533. private _blurTexture;
  57534. private _meshes;
  57535. private _excludedMeshes;
  57536. /**
  57537. * Instantiates a new highlight Layer and references it to the scene..
  57538. * @param name The name of the layer
  57539. * @param scene The scene to use the layer in
  57540. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57541. */
  57542. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57543. /**
  57544. * Get the effect name of the layer.
  57545. * @return The effect name
  57546. */
  57547. getEffectName(): string;
  57548. /**
  57549. * Create the merge effect. This is the shader use to blit the information back
  57550. * to the main canvas at the end of the scene rendering.
  57551. */
  57552. protected _createMergeEffect(): Effect;
  57553. /**
  57554. * Creates the render target textures and post processes used in the highlight layer.
  57555. */
  57556. protected _createTextureAndPostProcesses(): void;
  57557. /**
  57558. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57559. */
  57560. needStencil(): boolean;
  57561. /**
  57562. * Checks for the readiness of the element composing the layer.
  57563. * @param subMesh the mesh to check for
  57564. * @param useInstances specify wether or not to use instances to render the mesh
  57565. * @param emissiveTexture the associated emissive texture used to generate the glow
  57566. * @return true if ready otherwise, false
  57567. */
  57568. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57569. /**
  57570. * Implementation specific of rendering the generating effect on the main canvas.
  57571. * @param effect The effect used to render through
  57572. */
  57573. protected _internalRender(effect: Effect): void;
  57574. /**
  57575. * Returns true if the layer contains information to display, otherwise false.
  57576. */
  57577. shouldRender(): boolean;
  57578. /**
  57579. * Returns true if the mesh should render, otherwise false.
  57580. * @param mesh The mesh to render
  57581. * @returns true if it should render otherwise false
  57582. */
  57583. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57584. /**
  57585. * Adds specific effects defines.
  57586. * @param defines The defines to add specifics to.
  57587. */
  57588. protected _addCustomEffectDefines(defines: string[]): void;
  57589. /**
  57590. * Sets the required values for both the emissive texture and and the main color.
  57591. */
  57592. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57593. /**
  57594. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57595. * @param mesh The mesh to exclude from the highlight layer
  57596. */
  57597. addExcludedMesh(mesh: Mesh): void;
  57598. /**
  57599. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57600. * @param mesh The mesh to highlight
  57601. */
  57602. removeExcludedMesh(mesh: Mesh): void;
  57603. /**
  57604. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57605. * @param mesh mesh to test
  57606. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57607. */
  57608. hasMesh(mesh: AbstractMesh): boolean;
  57609. /**
  57610. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57611. * @param mesh The mesh to highlight
  57612. * @param color The color of the highlight
  57613. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57614. */
  57615. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57616. /**
  57617. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57618. * @param mesh The mesh to highlight
  57619. */
  57620. removeMesh(mesh: Mesh): void;
  57621. /**
  57622. * Remove all the meshes currently referenced in the highlight layer
  57623. */
  57624. removeAllMeshes(): void;
  57625. /**
  57626. * Force the stencil to the normal expected value for none glowing parts
  57627. */
  57628. private _defaultStencilReference;
  57629. /**
  57630. * Free any resources and references associated to a mesh.
  57631. * Internal use
  57632. * @param mesh The mesh to free.
  57633. * @hidden
  57634. */
  57635. _disposeMesh(mesh: Mesh): void;
  57636. /**
  57637. * Dispose the highlight layer and free resources.
  57638. */
  57639. dispose(): void;
  57640. /**
  57641. * Gets the class name of the effect layer
  57642. * @returns the string with the class name of the effect layer
  57643. */
  57644. getClassName(): string;
  57645. /**
  57646. * Serializes this Highlight layer
  57647. * @returns a serialized Highlight layer object
  57648. */
  57649. serialize(): any;
  57650. /**
  57651. * Creates a Highlight layer from parsed Highlight layer data
  57652. * @param parsedHightlightLayer defines the Highlight layer data
  57653. * @param scene defines the current scene
  57654. * @param rootUrl defines the root URL containing the Highlight layer information
  57655. * @returns a parsed Highlight layer
  57656. */
  57657. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57658. }
  57659. }
  57660. declare module BABYLON {
  57661. interface AbstractScene {
  57662. /**
  57663. * The list of layers (background and foreground) of the scene
  57664. */
  57665. layers: Array<Layer>;
  57666. }
  57667. /**
  57668. * Defines the layer scene component responsible to manage any layers
  57669. * in a given scene.
  57670. */
  57671. export class LayerSceneComponent implements ISceneComponent {
  57672. /**
  57673. * The component name helpfull to identify the component in the list of scene components.
  57674. */
  57675. readonly name: string;
  57676. /**
  57677. * The scene the component belongs to.
  57678. */
  57679. scene: Scene;
  57680. private _engine;
  57681. /**
  57682. * Creates a new instance of the component for the given scene
  57683. * @param scene Defines the scene to register the component in
  57684. */
  57685. constructor(scene: Scene);
  57686. /**
  57687. * Registers the component in a given scene
  57688. */
  57689. register(): void;
  57690. /**
  57691. * Rebuilds the elements related to this component in case of
  57692. * context lost for instance.
  57693. */
  57694. rebuild(): void;
  57695. /**
  57696. * Disposes the component and the associated ressources.
  57697. */
  57698. dispose(): void;
  57699. private _draw;
  57700. private _drawCameraPredicate;
  57701. private _drawCameraBackground;
  57702. private _drawCameraForeground;
  57703. private _drawRenderTargetPredicate;
  57704. private _drawRenderTargetBackground;
  57705. private _drawRenderTargetForeground;
  57706. /**
  57707. * Adds all the elements from the container to the scene
  57708. * @param container the container holding the elements
  57709. */
  57710. addFromContainer(container: AbstractScene): void;
  57711. /**
  57712. * Removes all the elements in the container from the scene
  57713. * @param container contains the elements to remove
  57714. * @param dispose if the removed element should be disposed (default: false)
  57715. */
  57716. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57717. }
  57718. }
  57719. declare module BABYLON {
  57720. /** @hidden */
  57721. export var layerPixelShader: {
  57722. name: string;
  57723. shader: string;
  57724. };
  57725. }
  57726. declare module BABYLON {
  57727. /** @hidden */
  57728. export var layerVertexShader: {
  57729. name: string;
  57730. shader: string;
  57731. };
  57732. }
  57733. declare module BABYLON {
  57734. /**
  57735. * This represents a full screen 2d layer.
  57736. * This can be useful to display a picture in the background of your scene for instance.
  57737. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57738. */
  57739. export class Layer {
  57740. /**
  57741. * Define the name of the layer.
  57742. */
  57743. name: string;
  57744. /**
  57745. * Define the texture the layer should display.
  57746. */
  57747. texture: Nullable<Texture>;
  57748. /**
  57749. * Is the layer in background or foreground.
  57750. */
  57751. isBackground: boolean;
  57752. /**
  57753. * Define the color of the layer (instead of texture).
  57754. */
  57755. color: Color4;
  57756. /**
  57757. * Define the scale of the layer in order to zoom in out of the texture.
  57758. */
  57759. scale: Vector2;
  57760. /**
  57761. * Define an offset for the layer in order to shift the texture.
  57762. */
  57763. offset: Vector2;
  57764. /**
  57765. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57766. */
  57767. alphaBlendingMode: number;
  57768. /**
  57769. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57770. * Alpha test will not mix with the background color in case of transparency.
  57771. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57772. */
  57773. alphaTest: boolean;
  57774. /**
  57775. * Define a mask to restrict the layer to only some of the scene cameras.
  57776. */
  57777. layerMask: number;
  57778. /**
  57779. * Define the list of render target the layer is visible into.
  57780. */
  57781. renderTargetTextures: RenderTargetTexture[];
  57782. /**
  57783. * Define if the layer is only used in renderTarget or if it also
  57784. * renders in the main frame buffer of the canvas.
  57785. */
  57786. renderOnlyInRenderTargetTextures: boolean;
  57787. private _scene;
  57788. private _vertexBuffers;
  57789. private _indexBuffer;
  57790. private _effect;
  57791. private _previousDefines;
  57792. /**
  57793. * An event triggered when the layer is disposed.
  57794. */
  57795. onDisposeObservable: Observable<Layer>;
  57796. private _onDisposeObserver;
  57797. /**
  57798. * Back compatibility with callback before the onDisposeObservable existed.
  57799. * The set callback will be triggered when the layer has been disposed.
  57800. */
  57801. set onDispose(callback: () => void);
  57802. /**
  57803. * An event triggered before rendering the scene
  57804. */
  57805. onBeforeRenderObservable: Observable<Layer>;
  57806. private _onBeforeRenderObserver;
  57807. /**
  57808. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57809. * The set callback will be triggered just before rendering the layer.
  57810. */
  57811. set onBeforeRender(callback: () => void);
  57812. /**
  57813. * An event triggered after rendering the scene
  57814. */
  57815. onAfterRenderObservable: Observable<Layer>;
  57816. private _onAfterRenderObserver;
  57817. /**
  57818. * Back compatibility with callback before the onAfterRenderObservable existed.
  57819. * The set callback will be triggered just after rendering the layer.
  57820. */
  57821. set onAfterRender(callback: () => void);
  57822. /**
  57823. * Instantiates a new layer.
  57824. * This represents a full screen 2d layer.
  57825. * This can be useful to display a picture in the background of your scene for instance.
  57826. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57827. * @param name Define the name of the layer in the scene
  57828. * @param imgUrl Define the url of the texture to display in the layer
  57829. * @param scene Define the scene the layer belongs to
  57830. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57831. * @param color Defines a color for the layer
  57832. */
  57833. constructor(
  57834. /**
  57835. * Define the name of the layer.
  57836. */
  57837. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57838. private _createIndexBuffer;
  57839. /** @hidden */
  57840. _rebuild(): void;
  57841. /**
  57842. * Renders the layer in the scene.
  57843. */
  57844. render(): void;
  57845. /**
  57846. * Disposes and releases the associated ressources.
  57847. */
  57848. dispose(): void;
  57849. }
  57850. }
  57851. declare module BABYLON {
  57852. /** @hidden */
  57853. export var lensFlarePixelShader: {
  57854. name: string;
  57855. shader: string;
  57856. };
  57857. }
  57858. declare module BABYLON {
  57859. /** @hidden */
  57860. export var lensFlareVertexShader: {
  57861. name: string;
  57862. shader: string;
  57863. };
  57864. }
  57865. declare module BABYLON {
  57866. /**
  57867. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57868. * It is usually composed of several `lensFlare`.
  57869. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57870. */
  57871. export class LensFlareSystem {
  57872. /**
  57873. * Define the name of the lens flare system
  57874. */
  57875. name: string;
  57876. /**
  57877. * List of lens flares used in this system.
  57878. */
  57879. lensFlares: LensFlare[];
  57880. /**
  57881. * Define a limit from the border the lens flare can be visible.
  57882. */
  57883. borderLimit: number;
  57884. /**
  57885. * Define a viewport border we do not want to see the lens flare in.
  57886. */
  57887. viewportBorder: number;
  57888. /**
  57889. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57890. */
  57891. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57892. /**
  57893. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57894. */
  57895. layerMask: number;
  57896. /**
  57897. * Define the id of the lens flare system in the scene.
  57898. * (equal to name by default)
  57899. */
  57900. id: string;
  57901. private _scene;
  57902. private _emitter;
  57903. private _vertexBuffers;
  57904. private _indexBuffer;
  57905. private _effect;
  57906. private _positionX;
  57907. private _positionY;
  57908. private _isEnabled;
  57909. /** @hidden */
  57910. static _SceneComponentInitialization: (scene: Scene) => void;
  57911. /**
  57912. * Instantiates a lens flare system.
  57913. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57914. * It is usually composed of several `lensFlare`.
  57915. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57916. * @param name Define the name of the lens flare system in the scene
  57917. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57918. * @param scene Define the scene the lens flare system belongs to
  57919. */
  57920. constructor(
  57921. /**
  57922. * Define the name of the lens flare system
  57923. */
  57924. name: string, emitter: any, scene: Scene);
  57925. /**
  57926. * Define if the lens flare system is enabled.
  57927. */
  57928. get isEnabled(): boolean;
  57929. set isEnabled(value: boolean);
  57930. /**
  57931. * Get the scene the effects belongs to.
  57932. * @returns the scene holding the lens flare system
  57933. */
  57934. getScene(): Scene;
  57935. /**
  57936. * Get the emitter of the lens flare system.
  57937. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57938. * @returns the emitter of the lens flare system
  57939. */
  57940. getEmitter(): any;
  57941. /**
  57942. * Set the emitter of the lens flare system.
  57943. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57944. * @param newEmitter Define the new emitter of the system
  57945. */
  57946. setEmitter(newEmitter: any): void;
  57947. /**
  57948. * Get the lens flare system emitter position.
  57949. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57950. * @returns the position
  57951. */
  57952. getEmitterPosition(): Vector3;
  57953. /**
  57954. * @hidden
  57955. */
  57956. computeEffectivePosition(globalViewport: Viewport): boolean;
  57957. /** @hidden */
  57958. _isVisible(): boolean;
  57959. /**
  57960. * @hidden
  57961. */
  57962. render(): boolean;
  57963. /**
  57964. * Dispose and release the lens flare with its associated resources.
  57965. */
  57966. dispose(): void;
  57967. /**
  57968. * Parse a lens flare system from a JSON repressentation
  57969. * @param parsedLensFlareSystem Define the JSON to parse
  57970. * @param scene Define the scene the parsed system should be instantiated in
  57971. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57972. * @returns the parsed system
  57973. */
  57974. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57975. /**
  57976. * Serialize the current Lens Flare System into a JSON representation.
  57977. * @returns the serialized JSON
  57978. */
  57979. serialize(): any;
  57980. }
  57981. }
  57982. declare module BABYLON {
  57983. /**
  57984. * This represents one of the lens effect in a `lensFlareSystem`.
  57985. * It controls one of the indiviual texture used in the effect.
  57986. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57987. */
  57988. export class LensFlare {
  57989. /**
  57990. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57991. */
  57992. size: number;
  57993. /**
  57994. * 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.
  57995. */
  57996. position: number;
  57997. /**
  57998. * Define the lens color.
  57999. */
  58000. color: Color3;
  58001. /**
  58002. * Define the lens texture.
  58003. */
  58004. texture: Nullable<Texture>;
  58005. /**
  58006. * Define the alpha mode to render this particular lens.
  58007. */
  58008. alphaMode: number;
  58009. private _system;
  58010. /**
  58011. * Creates a new Lens Flare.
  58012. * This represents one of the lens effect in a `lensFlareSystem`.
  58013. * It controls one of the indiviual texture used in the effect.
  58014. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58015. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58016. * @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.
  58017. * @param color Define the lens color
  58018. * @param imgUrl Define the lens texture url
  58019. * @param system Define the `lensFlareSystem` this flare is part of
  58020. * @returns The newly created Lens Flare
  58021. */
  58022. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58023. /**
  58024. * Instantiates a new Lens Flare.
  58025. * This represents one of the lens effect in a `lensFlareSystem`.
  58026. * It controls one of the indiviual texture used in the effect.
  58027. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58028. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58029. * @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.
  58030. * @param color Define the lens color
  58031. * @param imgUrl Define the lens texture url
  58032. * @param system Define the `lensFlareSystem` this flare is part of
  58033. */
  58034. constructor(
  58035. /**
  58036. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58037. */
  58038. size: number,
  58039. /**
  58040. * 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.
  58041. */
  58042. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58043. /**
  58044. * Dispose and release the lens flare with its associated resources.
  58045. */
  58046. dispose(): void;
  58047. }
  58048. }
  58049. declare module BABYLON {
  58050. interface AbstractScene {
  58051. /**
  58052. * The list of lens flare system added to the scene
  58053. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58054. */
  58055. lensFlareSystems: Array<LensFlareSystem>;
  58056. /**
  58057. * Removes the given lens flare system from this scene.
  58058. * @param toRemove The lens flare system to remove
  58059. * @returns The index of the removed lens flare system
  58060. */
  58061. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58062. /**
  58063. * Adds the given lens flare system to this scene
  58064. * @param newLensFlareSystem The lens flare system to add
  58065. */
  58066. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58067. /**
  58068. * Gets a lens flare system using its name
  58069. * @param name defines the name to look for
  58070. * @returns the lens flare system or null if not found
  58071. */
  58072. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58073. /**
  58074. * Gets a lens flare system using its id
  58075. * @param id defines the id to look for
  58076. * @returns the lens flare system or null if not found
  58077. */
  58078. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58079. }
  58080. /**
  58081. * Defines the lens flare scene component responsible to manage any lens flares
  58082. * in a given scene.
  58083. */
  58084. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58085. /**
  58086. * The component name helpfull to identify the component in the list of scene components.
  58087. */
  58088. readonly name: string;
  58089. /**
  58090. * The scene the component belongs to.
  58091. */
  58092. scene: Scene;
  58093. /**
  58094. * Creates a new instance of the component for the given scene
  58095. * @param scene Defines the scene to register the component in
  58096. */
  58097. constructor(scene: Scene);
  58098. /**
  58099. * Registers the component in a given scene
  58100. */
  58101. register(): void;
  58102. /**
  58103. * Rebuilds the elements related to this component in case of
  58104. * context lost for instance.
  58105. */
  58106. rebuild(): void;
  58107. /**
  58108. * Adds all the elements from the container to the scene
  58109. * @param container the container holding the elements
  58110. */
  58111. addFromContainer(container: AbstractScene): void;
  58112. /**
  58113. * Removes all the elements in the container from the scene
  58114. * @param container contains the elements to remove
  58115. * @param dispose if the removed element should be disposed (default: false)
  58116. */
  58117. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58118. /**
  58119. * Serializes the component data to the specified json object
  58120. * @param serializationObject The object to serialize to
  58121. */
  58122. serialize(serializationObject: any): void;
  58123. /**
  58124. * Disposes the component and the associated ressources.
  58125. */
  58126. dispose(): void;
  58127. private _draw;
  58128. }
  58129. }
  58130. declare module BABYLON {
  58131. /** @hidden */
  58132. export var depthPixelShader: {
  58133. name: string;
  58134. shader: string;
  58135. };
  58136. }
  58137. declare module BABYLON {
  58138. /** @hidden */
  58139. export var depthVertexShader: {
  58140. name: string;
  58141. shader: string;
  58142. };
  58143. }
  58144. declare module BABYLON {
  58145. /**
  58146. * This represents a depth renderer in Babylon.
  58147. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58148. */
  58149. export class DepthRenderer {
  58150. private _scene;
  58151. private _depthMap;
  58152. private _effect;
  58153. private readonly _storeNonLinearDepth;
  58154. private readonly _clearColor;
  58155. /** Get if the depth renderer is using packed depth or not */
  58156. readonly isPacked: boolean;
  58157. private _cachedDefines;
  58158. private _camera;
  58159. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58160. enabled: boolean;
  58161. /**
  58162. * Specifiess that the depth renderer will only be used within
  58163. * the camera it is created for.
  58164. * This can help forcing its rendering during the camera processing.
  58165. */
  58166. useOnlyInActiveCamera: boolean;
  58167. /** @hidden */
  58168. static _SceneComponentInitialization: (scene: Scene) => void;
  58169. /**
  58170. * Instantiates a depth renderer
  58171. * @param scene The scene the renderer belongs to
  58172. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58173. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58174. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58175. */
  58176. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58177. /**
  58178. * Creates the depth rendering effect and checks if the effect is ready.
  58179. * @param subMesh The submesh to be used to render the depth map of
  58180. * @param useInstances If multiple world instances should be used
  58181. * @returns if the depth renderer is ready to render the depth map
  58182. */
  58183. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58184. /**
  58185. * Gets the texture which the depth map will be written to.
  58186. * @returns The depth map texture
  58187. */
  58188. getDepthMap(): RenderTargetTexture;
  58189. /**
  58190. * Disposes of the depth renderer.
  58191. */
  58192. dispose(): void;
  58193. }
  58194. }
  58195. declare module BABYLON {
  58196. /** @hidden */
  58197. export var minmaxReduxPixelShader: {
  58198. name: string;
  58199. shader: string;
  58200. };
  58201. }
  58202. declare module BABYLON {
  58203. /**
  58204. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58205. * and maximum values from all values of the texture.
  58206. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58207. * The source values are read from the red channel of the texture.
  58208. */
  58209. export class MinMaxReducer {
  58210. /**
  58211. * Observable triggered when the computation has been performed
  58212. */
  58213. onAfterReductionPerformed: Observable<{
  58214. min: number;
  58215. max: number;
  58216. }>;
  58217. protected _camera: Camera;
  58218. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58219. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58220. protected _postProcessManager: PostProcessManager;
  58221. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58222. protected _forceFullscreenViewport: boolean;
  58223. /**
  58224. * Creates a min/max reducer
  58225. * @param camera The camera to use for the post processes
  58226. */
  58227. constructor(camera: Camera);
  58228. /**
  58229. * Gets the texture used to read the values from.
  58230. */
  58231. get sourceTexture(): Nullable<RenderTargetTexture>;
  58232. /**
  58233. * Sets the source texture to read the values from.
  58234. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58235. * because in such textures '1' value must not be taken into account to compute the maximum
  58236. * as this value is used to clear the texture.
  58237. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58238. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58239. * @param depthRedux Indicates if the texture is a depth texture or not
  58240. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58241. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58242. */
  58243. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58244. /**
  58245. * Defines the refresh rate of the computation.
  58246. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58247. */
  58248. get refreshRate(): number;
  58249. set refreshRate(value: number);
  58250. protected _activated: boolean;
  58251. /**
  58252. * Gets the activation status of the reducer
  58253. */
  58254. get activated(): boolean;
  58255. /**
  58256. * Activates the reduction computation.
  58257. * When activated, the observers registered in onAfterReductionPerformed are
  58258. * called after the compuation is performed
  58259. */
  58260. activate(): void;
  58261. /**
  58262. * Deactivates the reduction computation.
  58263. */
  58264. deactivate(): void;
  58265. /**
  58266. * Disposes the min/max reducer
  58267. * @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.
  58268. */
  58269. dispose(disposeAll?: boolean): void;
  58270. }
  58271. }
  58272. declare module BABYLON {
  58273. /**
  58274. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58275. */
  58276. export class DepthReducer extends MinMaxReducer {
  58277. private _depthRenderer;
  58278. private _depthRendererId;
  58279. /**
  58280. * Gets the depth renderer used for the computation.
  58281. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58282. */
  58283. get depthRenderer(): Nullable<DepthRenderer>;
  58284. /**
  58285. * Creates a depth reducer
  58286. * @param camera The camera used to render the depth texture
  58287. */
  58288. constructor(camera: Camera);
  58289. /**
  58290. * Sets the depth renderer to use to generate the depth map
  58291. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58292. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58293. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58294. */
  58295. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58296. /** @hidden */
  58297. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58298. /**
  58299. * Activates the reduction computation.
  58300. * When activated, the observers registered in onAfterReductionPerformed are
  58301. * called after the compuation is performed
  58302. */
  58303. activate(): void;
  58304. /**
  58305. * Deactivates the reduction computation.
  58306. */
  58307. deactivate(): void;
  58308. /**
  58309. * Disposes the depth reducer
  58310. * @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.
  58311. */
  58312. dispose(disposeAll?: boolean): void;
  58313. }
  58314. }
  58315. declare module BABYLON {
  58316. /**
  58317. * A CSM implementation allowing casting shadows on large scenes.
  58318. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58319. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58320. */
  58321. export class CascadedShadowGenerator extends ShadowGenerator {
  58322. private static readonly frustumCornersNDCSpace;
  58323. /**
  58324. * Name of the CSM class
  58325. */
  58326. static CLASSNAME: string;
  58327. /**
  58328. * Defines the default number of cascades used by the CSM.
  58329. */
  58330. static readonly DEFAULT_CASCADES_COUNT: number;
  58331. /**
  58332. * Defines the minimum number of cascades used by the CSM.
  58333. */
  58334. static readonly MIN_CASCADES_COUNT: number;
  58335. /**
  58336. * Defines the maximum number of cascades used by the CSM.
  58337. */
  58338. static readonly MAX_CASCADES_COUNT: number;
  58339. protected _validateFilter(filter: number): number;
  58340. /**
  58341. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58342. */
  58343. penumbraDarkness: number;
  58344. private _numCascades;
  58345. /**
  58346. * Gets or set the number of cascades used by the CSM.
  58347. */
  58348. get numCascades(): number;
  58349. set numCascades(value: number);
  58350. /**
  58351. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58352. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58353. */
  58354. stabilizeCascades: boolean;
  58355. private _freezeShadowCastersBoundingInfo;
  58356. private _freezeShadowCastersBoundingInfoObservable;
  58357. /**
  58358. * Enables or disables the shadow casters bounding info computation.
  58359. * If your shadow casters don't move, you can disable this feature.
  58360. * If it is enabled, the bounding box computation is done every frame.
  58361. */
  58362. get freezeShadowCastersBoundingInfo(): boolean;
  58363. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58364. private _scbiMin;
  58365. private _scbiMax;
  58366. protected _computeShadowCastersBoundingInfo(): void;
  58367. protected _shadowCastersBoundingInfo: BoundingInfo;
  58368. /**
  58369. * Gets or sets the shadow casters bounding info.
  58370. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58371. * so that the system won't overwrite the bounds you provide
  58372. */
  58373. get shadowCastersBoundingInfo(): BoundingInfo;
  58374. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58375. protected _breaksAreDirty: boolean;
  58376. protected _minDistance: number;
  58377. protected _maxDistance: number;
  58378. /**
  58379. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58380. *
  58381. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58382. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58383. * @param min minimal distance for the breaks (default to 0.)
  58384. * @param max maximal distance for the breaks (default to 1.)
  58385. */
  58386. setMinMaxDistance(min: number, max: number): void;
  58387. /** Gets the minimal distance used in the cascade break computation */
  58388. get minDistance(): number;
  58389. /** Gets the maximal distance used in the cascade break computation */
  58390. get maxDistance(): number;
  58391. /**
  58392. * Gets the class name of that object
  58393. * @returns "CascadedShadowGenerator"
  58394. */
  58395. getClassName(): string;
  58396. private _cascadeMinExtents;
  58397. private _cascadeMaxExtents;
  58398. /**
  58399. * Gets a cascade minimum extents
  58400. * @param cascadeIndex index of the cascade
  58401. * @returns the minimum cascade extents
  58402. */
  58403. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58404. /**
  58405. * Gets a cascade maximum extents
  58406. * @param cascadeIndex index of the cascade
  58407. * @returns the maximum cascade extents
  58408. */
  58409. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58410. private _cascades;
  58411. private _currentLayer;
  58412. private _viewSpaceFrustumsZ;
  58413. private _viewMatrices;
  58414. private _projectionMatrices;
  58415. private _transformMatrices;
  58416. private _transformMatricesAsArray;
  58417. private _frustumLengths;
  58418. private _lightSizeUVCorrection;
  58419. private _depthCorrection;
  58420. private _frustumCornersWorldSpace;
  58421. private _frustumCenter;
  58422. private _shadowCameraPos;
  58423. private _shadowMaxZ;
  58424. /**
  58425. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58426. * It defaults to camera.maxZ
  58427. */
  58428. get shadowMaxZ(): number;
  58429. /**
  58430. * Sets the shadow max z distance.
  58431. */
  58432. set shadowMaxZ(value: number);
  58433. protected _debug: boolean;
  58434. /**
  58435. * Gets or sets the debug flag.
  58436. * When enabled, the cascades are materialized by different colors on the screen.
  58437. */
  58438. get debug(): boolean;
  58439. set debug(dbg: boolean);
  58440. private _depthClamp;
  58441. /**
  58442. * Gets or sets the depth clamping value.
  58443. *
  58444. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58445. * to account for the shadow casters far away.
  58446. *
  58447. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58448. */
  58449. get depthClamp(): boolean;
  58450. set depthClamp(value: boolean);
  58451. private _cascadeBlendPercentage;
  58452. /**
  58453. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58454. * It defaults to 0.1 (10% blending).
  58455. */
  58456. get cascadeBlendPercentage(): number;
  58457. set cascadeBlendPercentage(value: number);
  58458. private _lambda;
  58459. /**
  58460. * Gets or set the lambda parameter.
  58461. * This parameter is used to split the camera frustum and create the cascades.
  58462. * 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.
  58463. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58464. */
  58465. get lambda(): number;
  58466. set lambda(value: number);
  58467. /**
  58468. * Gets the view matrix corresponding to a given cascade
  58469. * @param cascadeNum cascade to retrieve the view matrix from
  58470. * @returns the cascade view matrix
  58471. */
  58472. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58473. /**
  58474. * Gets the projection matrix corresponding to a given cascade
  58475. * @param cascadeNum cascade to retrieve the projection matrix from
  58476. * @returns the cascade projection matrix
  58477. */
  58478. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58479. /**
  58480. * Gets the transformation matrix corresponding to a given cascade
  58481. * @param cascadeNum cascade to retrieve the transformation matrix from
  58482. * @returns the cascade transformation matrix
  58483. */
  58484. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58485. private _depthRenderer;
  58486. /**
  58487. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58488. *
  58489. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58490. *
  58491. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58492. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58493. * @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
  58494. */
  58495. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58496. private _depthReducer;
  58497. private _autoCalcDepthBounds;
  58498. /**
  58499. * Gets or sets the autoCalcDepthBounds property.
  58500. *
  58501. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58502. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58503. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58504. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58505. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58506. */
  58507. get autoCalcDepthBounds(): boolean;
  58508. set autoCalcDepthBounds(value: boolean);
  58509. /**
  58510. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58511. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58512. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58513. * for setting the refresh rate on the renderer yourself!
  58514. */
  58515. get autoCalcDepthBoundsRefreshRate(): number;
  58516. set autoCalcDepthBoundsRefreshRate(value: number);
  58517. /**
  58518. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58519. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58520. * you change the camera near/far planes!
  58521. */
  58522. splitFrustum(): void;
  58523. private _splitFrustum;
  58524. private _computeMatrices;
  58525. private _computeFrustumInWorldSpace;
  58526. private _computeCascadeFrustum;
  58527. /**
  58528. * Support test.
  58529. */
  58530. static get IsSupported(): boolean;
  58531. /** @hidden */
  58532. static _SceneComponentInitialization: (scene: Scene) => void;
  58533. /**
  58534. * Creates a Cascaded Shadow Generator object.
  58535. * A ShadowGenerator is the required tool to use the shadows.
  58536. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58537. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58538. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58539. * @param light The directional light object generating the shadows.
  58540. * @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.
  58541. */
  58542. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58543. protected _initializeGenerator(): void;
  58544. protected _createTargetRenderTexture(): void;
  58545. protected _initializeShadowMap(): void;
  58546. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58547. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58548. /**
  58549. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58550. * @param defines Defines of the material we want to update
  58551. * @param lightIndex Index of the light in the enabled light list of the material
  58552. */
  58553. prepareDefines(defines: any, lightIndex: number): void;
  58554. /**
  58555. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58556. * defined in the generator but impacting the effect).
  58557. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58558. * @param effect The effect we are binfing the information for
  58559. */
  58560. bindShadowLight(lightIndex: string, effect: Effect): void;
  58561. /**
  58562. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58563. * (eq to view projection * shadow projection matrices)
  58564. * @returns The transform matrix used to create the shadow map
  58565. */
  58566. getTransformMatrix(): Matrix;
  58567. /**
  58568. * Disposes the ShadowGenerator.
  58569. * Returns nothing.
  58570. */
  58571. dispose(): void;
  58572. /**
  58573. * Serializes the shadow generator setup to a json object.
  58574. * @returns The serialized JSON object
  58575. */
  58576. serialize(): any;
  58577. /**
  58578. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58579. * @param parsedShadowGenerator The JSON object to parse
  58580. * @param scene The scene to create the shadow map for
  58581. * @returns The parsed shadow generator
  58582. */
  58583. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58584. }
  58585. }
  58586. declare module BABYLON {
  58587. /**
  58588. * Defines the shadow generator component responsible to manage any shadow generators
  58589. * in a given scene.
  58590. */
  58591. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58592. /**
  58593. * The component name helpfull to identify the component in the list of scene components.
  58594. */
  58595. readonly name: string;
  58596. /**
  58597. * The scene the component belongs to.
  58598. */
  58599. scene: Scene;
  58600. /**
  58601. * Creates a new instance of the component for the given scene
  58602. * @param scene Defines the scene to register the component in
  58603. */
  58604. constructor(scene: Scene);
  58605. /**
  58606. * Registers the component in a given scene
  58607. */
  58608. register(): void;
  58609. /**
  58610. * Rebuilds the elements related to this component in case of
  58611. * context lost for instance.
  58612. */
  58613. rebuild(): void;
  58614. /**
  58615. * Serializes the component data to the specified json object
  58616. * @param serializationObject The object to serialize to
  58617. */
  58618. serialize(serializationObject: any): void;
  58619. /**
  58620. * Adds all the elements from the container to the scene
  58621. * @param container the container holding the elements
  58622. */
  58623. addFromContainer(container: AbstractScene): void;
  58624. /**
  58625. * Removes all the elements in the container from the scene
  58626. * @param container contains the elements to remove
  58627. * @param dispose if the removed element should be disposed (default: false)
  58628. */
  58629. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58630. /**
  58631. * Rebuilds the elements related to this component in case of
  58632. * context lost for instance.
  58633. */
  58634. dispose(): void;
  58635. private _gatherRenderTargets;
  58636. }
  58637. }
  58638. declare module BABYLON {
  58639. /**
  58640. * A point light is a light defined by an unique point in world space.
  58641. * The light is emitted in every direction from this point.
  58642. * A good example of a point light is a standard light bulb.
  58643. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58644. */
  58645. export class PointLight extends ShadowLight {
  58646. private _shadowAngle;
  58647. /**
  58648. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58649. * This specifies what angle the shadow will use to be created.
  58650. *
  58651. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58652. */
  58653. get shadowAngle(): number;
  58654. /**
  58655. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58656. * This specifies what angle the shadow will use to be created.
  58657. *
  58658. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58659. */
  58660. set shadowAngle(value: number);
  58661. /**
  58662. * Gets the direction if it has been set.
  58663. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58664. */
  58665. get direction(): Vector3;
  58666. /**
  58667. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58668. */
  58669. set direction(value: Vector3);
  58670. /**
  58671. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58672. * A PointLight emits the light in every direction.
  58673. * It can cast shadows.
  58674. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58675. * ```javascript
  58676. * var pointLight = new PointLight("pl", camera.position, scene);
  58677. * ```
  58678. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58679. * @param name The light friendly name
  58680. * @param position The position of the point light in the scene
  58681. * @param scene The scene the lights belongs to
  58682. */
  58683. constructor(name: string, position: Vector3, scene: Scene);
  58684. /**
  58685. * Returns the string "PointLight"
  58686. * @returns the class name
  58687. */
  58688. getClassName(): string;
  58689. /**
  58690. * Returns the integer 0.
  58691. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58692. */
  58693. getTypeID(): number;
  58694. /**
  58695. * Specifies wether or not the shadowmap should be a cube texture.
  58696. * @returns true if the shadowmap needs to be a cube texture.
  58697. */
  58698. needCube(): boolean;
  58699. /**
  58700. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58701. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58702. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58703. */
  58704. getShadowDirection(faceIndex?: number): Vector3;
  58705. /**
  58706. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58707. * - fov = PI / 2
  58708. * - aspect ratio : 1.0
  58709. * - z-near and far equal to the active camera minZ and maxZ.
  58710. * Returns the PointLight.
  58711. */
  58712. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58713. protected _buildUniformLayout(): void;
  58714. /**
  58715. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58716. * @param effect The effect to update
  58717. * @param lightIndex The index of the light in the effect to update
  58718. * @returns The point light
  58719. */
  58720. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58721. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58722. /**
  58723. * Prepares the list of defines specific to the light type.
  58724. * @param defines the list of defines
  58725. * @param lightIndex defines the index of the light for the effect
  58726. */
  58727. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58728. }
  58729. }
  58730. declare module BABYLON {
  58731. /**
  58732. * Header information of HDR texture files.
  58733. */
  58734. export interface HDRInfo {
  58735. /**
  58736. * The height of the texture in pixels.
  58737. */
  58738. height: number;
  58739. /**
  58740. * The width of the texture in pixels.
  58741. */
  58742. width: number;
  58743. /**
  58744. * The index of the beginning of the data in the binary file.
  58745. */
  58746. dataPosition: number;
  58747. }
  58748. /**
  58749. * This groups tools to convert HDR texture to native colors array.
  58750. */
  58751. export class HDRTools {
  58752. private static Ldexp;
  58753. private static Rgbe2float;
  58754. private static readStringLine;
  58755. /**
  58756. * Reads header information from an RGBE texture stored in a native array.
  58757. * More information on this format are available here:
  58758. * https://en.wikipedia.org/wiki/RGBE_image_format
  58759. *
  58760. * @param uint8array The binary file stored in native array.
  58761. * @return The header information.
  58762. */
  58763. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58764. /**
  58765. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58766. * This RGBE texture needs to store the information as a panorama.
  58767. *
  58768. * More information on this format are available here:
  58769. * https://en.wikipedia.org/wiki/RGBE_image_format
  58770. *
  58771. * @param buffer The binary file stored in an array buffer.
  58772. * @param size The expected size of the extracted cubemap.
  58773. * @return The Cube Map information.
  58774. */
  58775. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58776. /**
  58777. * Returns the pixels data extracted from an RGBE texture.
  58778. * This pixels will be stored left to right up to down in the R G B order in one array.
  58779. *
  58780. * More information on this format are available here:
  58781. * https://en.wikipedia.org/wiki/RGBE_image_format
  58782. *
  58783. * @param uint8array The binary file stored in an array buffer.
  58784. * @param hdrInfo The header information of the file.
  58785. * @return The pixels data in RGB right to left up to down order.
  58786. */
  58787. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58788. private static RGBE_ReadPixels_RLE;
  58789. }
  58790. }
  58791. declare module BABYLON {
  58792. /**
  58793. * Effect Render Options
  58794. */
  58795. export interface IEffectRendererOptions {
  58796. /**
  58797. * Defines the vertices positions.
  58798. */
  58799. positions?: number[];
  58800. /**
  58801. * Defines the indices.
  58802. */
  58803. indices?: number[];
  58804. }
  58805. /**
  58806. * Helper class to render one or more effects.
  58807. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58808. */
  58809. export class EffectRenderer {
  58810. private engine;
  58811. private static _DefaultOptions;
  58812. private _vertexBuffers;
  58813. private _indexBuffer;
  58814. private _fullscreenViewport;
  58815. /**
  58816. * Creates an effect renderer
  58817. * @param engine the engine to use for rendering
  58818. * @param options defines the options of the effect renderer
  58819. */
  58820. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58821. /**
  58822. * Sets the current viewport in normalized coordinates 0-1
  58823. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58824. */
  58825. setViewport(viewport?: Viewport): void;
  58826. /**
  58827. * Binds the embedded attributes buffer to the effect.
  58828. * @param effect Defines the effect to bind the attributes for
  58829. */
  58830. bindBuffers(effect: Effect): void;
  58831. /**
  58832. * Sets the current effect wrapper to use during draw.
  58833. * The effect needs to be ready before calling this api.
  58834. * This also sets the default full screen position attribute.
  58835. * @param effectWrapper Defines the effect to draw with
  58836. */
  58837. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58838. /**
  58839. * Restores engine states
  58840. */
  58841. restoreStates(): void;
  58842. /**
  58843. * Draws a full screen quad.
  58844. */
  58845. draw(): void;
  58846. private isRenderTargetTexture;
  58847. /**
  58848. * renders one or more effects to a specified texture
  58849. * @param effectWrapper the effect to renderer
  58850. * @param outputTexture texture to draw to, if null it will render to the screen.
  58851. */
  58852. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58853. /**
  58854. * Disposes of the effect renderer
  58855. */
  58856. dispose(): void;
  58857. }
  58858. /**
  58859. * Options to create an EffectWrapper
  58860. */
  58861. interface EffectWrapperCreationOptions {
  58862. /**
  58863. * Engine to use to create the effect
  58864. */
  58865. engine: ThinEngine;
  58866. /**
  58867. * Fragment shader for the effect
  58868. */
  58869. fragmentShader: string;
  58870. /**
  58871. * Use the shader store instead of direct source code
  58872. */
  58873. useShaderStore?: boolean;
  58874. /**
  58875. * Vertex shader for the effect
  58876. */
  58877. vertexShader?: string;
  58878. /**
  58879. * Attributes to use in the shader
  58880. */
  58881. attributeNames?: Array<string>;
  58882. /**
  58883. * Uniforms to use in the shader
  58884. */
  58885. uniformNames?: Array<string>;
  58886. /**
  58887. * Texture sampler names to use in the shader
  58888. */
  58889. samplerNames?: Array<string>;
  58890. /**
  58891. * Defines to use in the shader
  58892. */
  58893. defines?: Array<string>;
  58894. /**
  58895. * Callback when effect is compiled
  58896. */
  58897. onCompiled?: Nullable<(effect: Effect) => void>;
  58898. /**
  58899. * The friendly name of the effect displayed in Spector.
  58900. */
  58901. name?: string;
  58902. }
  58903. /**
  58904. * Wraps an effect to be used for rendering
  58905. */
  58906. export class EffectWrapper {
  58907. /**
  58908. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58909. */
  58910. onApplyObservable: Observable<{}>;
  58911. /**
  58912. * The underlying effect
  58913. */
  58914. effect: Effect;
  58915. /**
  58916. * Creates an effect to be renderer
  58917. * @param creationOptions options to create the effect
  58918. */
  58919. constructor(creationOptions: EffectWrapperCreationOptions);
  58920. /**
  58921. * Disposes of the effect wrapper
  58922. */
  58923. dispose(): void;
  58924. }
  58925. }
  58926. declare module BABYLON {
  58927. /** @hidden */
  58928. export var hdrFilteringVertexShader: {
  58929. name: string;
  58930. shader: string;
  58931. };
  58932. }
  58933. declare module BABYLON {
  58934. /** @hidden */
  58935. export var hdrFilteringPixelShader: {
  58936. name: string;
  58937. shader: string;
  58938. };
  58939. }
  58940. declare module BABYLON {
  58941. /**
  58942. * Options for texture filtering
  58943. */
  58944. interface IHDRFilteringOptions {
  58945. /**
  58946. * Scales pixel intensity for the input HDR map.
  58947. */
  58948. hdrScale?: number;
  58949. /**
  58950. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58951. */
  58952. quality?: number;
  58953. }
  58954. /**
  58955. * Filters HDR maps to get correct renderings of PBR reflections
  58956. */
  58957. export class HDRFiltering {
  58958. private _engine;
  58959. private _effectRenderer;
  58960. private _effectWrapper;
  58961. private _lodGenerationOffset;
  58962. private _lodGenerationScale;
  58963. /**
  58964. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58965. * you care about baking speed.
  58966. */
  58967. quality: number;
  58968. /**
  58969. * Scales pixel intensity for the input HDR map.
  58970. */
  58971. hdrScale: number;
  58972. /**
  58973. * Instantiates HDR filter for reflection maps
  58974. *
  58975. * @param engine Thin engine
  58976. * @param options Options
  58977. */
  58978. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58979. private _createRenderTarget;
  58980. private _prefilterInternal;
  58981. private _createEffect;
  58982. /**
  58983. * Get a value indicating if the filter is ready to be used
  58984. * @param texture Texture to filter
  58985. * @returns true if the filter is ready
  58986. */
  58987. isReady(texture: BaseTexture): boolean;
  58988. /**
  58989. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58990. * Prefiltering will be invoked at the end of next rendering pass.
  58991. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58992. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58993. * @param texture Texture to filter
  58994. * @param onFinished Callback when filtering is done
  58995. * @return Promise called when prefiltering is done
  58996. */
  58997. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58998. }
  58999. }
  59000. declare module BABYLON {
  59001. /**
  59002. * This represents a texture coming from an HDR input.
  59003. *
  59004. * The only supported format is currently panorama picture stored in RGBE format.
  59005. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59006. */
  59007. export class HDRCubeTexture extends BaseTexture {
  59008. private static _facesMapping;
  59009. private _generateHarmonics;
  59010. private _noMipmap;
  59011. private _prefilterOnLoad;
  59012. private _textureMatrix;
  59013. private _size;
  59014. private _onLoad;
  59015. private _onError;
  59016. /**
  59017. * The texture URL.
  59018. */
  59019. url: string;
  59020. /**
  59021. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59022. */
  59023. coordinatesMode: number;
  59024. protected _isBlocking: boolean;
  59025. /**
  59026. * Sets wether or not the texture is blocking during loading.
  59027. */
  59028. set isBlocking(value: boolean);
  59029. /**
  59030. * Gets wether or not the texture is blocking during loading.
  59031. */
  59032. get isBlocking(): boolean;
  59033. protected _rotationY: number;
  59034. /**
  59035. * Sets texture matrix rotation angle around Y axis in radians.
  59036. */
  59037. set rotationY(value: number);
  59038. /**
  59039. * Gets texture matrix rotation angle around Y axis radians.
  59040. */
  59041. get rotationY(): number;
  59042. /**
  59043. * Gets or sets the center of the bounding box associated with the cube texture
  59044. * It must define where the camera used to render the texture was set
  59045. */
  59046. boundingBoxPosition: Vector3;
  59047. private _boundingBoxSize;
  59048. /**
  59049. * Gets or sets the size of the bounding box associated with the cube texture
  59050. * When defined, the cubemap will switch to local mode
  59051. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59052. * @example https://www.babylonjs-playground.com/#RNASML
  59053. */
  59054. set boundingBoxSize(value: Vector3);
  59055. get boundingBoxSize(): Vector3;
  59056. /**
  59057. * Instantiates an HDRTexture from the following parameters.
  59058. *
  59059. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59060. * @param sceneOrEngine The scene or engine the texture will be used in
  59061. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59062. * @param noMipmap Forces to not generate the mipmap if true
  59063. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59064. * @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)
  59065. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59066. */
  59067. 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>);
  59068. /**
  59069. * Get the current class name of the texture useful for serialization or dynamic coding.
  59070. * @returns "HDRCubeTexture"
  59071. */
  59072. getClassName(): string;
  59073. /**
  59074. * Occurs when the file is raw .hdr file.
  59075. */
  59076. private loadTexture;
  59077. clone(): HDRCubeTexture;
  59078. delayLoad(): void;
  59079. /**
  59080. * Get the texture reflection matrix used to rotate/transform the reflection.
  59081. * @returns the reflection matrix
  59082. */
  59083. getReflectionTextureMatrix(): Matrix;
  59084. /**
  59085. * Set the texture reflection matrix used to rotate/transform the reflection.
  59086. * @param value Define the reflection matrix to set
  59087. */
  59088. setReflectionTextureMatrix(value: Matrix): void;
  59089. /**
  59090. * Parses a JSON representation of an HDR Texture in order to create the texture
  59091. * @param parsedTexture Define the JSON representation
  59092. * @param scene Define the scene the texture should be created in
  59093. * @param rootUrl Define the root url in case we need to load relative dependencies
  59094. * @returns the newly created texture after parsing
  59095. */
  59096. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59097. serialize(): any;
  59098. }
  59099. }
  59100. declare module BABYLON {
  59101. /**
  59102. * Class used to control physics engine
  59103. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59104. */
  59105. export class PhysicsEngine implements IPhysicsEngine {
  59106. private _physicsPlugin;
  59107. /**
  59108. * Global value used to control the smallest number supported by the simulation
  59109. */
  59110. static Epsilon: number;
  59111. private _impostors;
  59112. private _joints;
  59113. private _subTimeStep;
  59114. /**
  59115. * Gets the gravity vector used by the simulation
  59116. */
  59117. gravity: Vector3;
  59118. /**
  59119. * Factory used to create the default physics plugin.
  59120. * @returns The default physics plugin
  59121. */
  59122. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59123. /**
  59124. * Creates a new Physics Engine
  59125. * @param gravity defines the gravity vector used by the simulation
  59126. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59127. */
  59128. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59129. /**
  59130. * Sets the gravity vector used by the simulation
  59131. * @param gravity defines the gravity vector to use
  59132. */
  59133. setGravity(gravity: Vector3): void;
  59134. /**
  59135. * Set the time step of the physics engine.
  59136. * Default is 1/60.
  59137. * To slow it down, enter 1/600 for example.
  59138. * To speed it up, 1/30
  59139. * @param newTimeStep defines the new timestep to apply to this world.
  59140. */
  59141. setTimeStep(newTimeStep?: number): void;
  59142. /**
  59143. * Get the time step of the physics engine.
  59144. * @returns the current time step
  59145. */
  59146. getTimeStep(): number;
  59147. /**
  59148. * Set the sub time step of the physics engine.
  59149. * Default is 0 meaning there is no sub steps
  59150. * To increase physics resolution precision, set a small value (like 1 ms)
  59151. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59152. */
  59153. setSubTimeStep(subTimeStep?: number): void;
  59154. /**
  59155. * Get the sub time step of the physics engine.
  59156. * @returns the current sub time step
  59157. */
  59158. getSubTimeStep(): number;
  59159. /**
  59160. * Release all resources
  59161. */
  59162. dispose(): void;
  59163. /**
  59164. * Gets the name of the current physics plugin
  59165. * @returns the name of the plugin
  59166. */
  59167. getPhysicsPluginName(): string;
  59168. /**
  59169. * Adding a new impostor for the impostor tracking.
  59170. * This will be done by the impostor itself.
  59171. * @param impostor the impostor to add
  59172. */
  59173. addImpostor(impostor: PhysicsImpostor): void;
  59174. /**
  59175. * Remove an impostor from the engine.
  59176. * This impostor and its mesh will not longer be updated by the physics engine.
  59177. * @param impostor the impostor to remove
  59178. */
  59179. removeImpostor(impostor: PhysicsImpostor): void;
  59180. /**
  59181. * Add a joint to the physics engine
  59182. * @param mainImpostor defines the main impostor to which the joint is added.
  59183. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59184. * @param joint defines the joint that will connect both impostors.
  59185. */
  59186. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59187. /**
  59188. * Removes a joint from the simulation
  59189. * @param mainImpostor defines the impostor used with the joint
  59190. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59191. * @param joint defines the joint to remove
  59192. */
  59193. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59194. /**
  59195. * Called by the scene. No need to call it.
  59196. * @param delta defines the timespam between frames
  59197. */
  59198. _step(delta: number): void;
  59199. /**
  59200. * Gets the current plugin used to run the simulation
  59201. * @returns current plugin
  59202. */
  59203. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59204. /**
  59205. * Gets the list of physic impostors
  59206. * @returns an array of PhysicsImpostor
  59207. */
  59208. getImpostors(): Array<PhysicsImpostor>;
  59209. /**
  59210. * Gets the impostor for a physics enabled object
  59211. * @param object defines the object impersonated by the impostor
  59212. * @returns the PhysicsImpostor or null if not found
  59213. */
  59214. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59215. /**
  59216. * Gets the impostor for a physics body object
  59217. * @param body defines physics body used by the impostor
  59218. * @returns the PhysicsImpostor or null if not found
  59219. */
  59220. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59221. /**
  59222. * Does a raycast in the physics world
  59223. * @param from when should the ray start?
  59224. * @param to when should the ray end?
  59225. * @returns PhysicsRaycastResult
  59226. */
  59227. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59228. }
  59229. }
  59230. declare module BABYLON {
  59231. /** @hidden */
  59232. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59233. private _useDeltaForWorldStep;
  59234. world: any;
  59235. name: string;
  59236. private _physicsMaterials;
  59237. private _fixedTimeStep;
  59238. private _cannonRaycastResult;
  59239. private _raycastResult;
  59240. private _physicsBodysToRemoveAfterStep;
  59241. private _firstFrame;
  59242. BJSCANNON: any;
  59243. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59244. setGravity(gravity: Vector3): void;
  59245. setTimeStep(timeStep: number): void;
  59246. getTimeStep(): number;
  59247. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59248. private _removeMarkedPhysicsBodiesFromWorld;
  59249. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59250. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59251. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59252. private _processChildMeshes;
  59253. removePhysicsBody(impostor: PhysicsImpostor): void;
  59254. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59255. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59256. private _addMaterial;
  59257. private _checkWithEpsilon;
  59258. private _createShape;
  59259. private _createHeightmap;
  59260. private _minus90X;
  59261. private _plus90X;
  59262. private _tmpPosition;
  59263. private _tmpDeltaPosition;
  59264. private _tmpUnityRotation;
  59265. private _updatePhysicsBodyTransformation;
  59266. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59267. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59268. isSupported(): boolean;
  59269. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59270. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59271. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59272. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59273. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59274. getBodyMass(impostor: PhysicsImpostor): number;
  59275. getBodyFriction(impostor: PhysicsImpostor): number;
  59276. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59277. getBodyRestitution(impostor: PhysicsImpostor): number;
  59278. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59279. sleepBody(impostor: PhysicsImpostor): void;
  59280. wakeUpBody(impostor: PhysicsImpostor): void;
  59281. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59282. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59283. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59284. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59285. getRadius(impostor: PhysicsImpostor): number;
  59286. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59287. dispose(): void;
  59288. private _extendNamespace;
  59289. /**
  59290. * Does a raycast in the physics world
  59291. * @param from when should the ray start?
  59292. * @param to when should the ray end?
  59293. * @returns PhysicsRaycastResult
  59294. */
  59295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59296. }
  59297. }
  59298. declare module BABYLON {
  59299. /** @hidden */
  59300. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59301. private _useDeltaForWorldStep;
  59302. world: any;
  59303. name: string;
  59304. BJSOIMO: any;
  59305. private _raycastResult;
  59306. private _fixedTimeStep;
  59307. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59308. setGravity(gravity: Vector3): void;
  59309. setTimeStep(timeStep: number): void;
  59310. getTimeStep(): number;
  59311. private _tmpImpostorsArray;
  59312. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59313. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59314. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59315. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59316. private _tmpPositionVector;
  59317. removePhysicsBody(impostor: PhysicsImpostor): void;
  59318. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59319. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59320. isSupported(): boolean;
  59321. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59322. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59323. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59324. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59325. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59326. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59327. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59328. getBodyMass(impostor: PhysicsImpostor): number;
  59329. getBodyFriction(impostor: PhysicsImpostor): number;
  59330. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59331. getBodyRestitution(impostor: PhysicsImpostor): number;
  59332. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59333. sleepBody(impostor: PhysicsImpostor): void;
  59334. wakeUpBody(impostor: PhysicsImpostor): void;
  59335. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59336. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59337. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59338. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59339. getRadius(impostor: PhysicsImpostor): number;
  59340. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59341. dispose(): void;
  59342. /**
  59343. * Does a raycast in the physics world
  59344. * @param from when should the ray start?
  59345. * @param to when should the ray end?
  59346. * @returns PhysicsRaycastResult
  59347. */
  59348. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59349. }
  59350. }
  59351. declare module BABYLON {
  59352. /**
  59353. * Class containing static functions to help procedurally build meshes
  59354. */
  59355. export class RibbonBuilder {
  59356. /**
  59357. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59358. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59359. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59360. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59361. * * 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
  59362. * * 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
  59363. * * 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
  59364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59365. * * 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
  59366. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59367. * * 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
  59368. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59369. * * 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
  59370. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59372. * @param name defines the name of the mesh
  59373. * @param options defines the options used to create the mesh
  59374. * @param scene defines the hosting scene
  59375. * @returns the ribbon mesh
  59376. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59377. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59378. */
  59379. static CreateRibbon(name: string, options: {
  59380. pathArray: Vector3[][];
  59381. closeArray?: boolean;
  59382. closePath?: boolean;
  59383. offset?: number;
  59384. updatable?: boolean;
  59385. sideOrientation?: number;
  59386. frontUVs?: Vector4;
  59387. backUVs?: Vector4;
  59388. instance?: Mesh;
  59389. invertUV?: boolean;
  59390. uvs?: Vector2[];
  59391. colors?: Color4[];
  59392. }, scene?: Nullable<Scene>): Mesh;
  59393. }
  59394. }
  59395. declare module BABYLON {
  59396. /**
  59397. * Class containing static functions to help procedurally build meshes
  59398. */
  59399. export class ShapeBuilder {
  59400. /**
  59401. * 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.
  59402. * * 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.
  59403. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59404. * * 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.
  59405. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59406. * * 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
  59407. * * 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
  59408. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59410. * * 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
  59411. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59413. * @param name defines the name of the mesh
  59414. * @param options defines the options used to create the mesh
  59415. * @param scene defines the hosting scene
  59416. * @returns the extruded shape mesh
  59417. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59419. */
  59420. static ExtrudeShape(name: string, options: {
  59421. shape: Vector3[];
  59422. path: Vector3[];
  59423. scale?: number;
  59424. rotation?: number;
  59425. cap?: number;
  59426. updatable?: boolean;
  59427. sideOrientation?: number;
  59428. frontUVs?: Vector4;
  59429. backUVs?: Vector4;
  59430. instance?: Mesh;
  59431. invertUV?: boolean;
  59432. }, scene?: Nullable<Scene>): Mesh;
  59433. /**
  59434. * Creates an custom extruded shape mesh.
  59435. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59436. * * 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.
  59437. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59438. * * 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
  59439. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59440. * * 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
  59441. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59442. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59443. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59444. * * 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
  59445. * * 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
  59446. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59448. * * 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
  59449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59451. * @param name defines the name of the mesh
  59452. * @param options defines the options used to create the mesh
  59453. * @param scene defines the hosting scene
  59454. * @returns the custom extruded shape mesh
  59455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59456. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59458. */
  59459. static ExtrudeShapeCustom(name: string, options: {
  59460. shape: Vector3[];
  59461. path: Vector3[];
  59462. scaleFunction?: any;
  59463. rotationFunction?: any;
  59464. ribbonCloseArray?: boolean;
  59465. ribbonClosePath?: boolean;
  59466. cap?: number;
  59467. updatable?: boolean;
  59468. sideOrientation?: number;
  59469. frontUVs?: Vector4;
  59470. backUVs?: Vector4;
  59471. instance?: Mesh;
  59472. invertUV?: boolean;
  59473. }, scene?: Nullable<Scene>): Mesh;
  59474. private static _ExtrudeShapeGeneric;
  59475. }
  59476. }
  59477. declare module BABYLON {
  59478. /**
  59479. * AmmoJS Physics plugin
  59480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59481. * @see https://github.com/kripken/ammo.js/
  59482. */
  59483. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59484. private _useDeltaForWorldStep;
  59485. /**
  59486. * Reference to the Ammo library
  59487. */
  59488. bjsAMMO: any;
  59489. /**
  59490. * Created ammoJS world which physics bodies are added to
  59491. */
  59492. world: any;
  59493. /**
  59494. * Name of the plugin
  59495. */
  59496. name: string;
  59497. private _timeStep;
  59498. private _fixedTimeStep;
  59499. private _maxSteps;
  59500. private _tmpQuaternion;
  59501. private _tmpAmmoTransform;
  59502. private _tmpAmmoQuaternion;
  59503. private _tmpAmmoConcreteContactResultCallback;
  59504. private _collisionConfiguration;
  59505. private _dispatcher;
  59506. private _overlappingPairCache;
  59507. private _solver;
  59508. private _softBodySolver;
  59509. private _tmpAmmoVectorA;
  59510. private _tmpAmmoVectorB;
  59511. private _tmpAmmoVectorC;
  59512. private _tmpAmmoVectorD;
  59513. private _tmpContactCallbackResult;
  59514. private _tmpAmmoVectorRCA;
  59515. private _tmpAmmoVectorRCB;
  59516. private _raycastResult;
  59517. private static readonly DISABLE_COLLISION_FLAG;
  59518. private static readonly KINEMATIC_FLAG;
  59519. private static readonly DISABLE_DEACTIVATION_FLAG;
  59520. /**
  59521. * Initializes the ammoJS plugin
  59522. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59523. * @param ammoInjection can be used to inject your own ammo reference
  59524. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59525. */
  59526. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59527. /**
  59528. * Sets the gravity of the physics world (m/(s^2))
  59529. * @param gravity Gravity to set
  59530. */
  59531. setGravity(gravity: Vector3): void;
  59532. /**
  59533. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59534. * @param timeStep timestep to use in seconds
  59535. */
  59536. setTimeStep(timeStep: number): void;
  59537. /**
  59538. * 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)
  59539. * @param fixedTimeStep fixedTimeStep to use in seconds
  59540. */
  59541. setFixedTimeStep(fixedTimeStep: number): void;
  59542. /**
  59543. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59544. * @param maxSteps the maximum number of steps by the physics engine per frame
  59545. */
  59546. setMaxSteps(maxSteps: number): void;
  59547. /**
  59548. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59549. * @returns the current timestep in seconds
  59550. */
  59551. getTimeStep(): number;
  59552. /**
  59553. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59554. */
  59555. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59556. private _isImpostorInContact;
  59557. private _isImpostorPairInContact;
  59558. private _stepSimulation;
  59559. /**
  59560. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59561. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59562. * After the step the babylon meshes are set to the position of the physics imposters
  59563. * @param delta amount of time to step forward
  59564. * @param impostors array of imposters to update before/after the step
  59565. */
  59566. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59567. /**
  59568. * Update babylon mesh to match physics world object
  59569. * @param impostor imposter to match
  59570. */
  59571. private _afterSoftStep;
  59572. /**
  59573. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59574. * @param impostor imposter to match
  59575. */
  59576. private _ropeStep;
  59577. /**
  59578. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59579. * @param impostor imposter to match
  59580. */
  59581. private _softbodyOrClothStep;
  59582. private _tmpMatrix;
  59583. /**
  59584. * Applies an impulse on the imposter
  59585. * @param impostor imposter to apply impulse to
  59586. * @param force amount of force to be applied to the imposter
  59587. * @param contactPoint the location to apply the impulse on the imposter
  59588. */
  59589. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59590. /**
  59591. * Applies a force on the imposter
  59592. * @param impostor imposter to apply force
  59593. * @param force amount of force to be applied to the imposter
  59594. * @param contactPoint the location to apply the force on the imposter
  59595. */
  59596. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59597. /**
  59598. * Creates a physics body using the plugin
  59599. * @param impostor the imposter to create the physics body on
  59600. */
  59601. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59602. /**
  59603. * Removes the physics body from the imposter and disposes of the body's memory
  59604. * @param impostor imposter to remove the physics body from
  59605. */
  59606. removePhysicsBody(impostor: PhysicsImpostor): void;
  59607. /**
  59608. * Generates a joint
  59609. * @param impostorJoint the imposter joint to create the joint with
  59610. */
  59611. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59612. /**
  59613. * Removes a joint
  59614. * @param impostorJoint the imposter joint to remove the joint from
  59615. */
  59616. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59617. private _addMeshVerts;
  59618. /**
  59619. * Initialise the soft body vertices to match its object's (mesh) vertices
  59620. * Softbody vertices (nodes) are in world space and to match this
  59621. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59622. * @param impostor to create the softbody for
  59623. */
  59624. private _softVertexData;
  59625. /**
  59626. * Create an impostor's soft body
  59627. * @param impostor to create the softbody for
  59628. */
  59629. private _createSoftbody;
  59630. /**
  59631. * Create cloth for an impostor
  59632. * @param impostor to create the softbody for
  59633. */
  59634. private _createCloth;
  59635. /**
  59636. * Create rope for an impostor
  59637. * @param impostor to create the softbody for
  59638. */
  59639. private _createRope;
  59640. /**
  59641. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59642. * @param impostor to create the custom physics shape for
  59643. */
  59644. private _createCustom;
  59645. private _addHullVerts;
  59646. private _createShape;
  59647. /**
  59648. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59649. * @param impostor imposter containing the physics body and babylon object
  59650. */
  59651. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59652. /**
  59653. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59654. * @param impostor imposter containing the physics body and babylon object
  59655. * @param newPosition new position
  59656. * @param newRotation new rotation
  59657. */
  59658. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59659. /**
  59660. * If this plugin is supported
  59661. * @returns true if its supported
  59662. */
  59663. isSupported(): boolean;
  59664. /**
  59665. * Sets the linear velocity of the physics body
  59666. * @param impostor imposter to set the velocity on
  59667. * @param velocity velocity to set
  59668. */
  59669. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59670. /**
  59671. * Sets the angular velocity of the physics body
  59672. * @param impostor imposter to set the velocity on
  59673. * @param velocity velocity to set
  59674. */
  59675. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59676. /**
  59677. * gets the linear velocity
  59678. * @param impostor imposter to get linear velocity from
  59679. * @returns linear velocity
  59680. */
  59681. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59682. /**
  59683. * gets the angular velocity
  59684. * @param impostor imposter to get angular velocity from
  59685. * @returns angular velocity
  59686. */
  59687. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59688. /**
  59689. * Sets the mass of physics body
  59690. * @param impostor imposter to set the mass on
  59691. * @param mass mass to set
  59692. */
  59693. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59694. /**
  59695. * Gets the mass of the physics body
  59696. * @param impostor imposter to get the mass from
  59697. * @returns mass
  59698. */
  59699. getBodyMass(impostor: PhysicsImpostor): number;
  59700. /**
  59701. * Gets friction of the impostor
  59702. * @param impostor impostor to get friction from
  59703. * @returns friction value
  59704. */
  59705. getBodyFriction(impostor: PhysicsImpostor): number;
  59706. /**
  59707. * Sets friction of the impostor
  59708. * @param impostor impostor to set friction on
  59709. * @param friction friction value
  59710. */
  59711. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59712. /**
  59713. * Gets restitution of the impostor
  59714. * @param impostor impostor to get restitution from
  59715. * @returns restitution value
  59716. */
  59717. getBodyRestitution(impostor: PhysicsImpostor): number;
  59718. /**
  59719. * Sets resitution of the impostor
  59720. * @param impostor impostor to set resitution on
  59721. * @param restitution resitution value
  59722. */
  59723. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59724. /**
  59725. * Gets pressure inside the impostor
  59726. * @param impostor impostor to get pressure from
  59727. * @returns pressure value
  59728. */
  59729. getBodyPressure(impostor: PhysicsImpostor): number;
  59730. /**
  59731. * Sets pressure inside a soft body impostor
  59732. * Cloth and rope must remain 0 pressure
  59733. * @param impostor impostor to set pressure on
  59734. * @param pressure pressure value
  59735. */
  59736. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59737. /**
  59738. * Gets stiffness of the impostor
  59739. * @param impostor impostor to get stiffness from
  59740. * @returns pressure value
  59741. */
  59742. getBodyStiffness(impostor: PhysicsImpostor): number;
  59743. /**
  59744. * Sets stiffness of the impostor
  59745. * @param impostor impostor to set stiffness on
  59746. * @param stiffness stiffness value from 0 to 1
  59747. */
  59748. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59749. /**
  59750. * Gets velocityIterations of the impostor
  59751. * @param impostor impostor to get velocity iterations from
  59752. * @returns velocityIterations value
  59753. */
  59754. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59755. /**
  59756. * Sets velocityIterations of the impostor
  59757. * @param impostor impostor to set velocity iterations on
  59758. * @param velocityIterations velocityIterations value
  59759. */
  59760. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59761. /**
  59762. * Gets positionIterations of the impostor
  59763. * @param impostor impostor to get position iterations from
  59764. * @returns positionIterations value
  59765. */
  59766. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59767. /**
  59768. * Sets positionIterations of the impostor
  59769. * @param impostor impostor to set position on
  59770. * @param positionIterations positionIterations value
  59771. */
  59772. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59773. /**
  59774. * Append an anchor to a cloth object
  59775. * @param impostor is the cloth impostor to add anchor to
  59776. * @param otherImpostor is the rigid impostor to anchor to
  59777. * @param width ratio across width from 0 to 1
  59778. * @param height ratio up height from 0 to 1
  59779. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59780. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59781. */
  59782. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59783. /**
  59784. * Append an hook to a rope object
  59785. * @param impostor is the rope impostor to add hook to
  59786. * @param otherImpostor is the rigid impostor to hook to
  59787. * @param length ratio along the rope from 0 to 1
  59788. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59789. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59790. */
  59791. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59792. /**
  59793. * Sleeps the physics body and stops it from being active
  59794. * @param impostor impostor to sleep
  59795. */
  59796. sleepBody(impostor: PhysicsImpostor): void;
  59797. /**
  59798. * Activates the physics body
  59799. * @param impostor impostor to activate
  59800. */
  59801. wakeUpBody(impostor: PhysicsImpostor): void;
  59802. /**
  59803. * Updates the distance parameters of the joint
  59804. * @param joint joint to update
  59805. * @param maxDistance maximum distance of the joint
  59806. * @param minDistance minimum distance of the joint
  59807. */
  59808. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59809. /**
  59810. * Sets a motor on the joint
  59811. * @param joint joint to set motor on
  59812. * @param speed speed of the motor
  59813. * @param maxForce maximum force of the motor
  59814. * @param motorIndex index of the motor
  59815. */
  59816. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59817. /**
  59818. * Sets the motors limit
  59819. * @param joint joint to set limit on
  59820. * @param upperLimit upper limit
  59821. * @param lowerLimit lower limit
  59822. */
  59823. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59824. /**
  59825. * Syncs the position and rotation of a mesh with the impostor
  59826. * @param mesh mesh to sync
  59827. * @param impostor impostor to update the mesh with
  59828. */
  59829. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59830. /**
  59831. * Gets the radius of the impostor
  59832. * @param impostor impostor to get radius from
  59833. * @returns the radius
  59834. */
  59835. getRadius(impostor: PhysicsImpostor): number;
  59836. /**
  59837. * Gets the box size of the impostor
  59838. * @param impostor impostor to get box size from
  59839. * @param result the resulting box size
  59840. */
  59841. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59842. /**
  59843. * Disposes of the impostor
  59844. */
  59845. dispose(): void;
  59846. /**
  59847. * Does a raycast in the physics world
  59848. * @param from when should the ray start?
  59849. * @param to when should the ray end?
  59850. * @returns PhysicsRaycastResult
  59851. */
  59852. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59853. }
  59854. }
  59855. declare module BABYLON {
  59856. interface AbstractScene {
  59857. /**
  59858. * The list of reflection probes added to the scene
  59859. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59860. */
  59861. reflectionProbes: Array<ReflectionProbe>;
  59862. /**
  59863. * Removes the given reflection probe from this scene.
  59864. * @param toRemove The reflection probe to remove
  59865. * @returns The index of the removed reflection probe
  59866. */
  59867. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59868. /**
  59869. * Adds the given reflection probe to this scene.
  59870. * @param newReflectionProbe The reflection probe to add
  59871. */
  59872. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59873. }
  59874. /**
  59875. * Class used to generate realtime reflection / refraction cube textures
  59876. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59877. */
  59878. export class ReflectionProbe {
  59879. /** defines the name of the probe */
  59880. name: string;
  59881. private _scene;
  59882. private _renderTargetTexture;
  59883. private _projectionMatrix;
  59884. private _viewMatrix;
  59885. private _target;
  59886. private _add;
  59887. private _attachedMesh;
  59888. private _invertYAxis;
  59889. /** Gets or sets probe position (center of the cube map) */
  59890. position: Vector3;
  59891. /**
  59892. * Creates a new reflection probe
  59893. * @param name defines the name of the probe
  59894. * @param size defines the texture resolution (for each face)
  59895. * @param scene defines the hosting scene
  59896. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59897. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59898. */
  59899. constructor(
  59900. /** defines the name of the probe */
  59901. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59902. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59903. get samples(): number;
  59904. set samples(value: number);
  59905. /** Gets or sets the refresh rate to use (on every frame by default) */
  59906. get refreshRate(): number;
  59907. set refreshRate(value: number);
  59908. /**
  59909. * Gets the hosting scene
  59910. * @returns a Scene
  59911. */
  59912. getScene(): Scene;
  59913. /** Gets the internal CubeTexture used to render to */
  59914. get cubeTexture(): RenderTargetTexture;
  59915. /** Gets the list of meshes to render */
  59916. get renderList(): Nullable<AbstractMesh[]>;
  59917. /**
  59918. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59919. * @param mesh defines the mesh to attach to
  59920. */
  59921. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59922. /**
  59923. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59924. * @param renderingGroupId The rendering group id corresponding to its index
  59925. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59926. */
  59927. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59928. /**
  59929. * Clean all associated resources
  59930. */
  59931. dispose(): void;
  59932. /**
  59933. * Converts the reflection probe information to a readable string for debug purpose.
  59934. * @param fullDetails Supports for multiple levels of logging within scene loading
  59935. * @returns the human readable reflection probe info
  59936. */
  59937. toString(fullDetails?: boolean): string;
  59938. /**
  59939. * Get the class name of the relfection probe.
  59940. * @returns "ReflectionProbe"
  59941. */
  59942. getClassName(): string;
  59943. /**
  59944. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59945. * @returns The JSON representation of the texture
  59946. */
  59947. serialize(): any;
  59948. /**
  59949. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59950. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59951. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59952. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59953. * @returns The parsed reflection probe if successful
  59954. */
  59955. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59956. }
  59957. }
  59958. declare module BABYLON {
  59959. /** @hidden */
  59960. export var _BabylonLoaderRegistered: boolean;
  59961. /**
  59962. * Helps setting up some configuration for the babylon file loader.
  59963. */
  59964. export class BabylonFileLoaderConfiguration {
  59965. /**
  59966. * The loader does not allow injecting custom physix engine into the plugins.
  59967. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59968. * So you could set this variable to your engine import to make it work.
  59969. */
  59970. static LoaderInjectedPhysicsEngine: any;
  59971. }
  59972. }
  59973. declare module BABYLON {
  59974. /**
  59975. * The Physically based simple base material of BJS.
  59976. *
  59977. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59978. * It is used as the base class for both the specGloss and metalRough conventions.
  59979. */
  59980. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59981. /**
  59982. * Number of Simultaneous lights allowed on the material.
  59983. */
  59984. maxSimultaneousLights: number;
  59985. /**
  59986. * If sets to true, disables all the lights affecting the material.
  59987. */
  59988. disableLighting: boolean;
  59989. /**
  59990. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59991. */
  59992. environmentTexture: BaseTexture;
  59993. /**
  59994. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59995. */
  59996. invertNormalMapX: boolean;
  59997. /**
  59998. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59999. */
  60000. invertNormalMapY: boolean;
  60001. /**
  60002. * Normal map used in the model.
  60003. */
  60004. normalTexture: BaseTexture;
  60005. /**
  60006. * Emissivie color used to self-illuminate the model.
  60007. */
  60008. emissiveColor: Color3;
  60009. /**
  60010. * Emissivie texture used to self-illuminate the model.
  60011. */
  60012. emissiveTexture: BaseTexture;
  60013. /**
  60014. * Occlusion Channel Strenght.
  60015. */
  60016. occlusionStrength: number;
  60017. /**
  60018. * Occlusion Texture of the material (adding extra occlusion effects).
  60019. */
  60020. occlusionTexture: BaseTexture;
  60021. /**
  60022. * Defines the alpha limits in alpha test mode.
  60023. */
  60024. alphaCutOff: number;
  60025. /**
  60026. * Gets the current double sided mode.
  60027. */
  60028. get doubleSided(): boolean;
  60029. /**
  60030. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60031. */
  60032. set doubleSided(value: boolean);
  60033. /**
  60034. * Stores the pre-calculated light information of a mesh in a texture.
  60035. */
  60036. lightmapTexture: BaseTexture;
  60037. /**
  60038. * If true, the light map contains occlusion information instead of lighting info.
  60039. */
  60040. useLightmapAsShadowmap: boolean;
  60041. /**
  60042. * Instantiates a new PBRMaterial instance.
  60043. *
  60044. * @param name The material name
  60045. * @param scene The scene the material will be use in.
  60046. */
  60047. constructor(name: string, scene: Scene);
  60048. getClassName(): string;
  60049. }
  60050. }
  60051. declare module BABYLON {
  60052. /**
  60053. * The PBR material of BJS following the metal roughness convention.
  60054. *
  60055. * This fits to the PBR convention in the GLTF definition:
  60056. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60057. */
  60058. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60059. /**
  60060. * The base color has two different interpretations depending on the value of metalness.
  60061. * When the material is a metal, the base color is the specific measured reflectance value
  60062. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60063. * of the material.
  60064. */
  60065. baseColor: Color3;
  60066. /**
  60067. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60068. * well as opacity information in the alpha channel.
  60069. */
  60070. baseTexture: BaseTexture;
  60071. /**
  60072. * Specifies the metallic scalar value of the material.
  60073. * Can also be used to scale the metalness values of the metallic texture.
  60074. */
  60075. metallic: number;
  60076. /**
  60077. * Specifies the roughness scalar value of the material.
  60078. * Can also be used to scale the roughness values of the metallic texture.
  60079. */
  60080. roughness: number;
  60081. /**
  60082. * Texture containing both the metallic value in the B channel and the
  60083. * roughness value in the G channel to keep better precision.
  60084. */
  60085. metallicRoughnessTexture: BaseTexture;
  60086. /**
  60087. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60088. *
  60089. * @param name The material name
  60090. * @param scene The scene the material will be use in.
  60091. */
  60092. constructor(name: string, scene: Scene);
  60093. /**
  60094. * Return the currrent class name of the material.
  60095. */
  60096. getClassName(): string;
  60097. /**
  60098. * Makes a duplicate of the current material.
  60099. * @param name - name to use for the new material.
  60100. */
  60101. clone(name: string): PBRMetallicRoughnessMaterial;
  60102. /**
  60103. * Serialize the material to a parsable JSON object.
  60104. */
  60105. serialize(): any;
  60106. /**
  60107. * Parses a JSON object correponding to the serialize function.
  60108. */
  60109. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60110. }
  60111. }
  60112. declare module BABYLON {
  60113. /**
  60114. * The PBR material of BJS following the specular glossiness convention.
  60115. *
  60116. * This fits to the PBR convention in the GLTF definition:
  60117. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60118. */
  60119. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60120. /**
  60121. * Specifies the diffuse color of the material.
  60122. */
  60123. diffuseColor: Color3;
  60124. /**
  60125. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60126. * channel.
  60127. */
  60128. diffuseTexture: BaseTexture;
  60129. /**
  60130. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60131. */
  60132. specularColor: Color3;
  60133. /**
  60134. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60135. */
  60136. glossiness: number;
  60137. /**
  60138. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60139. */
  60140. specularGlossinessTexture: BaseTexture;
  60141. /**
  60142. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60143. *
  60144. * @param name The material name
  60145. * @param scene The scene the material will be use in.
  60146. */
  60147. constructor(name: string, scene: Scene);
  60148. /**
  60149. * Return the currrent class name of the material.
  60150. */
  60151. getClassName(): string;
  60152. /**
  60153. * Makes a duplicate of the current material.
  60154. * @param name - name to use for the new material.
  60155. */
  60156. clone(name: string): PBRSpecularGlossinessMaterial;
  60157. /**
  60158. * Serialize the material to a parsable JSON object.
  60159. */
  60160. serialize(): any;
  60161. /**
  60162. * Parses a JSON object correponding to the serialize function.
  60163. */
  60164. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60165. }
  60166. }
  60167. declare module BABYLON {
  60168. /**
  60169. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60170. * It can help converting any input color in a desired output one. This can then be used to create effects
  60171. * from sepia, black and white to sixties or futuristic rendering...
  60172. *
  60173. * The only supported format is currently 3dl.
  60174. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60175. */
  60176. export class ColorGradingTexture extends BaseTexture {
  60177. /**
  60178. * The texture URL.
  60179. */
  60180. url: string;
  60181. /**
  60182. * Empty line regex stored for GC.
  60183. */
  60184. private static _noneEmptyLineRegex;
  60185. private _textureMatrix;
  60186. private _onLoad;
  60187. /**
  60188. * Instantiates a ColorGradingTexture from the following parameters.
  60189. *
  60190. * @param url The location of the color gradind data (currently only supporting 3dl)
  60191. * @param sceneOrEngine The scene or engine the texture will be used in
  60192. * @param onLoad defines a callback triggered when the texture has been loaded
  60193. */
  60194. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60195. /**
  60196. * Fires the onload event from the constructor if requested.
  60197. */
  60198. private _triggerOnLoad;
  60199. /**
  60200. * Returns the texture matrix used in most of the material.
  60201. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60202. */
  60203. getTextureMatrix(): Matrix;
  60204. /**
  60205. * Occurs when the file being loaded is a .3dl LUT file.
  60206. */
  60207. private load3dlTexture;
  60208. /**
  60209. * Starts the loading process of the texture.
  60210. */
  60211. private loadTexture;
  60212. /**
  60213. * Clones the color gradind texture.
  60214. */
  60215. clone(): ColorGradingTexture;
  60216. /**
  60217. * Called during delayed load for textures.
  60218. */
  60219. delayLoad(): void;
  60220. /**
  60221. * Parses a color grading texture serialized by Babylon.
  60222. * @param parsedTexture The texture information being parsedTexture
  60223. * @param scene The scene to load the texture in
  60224. * @param rootUrl The root url of the data assets to load
  60225. * @return A color gradind texture
  60226. */
  60227. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60228. /**
  60229. * Serializes the LUT texture to json format.
  60230. */
  60231. serialize(): any;
  60232. }
  60233. }
  60234. declare module BABYLON {
  60235. /**
  60236. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60237. */
  60238. export class EquiRectangularCubeTexture extends BaseTexture {
  60239. /** The six faces of the cube. */
  60240. private static _FacesMapping;
  60241. private _noMipmap;
  60242. private _onLoad;
  60243. private _onError;
  60244. /** The size of the cubemap. */
  60245. private _size;
  60246. /** The buffer of the image. */
  60247. private _buffer;
  60248. /** The width of the input image. */
  60249. private _width;
  60250. /** The height of the input image. */
  60251. private _height;
  60252. /** The URL to the image. */
  60253. url: string;
  60254. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60255. coordinatesMode: number;
  60256. /**
  60257. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60258. * @param url The location of the image
  60259. * @param scene The scene the texture will be used in
  60260. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60261. * @param noMipmap Forces to not generate the mipmap if true
  60262. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60263. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60264. * @param onLoad — defines a callback called when texture is loaded
  60265. * @param onError — defines a callback called if there is an error
  60266. */
  60267. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60268. /**
  60269. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60270. */
  60271. private loadImage;
  60272. /**
  60273. * Convert the image buffer into a cubemap and create a CubeTexture.
  60274. */
  60275. private loadTexture;
  60276. /**
  60277. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60278. * @param buffer The ArrayBuffer that should be converted.
  60279. * @returns The buffer as Float32Array.
  60280. */
  60281. private getFloat32ArrayFromArrayBuffer;
  60282. /**
  60283. * Get the current class name of the texture useful for serialization or dynamic coding.
  60284. * @returns "EquiRectangularCubeTexture"
  60285. */
  60286. getClassName(): string;
  60287. /**
  60288. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60289. * @returns A clone of the current EquiRectangularCubeTexture.
  60290. */
  60291. clone(): EquiRectangularCubeTexture;
  60292. }
  60293. }
  60294. declare module BABYLON {
  60295. /**
  60296. * Defines the options related to the creation of an HtmlElementTexture
  60297. */
  60298. export interface IHtmlElementTextureOptions {
  60299. /**
  60300. * Defines wether mip maps should be created or not.
  60301. */
  60302. generateMipMaps?: boolean;
  60303. /**
  60304. * Defines the sampling mode of the texture.
  60305. */
  60306. samplingMode?: number;
  60307. /**
  60308. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60309. */
  60310. engine: Nullable<ThinEngine>;
  60311. /**
  60312. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60313. */
  60314. scene: Nullable<Scene>;
  60315. }
  60316. /**
  60317. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60318. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60319. * is automatically managed.
  60320. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60321. * in your application.
  60322. *
  60323. * As the update is not automatic, you need to call them manually.
  60324. */
  60325. export class HtmlElementTexture extends BaseTexture {
  60326. /**
  60327. * The texture URL.
  60328. */
  60329. element: HTMLVideoElement | HTMLCanvasElement;
  60330. private static readonly DefaultOptions;
  60331. private _textureMatrix;
  60332. private _isVideo;
  60333. private _generateMipMaps;
  60334. private _samplingMode;
  60335. /**
  60336. * Instantiates a HtmlElementTexture from the following parameters.
  60337. *
  60338. * @param name Defines the name of the texture
  60339. * @param element Defines the video or canvas the texture is filled with
  60340. * @param options Defines the other none mandatory texture creation options
  60341. */
  60342. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60343. private _createInternalTexture;
  60344. /**
  60345. * Returns the texture matrix used in most of the material.
  60346. */
  60347. getTextureMatrix(): Matrix;
  60348. /**
  60349. * Updates the content of the texture.
  60350. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60351. */
  60352. update(invertY?: Nullable<boolean>): void;
  60353. }
  60354. }
  60355. declare module BABYLON {
  60356. /**
  60357. * Based on jsTGALoader - Javascript loader for TGA file
  60358. * By Vincent Thibault
  60359. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60360. */
  60361. export class TGATools {
  60362. private static _TYPE_INDEXED;
  60363. private static _TYPE_RGB;
  60364. private static _TYPE_GREY;
  60365. private static _TYPE_RLE_INDEXED;
  60366. private static _TYPE_RLE_RGB;
  60367. private static _TYPE_RLE_GREY;
  60368. private static _ORIGIN_MASK;
  60369. private static _ORIGIN_SHIFT;
  60370. private static _ORIGIN_BL;
  60371. private static _ORIGIN_BR;
  60372. private static _ORIGIN_UL;
  60373. private static _ORIGIN_UR;
  60374. /**
  60375. * Gets the header of a TGA file
  60376. * @param data defines the TGA data
  60377. * @returns the header
  60378. */
  60379. static GetTGAHeader(data: Uint8Array): any;
  60380. /**
  60381. * Uploads TGA content to a Babylon Texture
  60382. * @hidden
  60383. */
  60384. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60385. /** @hidden */
  60386. 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;
  60387. /** @hidden */
  60388. 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;
  60389. /** @hidden */
  60390. 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;
  60391. /** @hidden */
  60392. 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;
  60393. /** @hidden */
  60394. 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;
  60395. /** @hidden */
  60396. 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;
  60397. }
  60398. }
  60399. declare module BABYLON {
  60400. /**
  60401. * Implementation of the TGA Texture Loader.
  60402. * @hidden
  60403. */
  60404. export class _TGATextureLoader implements IInternalTextureLoader {
  60405. /**
  60406. * Defines wether the loader supports cascade loading the different faces.
  60407. */
  60408. readonly supportCascades: boolean;
  60409. /**
  60410. * This returns if the loader support the current file information.
  60411. * @param extension defines the file extension of the file being loaded
  60412. * @returns true if the loader can load the specified file
  60413. */
  60414. canLoad(extension: string): boolean;
  60415. /**
  60416. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60417. * @param data contains the texture data
  60418. * @param texture defines the BabylonJS internal texture
  60419. * @param createPolynomials will be true if polynomials have been requested
  60420. * @param onLoad defines the callback to trigger once the texture is ready
  60421. * @param onError defines the callback to trigger in case of error
  60422. */
  60423. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60424. /**
  60425. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60426. * @param data contains the texture data
  60427. * @param texture defines the BabylonJS internal texture
  60428. * @param callback defines the method to call once ready to upload
  60429. */
  60430. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60431. }
  60432. }
  60433. declare module BABYLON {
  60434. /**
  60435. * Info about the .basis files
  60436. */
  60437. class BasisFileInfo {
  60438. /**
  60439. * If the file has alpha
  60440. */
  60441. hasAlpha: boolean;
  60442. /**
  60443. * Info about each image of the basis file
  60444. */
  60445. images: Array<{
  60446. levels: Array<{
  60447. width: number;
  60448. height: number;
  60449. transcodedPixels: ArrayBufferView;
  60450. }>;
  60451. }>;
  60452. }
  60453. /**
  60454. * Result of transcoding a basis file
  60455. */
  60456. class TranscodeResult {
  60457. /**
  60458. * Info about the .basis file
  60459. */
  60460. fileInfo: BasisFileInfo;
  60461. /**
  60462. * Format to use when loading the file
  60463. */
  60464. format: number;
  60465. }
  60466. /**
  60467. * Configuration options for the Basis transcoder
  60468. */
  60469. export class BasisTranscodeConfiguration {
  60470. /**
  60471. * Supported compression formats used to determine the supported output format of the transcoder
  60472. */
  60473. supportedCompressionFormats?: {
  60474. /**
  60475. * etc1 compression format
  60476. */
  60477. etc1?: boolean;
  60478. /**
  60479. * s3tc compression format
  60480. */
  60481. s3tc?: boolean;
  60482. /**
  60483. * pvrtc compression format
  60484. */
  60485. pvrtc?: boolean;
  60486. /**
  60487. * etc2 compression format
  60488. */
  60489. etc2?: boolean;
  60490. };
  60491. /**
  60492. * If mipmap levels should be loaded for transcoded images (Default: true)
  60493. */
  60494. loadMipmapLevels?: boolean;
  60495. /**
  60496. * Index of a single image to load (Default: all images)
  60497. */
  60498. loadSingleImage?: number;
  60499. }
  60500. /**
  60501. * Used to load .Basis files
  60502. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60503. */
  60504. export class BasisTools {
  60505. private static _IgnoreSupportedFormats;
  60506. /**
  60507. * URL to use when loading the basis transcoder
  60508. */
  60509. static JSModuleURL: string;
  60510. /**
  60511. * URL to use when loading the wasm module for the transcoder
  60512. */
  60513. static WasmModuleURL: string;
  60514. /**
  60515. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60516. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60517. * @returns internal format corresponding to the Basis format
  60518. */
  60519. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60520. private static _WorkerPromise;
  60521. private static _Worker;
  60522. private static _actionId;
  60523. private static _CreateWorkerAsync;
  60524. /**
  60525. * Transcodes a loaded image file to compressed pixel data
  60526. * @param data image data to transcode
  60527. * @param config configuration options for the transcoding
  60528. * @returns a promise resulting in the transcoded image
  60529. */
  60530. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60531. /**
  60532. * Loads a texture from the transcode result
  60533. * @param texture texture load to
  60534. * @param transcodeResult the result of transcoding the basis file to load from
  60535. */
  60536. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60537. }
  60538. }
  60539. declare module BABYLON {
  60540. /**
  60541. * Loader for .basis file format
  60542. */
  60543. export class _BasisTextureLoader implements IInternalTextureLoader {
  60544. /**
  60545. * Defines whether the loader supports cascade loading the different faces.
  60546. */
  60547. readonly supportCascades: boolean;
  60548. /**
  60549. * This returns if the loader support the current file information.
  60550. * @param extension defines the file extension of the file being loaded
  60551. * @returns true if the loader can load the specified file
  60552. */
  60553. canLoad(extension: string): boolean;
  60554. /**
  60555. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60556. * @param data contains the texture data
  60557. * @param texture defines the BabylonJS internal texture
  60558. * @param createPolynomials will be true if polynomials have been requested
  60559. * @param onLoad defines the callback to trigger once the texture is ready
  60560. * @param onError defines the callback to trigger in case of error
  60561. */
  60562. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60563. /**
  60564. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60565. * @param data contains the texture data
  60566. * @param texture defines the BabylonJS internal texture
  60567. * @param callback defines the method to call once ready to upload
  60568. */
  60569. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60570. }
  60571. }
  60572. declare module BABYLON {
  60573. /**
  60574. * Defines the basic options interface of a TexturePacker Frame
  60575. */
  60576. export interface 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. /**
  60591. * This is a support class for frame Data on texture packer sets.
  60592. */
  60593. export class TexturePackerFrame implements ITexturePackerFrame {
  60594. /**
  60595. * The frame ID
  60596. */
  60597. id: number;
  60598. /**
  60599. * The frames Scale
  60600. */
  60601. scale: Vector2;
  60602. /**
  60603. * The Frames offset
  60604. */
  60605. offset: Vector2;
  60606. /**
  60607. * Initializes a texture package frame.
  60608. * @param id The numerical frame identifier
  60609. * @param scale Scalar Vector2 for UV frame
  60610. * @param offset Vector2 for the frame position in UV units.
  60611. * @returns TexturePackerFrame
  60612. */
  60613. constructor(id: number, scale: Vector2, offset: Vector2);
  60614. }
  60615. }
  60616. declare module BABYLON {
  60617. /**
  60618. * Defines the basic options interface of a TexturePacker
  60619. */
  60620. export interface ITexturePackerOptions {
  60621. /**
  60622. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60623. */
  60624. map?: string[];
  60625. /**
  60626. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60627. */
  60628. uvsIn?: string;
  60629. /**
  60630. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60631. */
  60632. uvsOut?: string;
  60633. /**
  60634. * number representing the layout style. Defaults to LAYOUT_STRIP
  60635. */
  60636. layout?: number;
  60637. /**
  60638. * number of columns if using custom column count layout(2). This defaults to 4.
  60639. */
  60640. colnum?: number;
  60641. /**
  60642. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60643. */
  60644. updateInputMeshes?: boolean;
  60645. /**
  60646. * boolean flag to dispose all the source textures. Defaults to true.
  60647. */
  60648. disposeSources?: boolean;
  60649. /**
  60650. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60651. */
  60652. fillBlanks?: boolean;
  60653. /**
  60654. * string value representing the context fill style color. Defaults to 'black'.
  60655. */
  60656. customFillColor?: string;
  60657. /**
  60658. * Width and Height Value of each Frame in the TexturePacker Sets
  60659. */
  60660. frameSize?: number;
  60661. /**
  60662. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60663. */
  60664. paddingRatio?: number;
  60665. /**
  60666. * Number that declares the fill method for the padding gutter.
  60667. */
  60668. paddingMode?: number;
  60669. /**
  60670. * If in SUBUV_COLOR padding mode what color to use.
  60671. */
  60672. paddingColor?: Color3 | Color4;
  60673. }
  60674. /**
  60675. * Defines the basic interface of a TexturePacker JSON File
  60676. */
  60677. export interface ITexturePackerJSON {
  60678. /**
  60679. * The frame ID
  60680. */
  60681. name: string;
  60682. /**
  60683. * The base64 channel data
  60684. */
  60685. sets: any;
  60686. /**
  60687. * The options of the Packer
  60688. */
  60689. options: ITexturePackerOptions;
  60690. /**
  60691. * The frame data of the Packer
  60692. */
  60693. frames: Array<number>;
  60694. }
  60695. /**
  60696. * This is a support class that generates a series of packed texture sets.
  60697. * @see https://doc.babylonjs.com/babylon101/materials
  60698. */
  60699. export class TexturePacker {
  60700. /** Packer Layout Constant 0 */
  60701. static readonly LAYOUT_STRIP: number;
  60702. /** Packer Layout Constant 1 */
  60703. static readonly LAYOUT_POWER2: number;
  60704. /** Packer Layout Constant 2 */
  60705. static readonly LAYOUT_COLNUM: number;
  60706. /** Packer Layout Constant 0 */
  60707. static readonly SUBUV_WRAP: number;
  60708. /** Packer Layout Constant 1 */
  60709. static readonly SUBUV_EXTEND: number;
  60710. /** Packer Layout Constant 2 */
  60711. static readonly SUBUV_COLOR: number;
  60712. /** The Name of the Texture Package */
  60713. name: string;
  60714. /** The scene scope of the TexturePacker */
  60715. scene: Scene;
  60716. /** The Meshes to target */
  60717. meshes: AbstractMesh[];
  60718. /** Arguments passed with the Constructor */
  60719. options: ITexturePackerOptions;
  60720. /** The promise that is started upon initialization */
  60721. promise: Nullable<Promise<TexturePacker | string>>;
  60722. /** The Container object for the channel sets that are generated */
  60723. sets: object;
  60724. /** The Container array for the frames that are generated */
  60725. frames: TexturePackerFrame[];
  60726. /** The expected number of textures the system is parsing. */
  60727. private _expecting;
  60728. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60729. private _paddingValue;
  60730. /**
  60731. * Initializes a texture package series from an array of meshes or a single mesh.
  60732. * @param name The name of the package
  60733. * @param meshes The target meshes to compose the package from
  60734. * @param options The arguments that texture packer should follow while building.
  60735. * @param scene The scene which the textures are scoped to.
  60736. * @returns TexturePacker
  60737. */
  60738. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60739. /**
  60740. * Starts the package process
  60741. * @param resolve The promises resolution function
  60742. * @returns TexturePacker
  60743. */
  60744. private _createFrames;
  60745. /**
  60746. * Calculates the Size of the Channel Sets
  60747. * @returns Vector2
  60748. */
  60749. private _calculateSize;
  60750. /**
  60751. * Calculates the UV data for the frames.
  60752. * @param baseSize the base frameSize
  60753. * @param padding the base frame padding
  60754. * @param dtSize size of the Dynamic Texture for that channel
  60755. * @param dtUnits is 1/dtSize
  60756. * @param update flag to update the input meshes
  60757. */
  60758. private _calculateMeshUVFrames;
  60759. /**
  60760. * Calculates the frames Offset.
  60761. * @param index of the frame
  60762. * @returns Vector2
  60763. */
  60764. private _getFrameOffset;
  60765. /**
  60766. * Updates a Mesh to the frame data
  60767. * @param mesh that is the target
  60768. * @param frameID or the frame index
  60769. */
  60770. private _updateMeshUV;
  60771. /**
  60772. * Updates a Meshes materials to use the texture packer channels
  60773. * @param m is the mesh to target
  60774. * @param force all channels on the packer to be set.
  60775. */
  60776. private _updateTextureReferences;
  60777. /**
  60778. * Public method to set a Mesh to a frame
  60779. * @param m that is the target
  60780. * @param frameID or the frame index
  60781. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60782. */
  60783. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60784. /**
  60785. * Starts the async promise to compile the texture packer.
  60786. * @returns Promise<void>
  60787. */
  60788. processAsync(): Promise<void>;
  60789. /**
  60790. * Disposes all textures associated with this packer
  60791. */
  60792. dispose(): void;
  60793. /**
  60794. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60795. * @param imageType is the image type to use.
  60796. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60797. */
  60798. download(imageType?: string, quality?: number): void;
  60799. /**
  60800. * Public method to load a texturePacker JSON file.
  60801. * @param data of the JSON file in string format.
  60802. */
  60803. updateFromJSON(data: string): void;
  60804. }
  60805. }
  60806. declare module BABYLON {
  60807. /**
  60808. * 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.
  60809. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60810. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60811. */
  60812. export class CustomProceduralTexture extends ProceduralTexture {
  60813. private _animate;
  60814. private _time;
  60815. private _config;
  60816. private _texturePath;
  60817. /**
  60818. * Instantiates a new Custom Procedural Texture.
  60819. * 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.
  60820. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60821. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60822. * @param name Define the name of the texture
  60823. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60824. * @param size Define the size of the texture to create
  60825. * @param scene Define the scene the texture belongs to
  60826. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60827. * @param generateMipMaps Define if the texture should creates mip maps or not
  60828. */
  60829. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60830. private _loadJson;
  60831. /**
  60832. * Is the texture ready to be used ? (rendered at least once)
  60833. * @returns true if ready, otherwise, false.
  60834. */
  60835. isReady(): boolean;
  60836. /**
  60837. * Render the texture to its associated render target.
  60838. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60839. */
  60840. render(useCameraPostProcess?: boolean): void;
  60841. /**
  60842. * Update the list of dependant textures samplers in the shader.
  60843. */
  60844. updateTextures(): void;
  60845. /**
  60846. * Update the uniform values of the procedural texture in the shader.
  60847. */
  60848. updateShaderUniforms(): void;
  60849. /**
  60850. * Define if the texture animates or not.
  60851. */
  60852. get animate(): boolean;
  60853. set animate(value: boolean);
  60854. }
  60855. }
  60856. declare module BABYLON {
  60857. /** @hidden */
  60858. export var noisePixelShader: {
  60859. name: string;
  60860. shader: string;
  60861. };
  60862. }
  60863. declare module BABYLON {
  60864. /**
  60865. * Class used to generate noise procedural textures
  60866. */
  60867. export class NoiseProceduralTexture extends ProceduralTexture {
  60868. private _time;
  60869. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60870. brightness: number;
  60871. /** Defines the number of octaves to process */
  60872. octaves: number;
  60873. /** Defines the level of persistence (0.8 by default) */
  60874. persistence: number;
  60875. /** Gets or sets animation speed factor (default is 1) */
  60876. animationSpeedFactor: number;
  60877. /**
  60878. * Creates a new NoiseProceduralTexture
  60879. * @param name defines the name fo the texture
  60880. * @param size defines the size of the texture (default is 256)
  60881. * @param scene defines the hosting scene
  60882. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60883. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60884. */
  60885. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60886. private _updateShaderUniforms;
  60887. protected _getDefines(): string;
  60888. /** Generate the current state of the procedural texture */
  60889. render(useCameraPostProcess?: boolean): void;
  60890. /**
  60891. * Serializes this noise procedural texture
  60892. * @returns a serialized noise procedural texture object
  60893. */
  60894. serialize(): any;
  60895. /**
  60896. * Clone the texture.
  60897. * @returns the cloned texture
  60898. */
  60899. clone(): NoiseProceduralTexture;
  60900. /**
  60901. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60902. * @param parsedTexture defines parsed texture data
  60903. * @param scene defines the current scene
  60904. * @param rootUrl defines the root URL containing noise procedural texture information
  60905. * @returns a parsed NoiseProceduralTexture
  60906. */
  60907. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60908. }
  60909. }
  60910. declare module BABYLON {
  60911. /**
  60912. * Raw cube texture where the raw buffers are passed in
  60913. */
  60914. export class RawCubeTexture extends CubeTexture {
  60915. /**
  60916. * Creates a cube texture where the raw buffers are passed in.
  60917. * @param scene defines the scene the texture is attached to
  60918. * @param data defines the array of data to use to create each face
  60919. * @param size defines the size of the textures
  60920. * @param format defines the format of the data
  60921. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60922. * @param generateMipMaps defines if the engine should generate the mip levels
  60923. * @param invertY defines if data must be stored with Y axis inverted
  60924. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60925. * @param compression defines the compression used (null by default)
  60926. */
  60927. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60928. /**
  60929. * Updates the raw cube texture.
  60930. * @param data defines the data to store
  60931. * @param format defines the data format
  60932. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60933. * @param invertY defines if data must be stored with Y axis inverted
  60934. * @param compression defines the compression used (null by default)
  60935. * @param level defines which level of the texture to update
  60936. */
  60937. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60938. /**
  60939. * Updates a raw cube texture with RGBD encoded data.
  60940. * @param data defines the array of data [mipmap][face] to use to create each face
  60941. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60942. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60943. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60944. * @returns a promsie that resolves when the operation is complete
  60945. */
  60946. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60947. /**
  60948. * Clones the raw cube texture.
  60949. * @return a new cube texture
  60950. */
  60951. clone(): CubeTexture;
  60952. /** @hidden */
  60953. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60954. }
  60955. }
  60956. declare module BABYLON {
  60957. /**
  60958. * Class used to store 2D array textures containing user data
  60959. */
  60960. export class RawTexture2DArray extends Texture {
  60961. /** Gets or sets the texture format to use */
  60962. format: number;
  60963. /**
  60964. * Create a new RawTexture2DArray
  60965. * @param data defines the data of the texture
  60966. * @param width defines the width of the texture
  60967. * @param height defines the height of the texture
  60968. * @param depth defines the number of layers of the texture
  60969. * @param format defines the texture format to use
  60970. * @param scene defines the hosting scene
  60971. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60972. * @param invertY defines if texture must be stored with Y axis inverted
  60973. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60974. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60975. */
  60976. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60977. /** Gets or sets the texture format to use */
  60978. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60979. /**
  60980. * Update the texture with new data
  60981. * @param data defines the data to store in the texture
  60982. */
  60983. update(data: ArrayBufferView): void;
  60984. }
  60985. }
  60986. declare module BABYLON {
  60987. /**
  60988. * Class used to store 3D textures containing user data
  60989. */
  60990. export class RawTexture3D extends Texture {
  60991. /** Gets or sets the texture format to use */
  60992. format: number;
  60993. /**
  60994. * Create a new RawTexture3D
  60995. * @param data defines the data of the texture
  60996. * @param width defines the width of the texture
  60997. * @param height defines the height of the texture
  60998. * @param depth defines the depth of the texture
  60999. * @param format defines the texture format to use
  61000. * @param scene defines the hosting scene
  61001. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61002. * @param invertY defines if texture must be stored with Y axis inverted
  61003. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61004. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61005. */
  61006. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61007. /** Gets or sets the texture format to use */
  61008. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61009. /**
  61010. * Update the texture with new data
  61011. * @param data defines the data to store in the texture
  61012. */
  61013. update(data: ArrayBufferView): void;
  61014. }
  61015. }
  61016. declare module BABYLON {
  61017. /**
  61018. * Creates a refraction texture used by refraction channel of the standard material.
  61019. * It is like a mirror but to see through a material.
  61020. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61021. */
  61022. export class RefractionTexture extends RenderTargetTexture {
  61023. /**
  61024. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61025. * 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.
  61026. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61027. */
  61028. refractionPlane: Plane;
  61029. /**
  61030. * Define how deep under the surface we should see.
  61031. */
  61032. depth: number;
  61033. /**
  61034. * Creates a refraction texture used by refraction channel of the standard material.
  61035. * It is like a mirror but to see through a material.
  61036. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61037. * @param name Define the texture name
  61038. * @param size Define the size of the underlying texture
  61039. * @param scene Define the scene the refraction belongs to
  61040. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61041. */
  61042. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61043. /**
  61044. * Clone the refraction texture.
  61045. * @returns the cloned texture
  61046. */
  61047. clone(): RefractionTexture;
  61048. /**
  61049. * Serialize the texture to a JSON representation you could use in Parse later on
  61050. * @returns the serialized JSON representation
  61051. */
  61052. serialize(): any;
  61053. }
  61054. }
  61055. declare module BABYLON {
  61056. /**
  61057. * Block used to add support for vertex skinning (bones)
  61058. */
  61059. export class BonesBlock extends NodeMaterialBlock {
  61060. /**
  61061. * Creates a new BonesBlock
  61062. * @param name defines the block name
  61063. */
  61064. constructor(name: string);
  61065. /**
  61066. * Initialize the block and prepare the context for build
  61067. * @param state defines the state that will be used for the build
  61068. */
  61069. initialize(state: NodeMaterialBuildState): void;
  61070. /**
  61071. * Gets the current class name
  61072. * @returns the class name
  61073. */
  61074. getClassName(): string;
  61075. /**
  61076. * Gets the matrix indices input component
  61077. */
  61078. get matricesIndices(): NodeMaterialConnectionPoint;
  61079. /**
  61080. * Gets the matrix weights input component
  61081. */
  61082. get matricesWeights(): NodeMaterialConnectionPoint;
  61083. /**
  61084. * Gets the extra matrix indices input component
  61085. */
  61086. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61087. /**
  61088. * Gets the extra matrix weights input component
  61089. */
  61090. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61091. /**
  61092. * Gets the world input component
  61093. */
  61094. get world(): NodeMaterialConnectionPoint;
  61095. /**
  61096. * Gets the output component
  61097. */
  61098. get output(): NodeMaterialConnectionPoint;
  61099. autoConfigure(material: NodeMaterial): void;
  61100. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61103. protected _buildBlock(state: NodeMaterialBuildState): this;
  61104. }
  61105. }
  61106. declare module BABYLON {
  61107. /**
  61108. * Block used to add support for instances
  61109. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61110. */
  61111. export class InstancesBlock extends NodeMaterialBlock {
  61112. /**
  61113. * Creates a new InstancesBlock
  61114. * @param name defines the block name
  61115. */
  61116. constructor(name: string);
  61117. /**
  61118. * Gets the current class name
  61119. * @returns the class name
  61120. */
  61121. getClassName(): string;
  61122. /**
  61123. * Gets the first world row input component
  61124. */
  61125. get world0(): NodeMaterialConnectionPoint;
  61126. /**
  61127. * Gets the second world row input component
  61128. */
  61129. get world1(): NodeMaterialConnectionPoint;
  61130. /**
  61131. * Gets the third world row input component
  61132. */
  61133. get world2(): NodeMaterialConnectionPoint;
  61134. /**
  61135. * Gets the forth world row input component
  61136. */
  61137. get world3(): NodeMaterialConnectionPoint;
  61138. /**
  61139. * Gets the world input component
  61140. */
  61141. get world(): NodeMaterialConnectionPoint;
  61142. /**
  61143. * Gets the output component
  61144. */
  61145. get output(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the isntanceID component
  61148. */
  61149. get instanceID(): NodeMaterialConnectionPoint;
  61150. autoConfigure(material: NodeMaterial): void;
  61151. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61152. protected _buildBlock(state: NodeMaterialBuildState): this;
  61153. }
  61154. }
  61155. declare module BABYLON {
  61156. /**
  61157. * Block used to add morph targets support to vertex shader
  61158. */
  61159. export class MorphTargetsBlock extends NodeMaterialBlock {
  61160. private _repeatableContentAnchor;
  61161. /**
  61162. * Create a new MorphTargetsBlock
  61163. * @param name defines the block name
  61164. */
  61165. constructor(name: string);
  61166. /**
  61167. * Gets the current class name
  61168. * @returns the class name
  61169. */
  61170. getClassName(): string;
  61171. /**
  61172. * Gets the position input component
  61173. */
  61174. get position(): NodeMaterialConnectionPoint;
  61175. /**
  61176. * Gets the normal input component
  61177. */
  61178. get normal(): NodeMaterialConnectionPoint;
  61179. /**
  61180. * Gets the tangent input component
  61181. */
  61182. get tangent(): NodeMaterialConnectionPoint;
  61183. /**
  61184. * Gets the tangent input component
  61185. */
  61186. get uv(): NodeMaterialConnectionPoint;
  61187. /**
  61188. * Gets the position output component
  61189. */
  61190. get positionOutput(): NodeMaterialConnectionPoint;
  61191. /**
  61192. * Gets the normal output component
  61193. */
  61194. get normalOutput(): NodeMaterialConnectionPoint;
  61195. /**
  61196. * Gets the tangent output component
  61197. */
  61198. get tangentOutput(): NodeMaterialConnectionPoint;
  61199. /**
  61200. * Gets the tangent output component
  61201. */
  61202. get uvOutput(): NodeMaterialConnectionPoint;
  61203. initialize(state: NodeMaterialBuildState): void;
  61204. autoConfigure(material: NodeMaterial): void;
  61205. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61206. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61207. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61208. protected _buildBlock(state: NodeMaterialBuildState): this;
  61209. }
  61210. }
  61211. declare module BABYLON {
  61212. /**
  61213. * Block used to get data information from a light
  61214. */
  61215. export class LightInformationBlock extends NodeMaterialBlock {
  61216. private _lightDataUniformName;
  61217. private _lightColorUniformName;
  61218. private _lightTypeDefineName;
  61219. /**
  61220. * Gets or sets the light associated with this block
  61221. */
  61222. light: Nullable<Light>;
  61223. /**
  61224. * Creates a new LightInformationBlock
  61225. * @param name defines the block name
  61226. */
  61227. constructor(name: string);
  61228. /**
  61229. * Gets the current class name
  61230. * @returns the class name
  61231. */
  61232. getClassName(): string;
  61233. /**
  61234. * Gets the world position input component
  61235. */
  61236. get worldPosition(): NodeMaterialConnectionPoint;
  61237. /**
  61238. * Gets the direction output component
  61239. */
  61240. get direction(): NodeMaterialConnectionPoint;
  61241. /**
  61242. * Gets the direction output component
  61243. */
  61244. get color(): NodeMaterialConnectionPoint;
  61245. /**
  61246. * Gets the direction output component
  61247. */
  61248. get intensity(): NodeMaterialConnectionPoint;
  61249. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61250. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61251. protected _buildBlock(state: NodeMaterialBuildState): this;
  61252. serialize(): any;
  61253. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61254. }
  61255. }
  61256. declare module BABYLON {
  61257. /**
  61258. * Block used to add image processing support to fragment shader
  61259. */
  61260. export class ImageProcessingBlock extends NodeMaterialBlock {
  61261. /**
  61262. * Create a new ImageProcessingBlock
  61263. * @param name defines the block name
  61264. */
  61265. constructor(name: string);
  61266. /**
  61267. * Gets the current class name
  61268. * @returns the class name
  61269. */
  61270. getClassName(): string;
  61271. /**
  61272. * Gets the color input component
  61273. */
  61274. get color(): NodeMaterialConnectionPoint;
  61275. /**
  61276. * Gets the output component
  61277. */
  61278. get output(): NodeMaterialConnectionPoint;
  61279. /**
  61280. * Initialize the block and prepare the context for build
  61281. * @param state defines the state that will be used for the build
  61282. */
  61283. initialize(state: NodeMaterialBuildState): void;
  61284. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61286. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61287. protected _buildBlock(state: NodeMaterialBuildState): this;
  61288. }
  61289. }
  61290. declare module BABYLON {
  61291. /**
  61292. * Block used to pertub normals based on a normal map
  61293. */
  61294. export class PerturbNormalBlock extends NodeMaterialBlock {
  61295. private _tangentSpaceParameterName;
  61296. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61297. invertX: boolean;
  61298. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61299. invertY: boolean;
  61300. /**
  61301. * Create a new PerturbNormalBlock
  61302. * @param name defines the block name
  61303. */
  61304. constructor(name: string);
  61305. /**
  61306. * Gets the current class name
  61307. * @returns the class name
  61308. */
  61309. getClassName(): string;
  61310. /**
  61311. * Gets the world position input component
  61312. */
  61313. get worldPosition(): NodeMaterialConnectionPoint;
  61314. /**
  61315. * Gets the world normal input component
  61316. */
  61317. get worldNormal(): NodeMaterialConnectionPoint;
  61318. /**
  61319. * Gets the world tangent input component
  61320. */
  61321. get worldTangent(): NodeMaterialConnectionPoint;
  61322. /**
  61323. * Gets the uv input component
  61324. */
  61325. get uv(): NodeMaterialConnectionPoint;
  61326. /**
  61327. * Gets the normal map color input component
  61328. */
  61329. get normalMapColor(): NodeMaterialConnectionPoint;
  61330. /**
  61331. * Gets the strength input component
  61332. */
  61333. get strength(): NodeMaterialConnectionPoint;
  61334. /**
  61335. * Gets the output component
  61336. */
  61337. get output(): NodeMaterialConnectionPoint;
  61338. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61339. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61340. autoConfigure(material: NodeMaterial): void;
  61341. protected _buildBlock(state: NodeMaterialBuildState): this;
  61342. protected _dumpPropertiesCode(): string;
  61343. serialize(): any;
  61344. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61345. }
  61346. }
  61347. declare module BABYLON {
  61348. /**
  61349. * Block used to discard a pixel if a value is smaller than a cutoff
  61350. */
  61351. export class DiscardBlock extends NodeMaterialBlock {
  61352. /**
  61353. * Create a new DiscardBlock
  61354. * @param name defines the block name
  61355. */
  61356. constructor(name: string);
  61357. /**
  61358. * Gets the current class name
  61359. * @returns the class name
  61360. */
  61361. getClassName(): string;
  61362. /**
  61363. * Gets the color input component
  61364. */
  61365. get value(): NodeMaterialConnectionPoint;
  61366. /**
  61367. * Gets the cutoff input component
  61368. */
  61369. get cutoff(): NodeMaterialConnectionPoint;
  61370. protected _buildBlock(state: NodeMaterialBuildState): this;
  61371. }
  61372. }
  61373. declare module BABYLON {
  61374. /**
  61375. * Block used to test if the fragment shader is front facing
  61376. */
  61377. export class FrontFacingBlock extends NodeMaterialBlock {
  61378. /**
  61379. * Creates a new FrontFacingBlock
  61380. * @param name defines the block name
  61381. */
  61382. constructor(name: string);
  61383. /**
  61384. * Gets the current class name
  61385. * @returns the class name
  61386. */
  61387. getClassName(): string;
  61388. /**
  61389. * Gets the output component
  61390. */
  61391. get output(): NodeMaterialConnectionPoint;
  61392. protected _buildBlock(state: NodeMaterialBuildState): this;
  61393. }
  61394. }
  61395. declare module BABYLON {
  61396. /**
  61397. * Block used to get the derivative value on x and y of a given input
  61398. */
  61399. export class DerivativeBlock extends NodeMaterialBlock {
  61400. /**
  61401. * Create a new DerivativeBlock
  61402. * @param name defines the block name
  61403. */
  61404. constructor(name: string);
  61405. /**
  61406. * Gets the current class name
  61407. * @returns the class name
  61408. */
  61409. getClassName(): string;
  61410. /**
  61411. * Gets the input component
  61412. */
  61413. get input(): NodeMaterialConnectionPoint;
  61414. /**
  61415. * Gets the derivative output on x
  61416. */
  61417. get dx(): NodeMaterialConnectionPoint;
  61418. /**
  61419. * Gets the derivative output on y
  61420. */
  61421. get dy(): NodeMaterialConnectionPoint;
  61422. protected _buildBlock(state: NodeMaterialBuildState): this;
  61423. }
  61424. }
  61425. declare module BABYLON {
  61426. /**
  61427. * Block used to make gl_FragCoord available
  61428. */
  61429. export class FragCoordBlock extends NodeMaterialBlock {
  61430. /**
  61431. * Creates a new FragCoordBlock
  61432. * @param name defines the block name
  61433. */
  61434. constructor(name: string);
  61435. /**
  61436. * Gets the current class name
  61437. * @returns the class name
  61438. */
  61439. getClassName(): string;
  61440. /**
  61441. * Gets the xy component
  61442. */
  61443. get xy(): NodeMaterialConnectionPoint;
  61444. /**
  61445. * Gets the xyz component
  61446. */
  61447. get xyz(): NodeMaterialConnectionPoint;
  61448. /**
  61449. * Gets the xyzw component
  61450. */
  61451. get xyzw(): NodeMaterialConnectionPoint;
  61452. /**
  61453. * Gets the x component
  61454. */
  61455. get x(): NodeMaterialConnectionPoint;
  61456. /**
  61457. * Gets the y component
  61458. */
  61459. get y(): NodeMaterialConnectionPoint;
  61460. /**
  61461. * Gets the z component
  61462. */
  61463. get z(): NodeMaterialConnectionPoint;
  61464. /**
  61465. * Gets the w component
  61466. */
  61467. get output(): NodeMaterialConnectionPoint;
  61468. protected writeOutputs(state: NodeMaterialBuildState): string;
  61469. protected _buildBlock(state: NodeMaterialBuildState): this;
  61470. }
  61471. }
  61472. declare module BABYLON {
  61473. /**
  61474. * Block used to get the screen sizes
  61475. */
  61476. export class ScreenSizeBlock extends NodeMaterialBlock {
  61477. private _varName;
  61478. private _scene;
  61479. /**
  61480. * Creates a new ScreenSizeBlock
  61481. * @param name defines the block name
  61482. */
  61483. constructor(name: string);
  61484. /**
  61485. * Gets the current class name
  61486. * @returns the class name
  61487. */
  61488. getClassName(): string;
  61489. /**
  61490. * Gets the xy component
  61491. */
  61492. get xy(): NodeMaterialConnectionPoint;
  61493. /**
  61494. * Gets the x component
  61495. */
  61496. get x(): NodeMaterialConnectionPoint;
  61497. /**
  61498. * Gets the y component
  61499. */
  61500. get y(): NodeMaterialConnectionPoint;
  61501. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61502. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61503. protected _buildBlock(state: NodeMaterialBuildState): this;
  61504. }
  61505. }
  61506. declare module BABYLON {
  61507. /**
  61508. * Block used to add support for scene fog
  61509. */
  61510. export class FogBlock extends NodeMaterialBlock {
  61511. private _fogDistanceName;
  61512. private _fogParameters;
  61513. /**
  61514. * Create a new FogBlock
  61515. * @param name defines the block name
  61516. */
  61517. constructor(name: string);
  61518. /**
  61519. * Gets the current class name
  61520. * @returns the class name
  61521. */
  61522. getClassName(): string;
  61523. /**
  61524. * Gets the world position input component
  61525. */
  61526. get worldPosition(): NodeMaterialConnectionPoint;
  61527. /**
  61528. * Gets the view input component
  61529. */
  61530. get view(): NodeMaterialConnectionPoint;
  61531. /**
  61532. * Gets the color input component
  61533. */
  61534. get input(): NodeMaterialConnectionPoint;
  61535. /**
  61536. * Gets the fog color input component
  61537. */
  61538. get fogColor(): NodeMaterialConnectionPoint;
  61539. /**
  61540. * Gets the output component
  61541. */
  61542. get output(): NodeMaterialConnectionPoint;
  61543. autoConfigure(material: NodeMaterial): void;
  61544. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61545. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61546. protected _buildBlock(state: NodeMaterialBuildState): this;
  61547. }
  61548. }
  61549. declare module BABYLON {
  61550. /**
  61551. * Block used to add light in the fragment shader
  61552. */
  61553. export class LightBlock extends NodeMaterialBlock {
  61554. private _lightId;
  61555. /**
  61556. * Gets or sets the light associated with this block
  61557. */
  61558. light: Nullable<Light>;
  61559. /**
  61560. * Create a new LightBlock
  61561. * @param name defines the block name
  61562. */
  61563. constructor(name: string);
  61564. /**
  61565. * Gets the current class name
  61566. * @returns the class name
  61567. */
  61568. getClassName(): string;
  61569. /**
  61570. * Gets the world position input component
  61571. */
  61572. get worldPosition(): NodeMaterialConnectionPoint;
  61573. /**
  61574. * Gets the world normal input component
  61575. */
  61576. get worldNormal(): NodeMaterialConnectionPoint;
  61577. /**
  61578. * Gets the camera (or eye) position component
  61579. */
  61580. get cameraPosition(): NodeMaterialConnectionPoint;
  61581. /**
  61582. * Gets the glossiness component
  61583. */
  61584. get glossiness(): NodeMaterialConnectionPoint;
  61585. /**
  61586. * Gets the glossinness power component
  61587. */
  61588. get glossPower(): NodeMaterialConnectionPoint;
  61589. /**
  61590. * Gets the diffuse color component
  61591. */
  61592. get diffuseColor(): NodeMaterialConnectionPoint;
  61593. /**
  61594. * Gets the specular color component
  61595. */
  61596. get specularColor(): NodeMaterialConnectionPoint;
  61597. /**
  61598. * Gets the diffuse output component
  61599. */
  61600. get diffuseOutput(): NodeMaterialConnectionPoint;
  61601. /**
  61602. * Gets the specular output component
  61603. */
  61604. get specularOutput(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the shadow output component
  61607. */
  61608. get shadow(): NodeMaterialConnectionPoint;
  61609. autoConfigure(material: NodeMaterial): void;
  61610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61611. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61612. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61613. private _injectVertexCode;
  61614. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61615. serialize(): any;
  61616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61617. }
  61618. }
  61619. declare module BABYLON {
  61620. /**
  61621. * Block used to read a reflection texture from a sampler
  61622. */
  61623. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61624. /**
  61625. * Create a new ReflectionTextureBlock
  61626. * @param name defines the block name
  61627. */
  61628. constructor(name: string);
  61629. /**
  61630. * Gets the current class name
  61631. * @returns the class name
  61632. */
  61633. getClassName(): string;
  61634. /**
  61635. * Gets the world position input component
  61636. */
  61637. get position(): NodeMaterialConnectionPoint;
  61638. /**
  61639. * Gets the world position input component
  61640. */
  61641. get worldPosition(): NodeMaterialConnectionPoint;
  61642. /**
  61643. * Gets the world normal input component
  61644. */
  61645. get worldNormal(): NodeMaterialConnectionPoint;
  61646. /**
  61647. * Gets the world input component
  61648. */
  61649. get world(): NodeMaterialConnectionPoint;
  61650. /**
  61651. * Gets the camera (or eye) position component
  61652. */
  61653. get cameraPosition(): NodeMaterialConnectionPoint;
  61654. /**
  61655. * Gets the view input component
  61656. */
  61657. get view(): NodeMaterialConnectionPoint;
  61658. /**
  61659. * Gets the rgb output component
  61660. */
  61661. get rgb(): NodeMaterialConnectionPoint;
  61662. /**
  61663. * Gets the r output component
  61664. */
  61665. get r(): NodeMaterialConnectionPoint;
  61666. /**
  61667. * Gets the g output component
  61668. */
  61669. get g(): NodeMaterialConnectionPoint;
  61670. /**
  61671. * Gets the b output component
  61672. */
  61673. get b(): NodeMaterialConnectionPoint;
  61674. autoConfigure(material: NodeMaterial): void;
  61675. protected _buildBlock(state: NodeMaterialBuildState): this;
  61676. }
  61677. }
  61678. declare module BABYLON {
  61679. /**
  61680. * Block used to add 2 vectors
  61681. */
  61682. export class AddBlock extends NodeMaterialBlock {
  61683. /**
  61684. * Creates a new AddBlock
  61685. * @param name defines the block name
  61686. */
  61687. constructor(name: string);
  61688. /**
  61689. * Gets the current class name
  61690. * @returns the class name
  61691. */
  61692. getClassName(): string;
  61693. /**
  61694. * Gets the left operand input component
  61695. */
  61696. get left(): NodeMaterialConnectionPoint;
  61697. /**
  61698. * Gets the right operand input component
  61699. */
  61700. get right(): NodeMaterialConnectionPoint;
  61701. /**
  61702. * Gets the output component
  61703. */
  61704. get output(): NodeMaterialConnectionPoint;
  61705. protected _buildBlock(state: NodeMaterialBuildState): this;
  61706. }
  61707. }
  61708. declare module BABYLON {
  61709. /**
  61710. * Block used to scale a vector by a float
  61711. */
  61712. export class ScaleBlock extends NodeMaterialBlock {
  61713. /**
  61714. * Creates a new ScaleBlock
  61715. * @param name defines the block name
  61716. */
  61717. constructor(name: string);
  61718. /**
  61719. * Gets the current class name
  61720. * @returns the class name
  61721. */
  61722. getClassName(): string;
  61723. /**
  61724. * Gets the input component
  61725. */
  61726. get input(): NodeMaterialConnectionPoint;
  61727. /**
  61728. * Gets the factor input component
  61729. */
  61730. get factor(): NodeMaterialConnectionPoint;
  61731. /**
  61732. * Gets the output component
  61733. */
  61734. get output(): NodeMaterialConnectionPoint;
  61735. protected _buildBlock(state: NodeMaterialBuildState): this;
  61736. }
  61737. }
  61738. declare module BABYLON {
  61739. /**
  61740. * Block used to clamp a float
  61741. */
  61742. export class ClampBlock extends NodeMaterialBlock {
  61743. /** Gets or sets the minimum range */
  61744. minimum: number;
  61745. /** Gets or sets the maximum range */
  61746. maximum: number;
  61747. /**
  61748. * Creates a new ClampBlock
  61749. * @param name defines the block name
  61750. */
  61751. constructor(name: string);
  61752. /**
  61753. * Gets the current class name
  61754. * @returns the class name
  61755. */
  61756. getClassName(): string;
  61757. /**
  61758. * Gets the value input component
  61759. */
  61760. get value(): NodeMaterialConnectionPoint;
  61761. /**
  61762. * Gets the output component
  61763. */
  61764. get output(): NodeMaterialConnectionPoint;
  61765. protected _buildBlock(state: NodeMaterialBuildState): this;
  61766. protected _dumpPropertiesCode(): string;
  61767. serialize(): any;
  61768. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61769. }
  61770. }
  61771. declare module BABYLON {
  61772. /**
  61773. * Block used to apply a cross product between 2 vectors
  61774. */
  61775. export class CrossBlock extends NodeMaterialBlock {
  61776. /**
  61777. * Creates a new CrossBlock
  61778. * @param name defines the block name
  61779. */
  61780. constructor(name: string);
  61781. /**
  61782. * Gets the current class name
  61783. * @returns the class name
  61784. */
  61785. getClassName(): string;
  61786. /**
  61787. * Gets the left operand input component
  61788. */
  61789. get left(): NodeMaterialConnectionPoint;
  61790. /**
  61791. * Gets the right operand input component
  61792. */
  61793. get right(): NodeMaterialConnectionPoint;
  61794. /**
  61795. * Gets the output component
  61796. */
  61797. get output(): NodeMaterialConnectionPoint;
  61798. protected _buildBlock(state: NodeMaterialBuildState): this;
  61799. }
  61800. }
  61801. declare module BABYLON {
  61802. /**
  61803. * Block used to apply a dot product between 2 vectors
  61804. */
  61805. export class DotBlock extends NodeMaterialBlock {
  61806. /**
  61807. * Creates a new DotBlock
  61808. * @param name defines the block name
  61809. */
  61810. constructor(name: string);
  61811. /**
  61812. * Gets the current class name
  61813. * @returns the class name
  61814. */
  61815. getClassName(): string;
  61816. /**
  61817. * Gets the left operand input component
  61818. */
  61819. get left(): NodeMaterialConnectionPoint;
  61820. /**
  61821. * Gets the right operand input component
  61822. */
  61823. get right(): NodeMaterialConnectionPoint;
  61824. /**
  61825. * Gets the output component
  61826. */
  61827. get output(): NodeMaterialConnectionPoint;
  61828. protected _buildBlock(state: NodeMaterialBuildState): this;
  61829. }
  61830. }
  61831. declare module BABYLON {
  61832. /**
  61833. * Block used to normalize a vector
  61834. */
  61835. export class NormalizeBlock extends NodeMaterialBlock {
  61836. /**
  61837. * Creates a new NormalizeBlock
  61838. * @param name defines the block name
  61839. */
  61840. constructor(name: string);
  61841. /**
  61842. * Gets the current class name
  61843. * @returns the class name
  61844. */
  61845. getClassName(): string;
  61846. /**
  61847. * Gets the input component
  61848. */
  61849. get input(): NodeMaterialConnectionPoint;
  61850. /**
  61851. * Gets the output component
  61852. */
  61853. get output(): NodeMaterialConnectionPoint;
  61854. protected _buildBlock(state: NodeMaterialBuildState): this;
  61855. }
  61856. }
  61857. declare module BABYLON {
  61858. /**
  61859. * Operations supported by the Trigonometry block
  61860. */
  61861. export enum TrigonometryBlockOperations {
  61862. /** Cos */
  61863. Cos = 0,
  61864. /** Sin */
  61865. Sin = 1,
  61866. /** Abs */
  61867. Abs = 2,
  61868. /** Exp */
  61869. Exp = 3,
  61870. /** Exp2 */
  61871. Exp2 = 4,
  61872. /** Round */
  61873. Round = 5,
  61874. /** Floor */
  61875. Floor = 6,
  61876. /** Ceiling */
  61877. Ceiling = 7,
  61878. /** Square root */
  61879. Sqrt = 8,
  61880. /** Log */
  61881. Log = 9,
  61882. /** Tangent */
  61883. Tan = 10,
  61884. /** Arc tangent */
  61885. ArcTan = 11,
  61886. /** Arc cosinus */
  61887. ArcCos = 12,
  61888. /** Arc sinus */
  61889. ArcSin = 13,
  61890. /** Fraction */
  61891. Fract = 14,
  61892. /** Sign */
  61893. Sign = 15,
  61894. /** To radians (from degrees) */
  61895. Radians = 16,
  61896. /** To degrees (from radians) */
  61897. Degrees = 17
  61898. }
  61899. /**
  61900. * Block used to apply trigonometry operation to floats
  61901. */
  61902. export class TrigonometryBlock extends NodeMaterialBlock {
  61903. /**
  61904. * Gets or sets the operation applied by the block
  61905. */
  61906. operation: TrigonometryBlockOperations;
  61907. /**
  61908. * Creates a new TrigonometryBlock
  61909. * @param name defines the block name
  61910. */
  61911. constructor(name: string);
  61912. /**
  61913. * Gets the current class name
  61914. * @returns the class name
  61915. */
  61916. getClassName(): string;
  61917. /**
  61918. * Gets the input component
  61919. */
  61920. get input(): NodeMaterialConnectionPoint;
  61921. /**
  61922. * Gets the output component
  61923. */
  61924. get output(): NodeMaterialConnectionPoint;
  61925. protected _buildBlock(state: NodeMaterialBuildState): this;
  61926. serialize(): any;
  61927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61928. protected _dumpPropertiesCode(): string;
  61929. }
  61930. }
  61931. declare module BABYLON {
  61932. /**
  61933. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61934. */
  61935. export class ColorMergerBlock extends NodeMaterialBlock {
  61936. /**
  61937. * Create a new ColorMergerBlock
  61938. * @param name defines the block name
  61939. */
  61940. constructor(name: string);
  61941. /**
  61942. * Gets the current class name
  61943. * @returns the class name
  61944. */
  61945. getClassName(): string;
  61946. /**
  61947. * Gets the rgb component (input)
  61948. */
  61949. get rgbIn(): NodeMaterialConnectionPoint;
  61950. /**
  61951. * Gets the r component (input)
  61952. */
  61953. get r(): NodeMaterialConnectionPoint;
  61954. /**
  61955. * Gets the g component (input)
  61956. */
  61957. get g(): NodeMaterialConnectionPoint;
  61958. /**
  61959. * Gets the b component (input)
  61960. */
  61961. get b(): NodeMaterialConnectionPoint;
  61962. /**
  61963. * Gets the a component (input)
  61964. */
  61965. get a(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the rgba component (output)
  61968. */
  61969. get rgba(): NodeMaterialConnectionPoint;
  61970. /**
  61971. * Gets the rgb component (output)
  61972. */
  61973. get rgbOut(): NodeMaterialConnectionPoint;
  61974. /**
  61975. * Gets the rgb component (output)
  61976. * @deprecated Please use rgbOut instead.
  61977. */
  61978. get rgb(): NodeMaterialConnectionPoint;
  61979. protected _buildBlock(state: NodeMaterialBuildState): this;
  61980. }
  61981. }
  61982. declare module BABYLON {
  61983. /**
  61984. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61985. */
  61986. export class VectorSplitterBlock extends NodeMaterialBlock {
  61987. /**
  61988. * Create a new VectorSplitterBlock
  61989. * @param name defines the block name
  61990. */
  61991. constructor(name: string);
  61992. /**
  61993. * Gets the current class name
  61994. * @returns the class name
  61995. */
  61996. getClassName(): string;
  61997. /**
  61998. * Gets the xyzw component (input)
  61999. */
  62000. get xyzw(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the xyz component (input)
  62003. */
  62004. get xyzIn(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the xy component (input)
  62007. */
  62008. get xyIn(): NodeMaterialConnectionPoint;
  62009. /**
  62010. * Gets the xyz component (output)
  62011. */
  62012. get xyzOut(): NodeMaterialConnectionPoint;
  62013. /**
  62014. * Gets the xy component (output)
  62015. */
  62016. get xyOut(): NodeMaterialConnectionPoint;
  62017. /**
  62018. * Gets the x component (output)
  62019. */
  62020. get x(): NodeMaterialConnectionPoint;
  62021. /**
  62022. * Gets the y component (output)
  62023. */
  62024. get y(): NodeMaterialConnectionPoint;
  62025. /**
  62026. * Gets the z component (output)
  62027. */
  62028. get z(): NodeMaterialConnectionPoint;
  62029. /**
  62030. * Gets the w component (output)
  62031. */
  62032. get w(): NodeMaterialConnectionPoint;
  62033. protected _inputRename(name: string): string;
  62034. protected _outputRename(name: string): string;
  62035. protected _buildBlock(state: NodeMaterialBuildState): this;
  62036. }
  62037. }
  62038. declare module BABYLON {
  62039. /**
  62040. * Block used to lerp between 2 values
  62041. */
  62042. export class LerpBlock extends NodeMaterialBlock {
  62043. /**
  62044. * Creates a new LerpBlock
  62045. * @param name defines the block name
  62046. */
  62047. constructor(name: string);
  62048. /**
  62049. * Gets the current class name
  62050. * @returns the class name
  62051. */
  62052. getClassName(): string;
  62053. /**
  62054. * Gets the left operand input component
  62055. */
  62056. get left(): NodeMaterialConnectionPoint;
  62057. /**
  62058. * Gets the right operand input component
  62059. */
  62060. get right(): NodeMaterialConnectionPoint;
  62061. /**
  62062. * Gets the gradient operand input component
  62063. */
  62064. get gradient(): NodeMaterialConnectionPoint;
  62065. /**
  62066. * Gets the output component
  62067. */
  62068. get output(): NodeMaterialConnectionPoint;
  62069. protected _buildBlock(state: NodeMaterialBuildState): this;
  62070. }
  62071. }
  62072. declare module BABYLON {
  62073. /**
  62074. * Block used to divide 2 vectors
  62075. */
  62076. export class DivideBlock extends NodeMaterialBlock {
  62077. /**
  62078. * Creates a new DivideBlock
  62079. * @param name defines the block name
  62080. */
  62081. constructor(name: string);
  62082. /**
  62083. * Gets the current class name
  62084. * @returns the class name
  62085. */
  62086. getClassName(): string;
  62087. /**
  62088. * Gets the left operand input component
  62089. */
  62090. get left(): NodeMaterialConnectionPoint;
  62091. /**
  62092. * Gets the right operand input component
  62093. */
  62094. get right(): NodeMaterialConnectionPoint;
  62095. /**
  62096. * Gets the output component
  62097. */
  62098. get output(): NodeMaterialConnectionPoint;
  62099. protected _buildBlock(state: NodeMaterialBuildState): this;
  62100. }
  62101. }
  62102. declare module BABYLON {
  62103. /**
  62104. * Block used to subtract 2 vectors
  62105. */
  62106. export class SubtractBlock extends NodeMaterialBlock {
  62107. /**
  62108. * Creates a new SubtractBlock
  62109. * @param name defines the block name
  62110. */
  62111. constructor(name: string);
  62112. /**
  62113. * Gets the current class name
  62114. * @returns the class name
  62115. */
  62116. getClassName(): string;
  62117. /**
  62118. * Gets the left operand input component
  62119. */
  62120. get left(): NodeMaterialConnectionPoint;
  62121. /**
  62122. * Gets the right operand input component
  62123. */
  62124. get right(): NodeMaterialConnectionPoint;
  62125. /**
  62126. * Gets the output component
  62127. */
  62128. get output(): NodeMaterialConnectionPoint;
  62129. protected _buildBlock(state: NodeMaterialBuildState): this;
  62130. }
  62131. }
  62132. declare module BABYLON {
  62133. /**
  62134. * Block used to step a value
  62135. */
  62136. export class StepBlock extends NodeMaterialBlock {
  62137. /**
  62138. * Creates a new StepBlock
  62139. * @param name defines the block name
  62140. */
  62141. constructor(name: string);
  62142. /**
  62143. * Gets the current class name
  62144. * @returns the class name
  62145. */
  62146. getClassName(): string;
  62147. /**
  62148. * Gets the value operand input component
  62149. */
  62150. get value(): NodeMaterialConnectionPoint;
  62151. /**
  62152. * Gets the edge operand input component
  62153. */
  62154. get edge(): NodeMaterialConnectionPoint;
  62155. /**
  62156. * Gets the output component
  62157. */
  62158. get output(): NodeMaterialConnectionPoint;
  62159. protected _buildBlock(state: NodeMaterialBuildState): this;
  62160. }
  62161. }
  62162. declare module BABYLON {
  62163. /**
  62164. * Block used to get the opposite (1 - x) of a value
  62165. */
  62166. export class OneMinusBlock extends NodeMaterialBlock {
  62167. /**
  62168. * Creates a new OneMinusBlock
  62169. * @param name defines the block name
  62170. */
  62171. constructor(name: string);
  62172. /**
  62173. * Gets the current class name
  62174. * @returns the class name
  62175. */
  62176. getClassName(): string;
  62177. /**
  62178. * Gets the input component
  62179. */
  62180. get input(): NodeMaterialConnectionPoint;
  62181. /**
  62182. * Gets the output component
  62183. */
  62184. get output(): NodeMaterialConnectionPoint;
  62185. protected _buildBlock(state: NodeMaterialBuildState): this;
  62186. }
  62187. }
  62188. declare module BABYLON {
  62189. /**
  62190. * Block used to get the view direction
  62191. */
  62192. export class ViewDirectionBlock extends NodeMaterialBlock {
  62193. /**
  62194. * Creates a new ViewDirectionBlock
  62195. * @param name defines the block name
  62196. */
  62197. constructor(name: string);
  62198. /**
  62199. * Gets the current class name
  62200. * @returns the class name
  62201. */
  62202. getClassName(): string;
  62203. /**
  62204. * Gets the world position component
  62205. */
  62206. get worldPosition(): NodeMaterialConnectionPoint;
  62207. /**
  62208. * Gets the camera position component
  62209. */
  62210. get cameraPosition(): NodeMaterialConnectionPoint;
  62211. /**
  62212. * Gets the output component
  62213. */
  62214. get output(): NodeMaterialConnectionPoint;
  62215. autoConfigure(material: NodeMaterial): void;
  62216. protected _buildBlock(state: NodeMaterialBuildState): this;
  62217. }
  62218. }
  62219. declare module BABYLON {
  62220. /**
  62221. * Block used to compute fresnel value
  62222. */
  62223. export class FresnelBlock extends NodeMaterialBlock {
  62224. /**
  62225. * Create a new FresnelBlock
  62226. * @param name defines the block name
  62227. */
  62228. constructor(name: string);
  62229. /**
  62230. * Gets the current class name
  62231. * @returns the class name
  62232. */
  62233. getClassName(): string;
  62234. /**
  62235. * Gets the world normal input component
  62236. */
  62237. get worldNormal(): NodeMaterialConnectionPoint;
  62238. /**
  62239. * Gets the view direction input component
  62240. */
  62241. get viewDirection(): NodeMaterialConnectionPoint;
  62242. /**
  62243. * Gets the bias input component
  62244. */
  62245. get bias(): NodeMaterialConnectionPoint;
  62246. /**
  62247. * Gets the camera (or eye) position component
  62248. */
  62249. get power(): NodeMaterialConnectionPoint;
  62250. /**
  62251. * Gets the fresnel output component
  62252. */
  62253. get fresnel(): NodeMaterialConnectionPoint;
  62254. autoConfigure(material: NodeMaterial): void;
  62255. protected _buildBlock(state: NodeMaterialBuildState): this;
  62256. }
  62257. }
  62258. declare module BABYLON {
  62259. /**
  62260. * Block used to get the max of 2 values
  62261. */
  62262. export class MaxBlock extends NodeMaterialBlock {
  62263. /**
  62264. * Creates a new MaxBlock
  62265. * @param name defines the block name
  62266. */
  62267. constructor(name: string);
  62268. /**
  62269. * Gets the current class name
  62270. * @returns the class name
  62271. */
  62272. getClassName(): string;
  62273. /**
  62274. * Gets the left operand input component
  62275. */
  62276. get left(): NodeMaterialConnectionPoint;
  62277. /**
  62278. * Gets the right operand input component
  62279. */
  62280. get right(): NodeMaterialConnectionPoint;
  62281. /**
  62282. * Gets the output component
  62283. */
  62284. get output(): NodeMaterialConnectionPoint;
  62285. protected _buildBlock(state: NodeMaterialBuildState): this;
  62286. }
  62287. }
  62288. declare module BABYLON {
  62289. /**
  62290. * Block used to get the min of 2 values
  62291. */
  62292. export class MinBlock extends NodeMaterialBlock {
  62293. /**
  62294. * Creates a new MinBlock
  62295. * @param name defines the block name
  62296. */
  62297. constructor(name: string);
  62298. /**
  62299. * Gets the current class name
  62300. * @returns the class name
  62301. */
  62302. getClassName(): string;
  62303. /**
  62304. * Gets the left operand input component
  62305. */
  62306. get left(): NodeMaterialConnectionPoint;
  62307. /**
  62308. * Gets the right operand input component
  62309. */
  62310. get right(): NodeMaterialConnectionPoint;
  62311. /**
  62312. * Gets the output component
  62313. */
  62314. get output(): NodeMaterialConnectionPoint;
  62315. protected _buildBlock(state: NodeMaterialBuildState): this;
  62316. }
  62317. }
  62318. declare module BABYLON {
  62319. /**
  62320. * Block used to get the distance between 2 values
  62321. */
  62322. export class DistanceBlock extends NodeMaterialBlock {
  62323. /**
  62324. * Creates a new DistanceBlock
  62325. * @param name defines the block name
  62326. */
  62327. constructor(name: string);
  62328. /**
  62329. * Gets the current class name
  62330. * @returns the class name
  62331. */
  62332. getClassName(): string;
  62333. /**
  62334. * Gets the left operand input component
  62335. */
  62336. get left(): NodeMaterialConnectionPoint;
  62337. /**
  62338. * Gets the right operand input component
  62339. */
  62340. get right(): NodeMaterialConnectionPoint;
  62341. /**
  62342. * Gets the output component
  62343. */
  62344. get output(): NodeMaterialConnectionPoint;
  62345. protected _buildBlock(state: NodeMaterialBuildState): this;
  62346. }
  62347. }
  62348. declare module BABYLON {
  62349. /**
  62350. * Block used to get the length of a vector
  62351. */
  62352. export class LengthBlock extends NodeMaterialBlock {
  62353. /**
  62354. * Creates a new LengthBlock
  62355. * @param name defines the block name
  62356. */
  62357. constructor(name: string);
  62358. /**
  62359. * Gets the current class name
  62360. * @returns the class name
  62361. */
  62362. getClassName(): string;
  62363. /**
  62364. * Gets the value input component
  62365. */
  62366. get value(): NodeMaterialConnectionPoint;
  62367. /**
  62368. * Gets the output component
  62369. */
  62370. get output(): NodeMaterialConnectionPoint;
  62371. protected _buildBlock(state: NodeMaterialBuildState): this;
  62372. }
  62373. }
  62374. declare module BABYLON {
  62375. /**
  62376. * Block used to get negative version of a value (i.e. x * -1)
  62377. */
  62378. export class NegateBlock extends NodeMaterialBlock {
  62379. /**
  62380. * Creates a new NegateBlock
  62381. * @param name defines the block name
  62382. */
  62383. constructor(name: string);
  62384. /**
  62385. * Gets the current class name
  62386. * @returns the class name
  62387. */
  62388. getClassName(): string;
  62389. /**
  62390. * Gets the value input component
  62391. */
  62392. get value(): NodeMaterialConnectionPoint;
  62393. /**
  62394. * Gets the output component
  62395. */
  62396. get output(): NodeMaterialConnectionPoint;
  62397. protected _buildBlock(state: NodeMaterialBuildState): this;
  62398. }
  62399. }
  62400. declare module BABYLON {
  62401. /**
  62402. * Block used to get the value of the first parameter raised to the power of the second
  62403. */
  62404. export class PowBlock extends NodeMaterialBlock {
  62405. /**
  62406. * Creates a new PowBlock
  62407. * @param name defines the block name
  62408. */
  62409. constructor(name: string);
  62410. /**
  62411. * Gets the current class name
  62412. * @returns the class name
  62413. */
  62414. getClassName(): string;
  62415. /**
  62416. * Gets the value operand input component
  62417. */
  62418. get value(): NodeMaterialConnectionPoint;
  62419. /**
  62420. * Gets the power operand input component
  62421. */
  62422. get power(): NodeMaterialConnectionPoint;
  62423. /**
  62424. * Gets the output component
  62425. */
  62426. get output(): NodeMaterialConnectionPoint;
  62427. protected _buildBlock(state: NodeMaterialBuildState): this;
  62428. }
  62429. }
  62430. declare module BABYLON {
  62431. /**
  62432. * Block used to get a random number
  62433. */
  62434. export class RandomNumberBlock extends NodeMaterialBlock {
  62435. /**
  62436. * Creates a new RandomNumberBlock
  62437. * @param name defines the block name
  62438. */
  62439. constructor(name: string);
  62440. /**
  62441. * Gets the current class name
  62442. * @returns the class name
  62443. */
  62444. getClassName(): string;
  62445. /**
  62446. * Gets the seed input component
  62447. */
  62448. get seed(): NodeMaterialConnectionPoint;
  62449. /**
  62450. * Gets the output component
  62451. */
  62452. get output(): NodeMaterialConnectionPoint;
  62453. protected _buildBlock(state: NodeMaterialBuildState): this;
  62454. }
  62455. }
  62456. declare module BABYLON {
  62457. /**
  62458. * Block used to compute arc tangent of 2 values
  62459. */
  62460. export class ArcTan2Block extends NodeMaterialBlock {
  62461. /**
  62462. * Creates a new ArcTan2Block
  62463. * @param name defines the block name
  62464. */
  62465. constructor(name: string);
  62466. /**
  62467. * Gets the current class name
  62468. * @returns the class name
  62469. */
  62470. getClassName(): string;
  62471. /**
  62472. * Gets the x operand input component
  62473. */
  62474. get x(): NodeMaterialConnectionPoint;
  62475. /**
  62476. * Gets the y operand input component
  62477. */
  62478. get y(): NodeMaterialConnectionPoint;
  62479. /**
  62480. * Gets the output component
  62481. */
  62482. get output(): NodeMaterialConnectionPoint;
  62483. protected _buildBlock(state: NodeMaterialBuildState): this;
  62484. }
  62485. }
  62486. declare module BABYLON {
  62487. /**
  62488. * Block used to smooth step a value
  62489. */
  62490. export class SmoothStepBlock extends NodeMaterialBlock {
  62491. /**
  62492. * Creates a new SmoothStepBlock
  62493. * @param name defines the block name
  62494. */
  62495. constructor(name: string);
  62496. /**
  62497. * Gets the current class name
  62498. * @returns the class name
  62499. */
  62500. getClassName(): string;
  62501. /**
  62502. * Gets the value operand input component
  62503. */
  62504. get value(): NodeMaterialConnectionPoint;
  62505. /**
  62506. * Gets the first edge operand input component
  62507. */
  62508. get edge0(): NodeMaterialConnectionPoint;
  62509. /**
  62510. * Gets the second edge operand input component
  62511. */
  62512. get edge1(): NodeMaterialConnectionPoint;
  62513. /**
  62514. * Gets the output component
  62515. */
  62516. get output(): NodeMaterialConnectionPoint;
  62517. protected _buildBlock(state: NodeMaterialBuildState): this;
  62518. }
  62519. }
  62520. declare module BABYLON {
  62521. /**
  62522. * Block used to get the reciprocal (1 / x) of a value
  62523. */
  62524. export class ReciprocalBlock extends NodeMaterialBlock {
  62525. /**
  62526. * Creates a new ReciprocalBlock
  62527. * @param name defines the block name
  62528. */
  62529. constructor(name: string);
  62530. /**
  62531. * Gets the current class name
  62532. * @returns the class name
  62533. */
  62534. getClassName(): string;
  62535. /**
  62536. * Gets the input component
  62537. */
  62538. get input(): NodeMaterialConnectionPoint;
  62539. /**
  62540. * Gets the output component
  62541. */
  62542. get output(): NodeMaterialConnectionPoint;
  62543. protected _buildBlock(state: NodeMaterialBuildState): this;
  62544. }
  62545. }
  62546. declare module BABYLON {
  62547. /**
  62548. * Block used to replace a color by another one
  62549. */
  62550. export class ReplaceColorBlock extends NodeMaterialBlock {
  62551. /**
  62552. * Creates a new ReplaceColorBlock
  62553. * @param name defines the block name
  62554. */
  62555. constructor(name: string);
  62556. /**
  62557. * Gets the current class name
  62558. * @returns the class name
  62559. */
  62560. getClassName(): string;
  62561. /**
  62562. * Gets the value input component
  62563. */
  62564. get value(): NodeMaterialConnectionPoint;
  62565. /**
  62566. * Gets the reference input component
  62567. */
  62568. get reference(): NodeMaterialConnectionPoint;
  62569. /**
  62570. * Gets the distance input component
  62571. */
  62572. get distance(): NodeMaterialConnectionPoint;
  62573. /**
  62574. * Gets the replacement input component
  62575. */
  62576. get replacement(): NodeMaterialConnectionPoint;
  62577. /**
  62578. * Gets the output component
  62579. */
  62580. get output(): NodeMaterialConnectionPoint;
  62581. protected _buildBlock(state: NodeMaterialBuildState): this;
  62582. }
  62583. }
  62584. declare module BABYLON {
  62585. /**
  62586. * Block used to posterize a value
  62587. * @see https://en.wikipedia.org/wiki/Posterization
  62588. */
  62589. export class PosterizeBlock extends NodeMaterialBlock {
  62590. /**
  62591. * Creates a new PosterizeBlock
  62592. * @param name defines the block name
  62593. */
  62594. constructor(name: string);
  62595. /**
  62596. * Gets the current class name
  62597. * @returns the class name
  62598. */
  62599. getClassName(): string;
  62600. /**
  62601. * Gets the value input component
  62602. */
  62603. get value(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the steps input component
  62606. */
  62607. get steps(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Gets the output component
  62610. */
  62611. get output(): NodeMaterialConnectionPoint;
  62612. protected _buildBlock(state: NodeMaterialBuildState): this;
  62613. }
  62614. }
  62615. declare module BABYLON {
  62616. /**
  62617. * Operations supported by the Wave block
  62618. */
  62619. export enum WaveBlockKind {
  62620. /** SawTooth */
  62621. SawTooth = 0,
  62622. /** Square */
  62623. Square = 1,
  62624. /** Triangle */
  62625. Triangle = 2
  62626. }
  62627. /**
  62628. * Block used to apply wave operation to floats
  62629. */
  62630. export class WaveBlock extends NodeMaterialBlock {
  62631. /**
  62632. * Gets or sets the kibnd of wave to be applied by the block
  62633. */
  62634. kind: WaveBlockKind;
  62635. /**
  62636. * Creates a new WaveBlock
  62637. * @param name defines the block name
  62638. */
  62639. constructor(name: string);
  62640. /**
  62641. * Gets the current class name
  62642. * @returns the class name
  62643. */
  62644. getClassName(): string;
  62645. /**
  62646. * Gets the input component
  62647. */
  62648. get input(): NodeMaterialConnectionPoint;
  62649. /**
  62650. * Gets the output component
  62651. */
  62652. get output(): NodeMaterialConnectionPoint;
  62653. protected _buildBlock(state: NodeMaterialBuildState): this;
  62654. serialize(): any;
  62655. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62656. }
  62657. }
  62658. declare module BABYLON {
  62659. /**
  62660. * Class used to store a color step for the GradientBlock
  62661. */
  62662. export class GradientBlockColorStep {
  62663. /**
  62664. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62665. */
  62666. step: number;
  62667. /**
  62668. * Gets or sets the color associated with this step
  62669. */
  62670. color: Color3;
  62671. /**
  62672. * Creates a new GradientBlockColorStep
  62673. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62674. * @param color defines the color associated with this step
  62675. */
  62676. constructor(
  62677. /**
  62678. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62679. */
  62680. step: number,
  62681. /**
  62682. * Gets or sets the color associated with this step
  62683. */
  62684. color: Color3);
  62685. }
  62686. /**
  62687. * Block used to return a color from a gradient based on an input value between 0 and 1
  62688. */
  62689. export class GradientBlock extends NodeMaterialBlock {
  62690. /**
  62691. * Gets or sets the list of color steps
  62692. */
  62693. colorSteps: GradientBlockColorStep[];
  62694. /**
  62695. * Creates a new GradientBlock
  62696. * @param name defines the block name
  62697. */
  62698. constructor(name: string);
  62699. /**
  62700. * Gets the current class name
  62701. * @returns the class name
  62702. */
  62703. getClassName(): string;
  62704. /**
  62705. * Gets the gradient input component
  62706. */
  62707. get gradient(): NodeMaterialConnectionPoint;
  62708. /**
  62709. * Gets the output component
  62710. */
  62711. get output(): NodeMaterialConnectionPoint;
  62712. private _writeColorConstant;
  62713. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62714. serialize(): any;
  62715. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62716. protected _dumpPropertiesCode(): string;
  62717. }
  62718. }
  62719. declare module BABYLON {
  62720. /**
  62721. * Block used to normalize lerp between 2 values
  62722. */
  62723. export class NLerpBlock extends NodeMaterialBlock {
  62724. /**
  62725. * Creates a new NLerpBlock
  62726. * @param name defines the block name
  62727. */
  62728. constructor(name: string);
  62729. /**
  62730. * Gets the current class name
  62731. * @returns the class name
  62732. */
  62733. getClassName(): string;
  62734. /**
  62735. * Gets the left operand input component
  62736. */
  62737. get left(): NodeMaterialConnectionPoint;
  62738. /**
  62739. * Gets the right operand input component
  62740. */
  62741. get right(): NodeMaterialConnectionPoint;
  62742. /**
  62743. * Gets the gradient operand input component
  62744. */
  62745. get gradient(): NodeMaterialConnectionPoint;
  62746. /**
  62747. * Gets the output component
  62748. */
  62749. get output(): NodeMaterialConnectionPoint;
  62750. protected _buildBlock(state: NodeMaterialBuildState): this;
  62751. }
  62752. }
  62753. declare module BABYLON {
  62754. /**
  62755. * block used to Generate a Worley Noise 3D Noise Pattern
  62756. */
  62757. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62758. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62759. manhattanDistance: boolean;
  62760. /**
  62761. * Creates a new WorleyNoise3DBlock
  62762. * @param name defines the block name
  62763. */
  62764. constructor(name: string);
  62765. /**
  62766. * Gets the current class name
  62767. * @returns the class name
  62768. */
  62769. getClassName(): string;
  62770. /**
  62771. * Gets the seed input component
  62772. */
  62773. get seed(): NodeMaterialConnectionPoint;
  62774. /**
  62775. * Gets the jitter input component
  62776. */
  62777. get jitter(): NodeMaterialConnectionPoint;
  62778. /**
  62779. * Gets the output component
  62780. */
  62781. get output(): NodeMaterialConnectionPoint;
  62782. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62783. /**
  62784. * Exposes the properties to the UI?
  62785. */
  62786. protected _dumpPropertiesCode(): string;
  62787. /**
  62788. * Exposes the properties to the Seralize?
  62789. */
  62790. serialize(): any;
  62791. /**
  62792. * Exposes the properties to the deseralize?
  62793. */
  62794. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62795. }
  62796. }
  62797. declare module BABYLON {
  62798. /**
  62799. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62800. */
  62801. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62802. /**
  62803. * Creates a new SimplexPerlin3DBlock
  62804. * @param name defines the block name
  62805. */
  62806. constructor(name: string);
  62807. /**
  62808. * Gets the current class name
  62809. * @returns the class name
  62810. */
  62811. getClassName(): string;
  62812. /**
  62813. * Gets the seed operand input component
  62814. */
  62815. get seed(): NodeMaterialConnectionPoint;
  62816. /**
  62817. * Gets the output component
  62818. */
  62819. get output(): NodeMaterialConnectionPoint;
  62820. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62821. }
  62822. }
  62823. declare module BABYLON {
  62824. /**
  62825. * Block used to blend normals
  62826. */
  62827. export class NormalBlendBlock extends NodeMaterialBlock {
  62828. /**
  62829. * Creates a new NormalBlendBlock
  62830. * @param name defines the block name
  62831. */
  62832. constructor(name: string);
  62833. /**
  62834. * Gets the current class name
  62835. * @returns the class name
  62836. */
  62837. getClassName(): string;
  62838. /**
  62839. * Gets the first input component
  62840. */
  62841. get normalMap0(): NodeMaterialConnectionPoint;
  62842. /**
  62843. * Gets the second input component
  62844. */
  62845. get normalMap1(): NodeMaterialConnectionPoint;
  62846. /**
  62847. * Gets the output component
  62848. */
  62849. get output(): NodeMaterialConnectionPoint;
  62850. protected _buildBlock(state: NodeMaterialBuildState): this;
  62851. }
  62852. }
  62853. declare module BABYLON {
  62854. /**
  62855. * Block used to rotate a 2d vector by a given angle
  62856. */
  62857. export class Rotate2dBlock extends NodeMaterialBlock {
  62858. /**
  62859. * Creates a new Rotate2dBlock
  62860. * @param name defines the block name
  62861. */
  62862. constructor(name: string);
  62863. /**
  62864. * Gets the current class name
  62865. * @returns the class name
  62866. */
  62867. getClassName(): string;
  62868. /**
  62869. * Gets the input vector
  62870. */
  62871. get input(): NodeMaterialConnectionPoint;
  62872. /**
  62873. * Gets the input angle
  62874. */
  62875. get angle(): NodeMaterialConnectionPoint;
  62876. /**
  62877. * Gets the output component
  62878. */
  62879. get output(): NodeMaterialConnectionPoint;
  62880. autoConfigure(material: NodeMaterial): void;
  62881. protected _buildBlock(state: NodeMaterialBuildState): this;
  62882. }
  62883. }
  62884. declare module BABYLON {
  62885. /**
  62886. * Block used to get the reflected vector from a direction and a normal
  62887. */
  62888. export class ReflectBlock extends NodeMaterialBlock {
  62889. /**
  62890. * Creates a new ReflectBlock
  62891. * @param name defines the block name
  62892. */
  62893. constructor(name: string);
  62894. /**
  62895. * Gets the current class name
  62896. * @returns the class name
  62897. */
  62898. getClassName(): string;
  62899. /**
  62900. * Gets the incident component
  62901. */
  62902. get incident(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the normal component
  62905. */
  62906. get normal(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the output component
  62909. */
  62910. get output(): NodeMaterialConnectionPoint;
  62911. protected _buildBlock(state: NodeMaterialBuildState): this;
  62912. }
  62913. }
  62914. declare module BABYLON {
  62915. /**
  62916. * Block used to get the refracted vector from a direction and a normal
  62917. */
  62918. export class RefractBlock extends NodeMaterialBlock {
  62919. /**
  62920. * Creates a new RefractBlock
  62921. * @param name defines the block name
  62922. */
  62923. constructor(name: string);
  62924. /**
  62925. * Gets the current class name
  62926. * @returns the class name
  62927. */
  62928. getClassName(): string;
  62929. /**
  62930. * Gets the incident component
  62931. */
  62932. get incident(): NodeMaterialConnectionPoint;
  62933. /**
  62934. * Gets the normal component
  62935. */
  62936. get normal(): NodeMaterialConnectionPoint;
  62937. /**
  62938. * Gets the index of refraction component
  62939. */
  62940. get ior(): NodeMaterialConnectionPoint;
  62941. /**
  62942. * Gets the output component
  62943. */
  62944. get output(): NodeMaterialConnectionPoint;
  62945. protected _buildBlock(state: NodeMaterialBuildState): this;
  62946. }
  62947. }
  62948. declare module BABYLON {
  62949. /**
  62950. * Block used to desaturate a color
  62951. */
  62952. export class DesaturateBlock extends NodeMaterialBlock {
  62953. /**
  62954. * Creates a new DesaturateBlock
  62955. * @param name defines the block name
  62956. */
  62957. constructor(name: string);
  62958. /**
  62959. * Gets the current class name
  62960. * @returns the class name
  62961. */
  62962. getClassName(): string;
  62963. /**
  62964. * Gets the color operand input component
  62965. */
  62966. get color(): NodeMaterialConnectionPoint;
  62967. /**
  62968. * Gets the level operand input component
  62969. */
  62970. get level(): NodeMaterialConnectionPoint;
  62971. /**
  62972. * Gets the output component
  62973. */
  62974. get output(): NodeMaterialConnectionPoint;
  62975. protected _buildBlock(state: NodeMaterialBuildState): this;
  62976. }
  62977. }
  62978. declare module BABYLON {
  62979. /**
  62980. * Block used to implement the ambient occlusion module of the PBR material
  62981. */
  62982. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62983. /**
  62984. * Create a new AmbientOcclusionBlock
  62985. * @param name defines the block name
  62986. */
  62987. constructor(name: string);
  62988. /**
  62989. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62990. */
  62991. useAmbientInGrayScale: boolean;
  62992. /**
  62993. * Initialize the block and prepare the context for build
  62994. * @param state defines the state that will be used for the build
  62995. */
  62996. initialize(state: NodeMaterialBuildState): void;
  62997. /**
  62998. * Gets the current class name
  62999. * @returns the class name
  63000. */
  63001. getClassName(): string;
  63002. /**
  63003. * Gets the texture input component
  63004. */
  63005. get texture(): NodeMaterialConnectionPoint;
  63006. /**
  63007. * Gets the texture intensity component
  63008. */
  63009. get intensity(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the direct light intensity input component
  63012. */
  63013. get directLightIntensity(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the ambient occlusion object output component
  63016. */
  63017. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63018. /**
  63019. * Gets the main code of the block (fragment side)
  63020. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63021. * @returns the shader code
  63022. */
  63023. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63024. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63025. protected _buildBlock(state: NodeMaterialBuildState): this;
  63026. protected _dumpPropertiesCode(): string;
  63027. serialize(): any;
  63028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63029. }
  63030. }
  63031. declare module BABYLON {
  63032. /**
  63033. * Block used to implement the reflection module of the PBR material
  63034. */
  63035. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63036. /** @hidden */
  63037. _defineLODReflectionAlpha: string;
  63038. /** @hidden */
  63039. _defineLinearSpecularReflection: string;
  63040. private _vEnvironmentIrradianceName;
  63041. /** @hidden */
  63042. _vReflectionMicrosurfaceInfosName: string;
  63043. /** @hidden */
  63044. _vReflectionInfosName: string;
  63045. /** @hidden */
  63046. _vReflectionFilteringInfoName: string;
  63047. private _scene;
  63048. /**
  63049. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63050. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63051. * It's less burden on the user side in the editor part.
  63052. */
  63053. /** @hidden */
  63054. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63055. /** @hidden */
  63056. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63057. /** @hidden */
  63058. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63059. /**
  63060. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63061. * diffuse part of the IBL.
  63062. */
  63063. useSphericalHarmonics: boolean;
  63064. /**
  63065. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63066. */
  63067. forceIrradianceInFragment: boolean;
  63068. /**
  63069. * Create a new ReflectionBlock
  63070. * @param name defines the block name
  63071. */
  63072. constructor(name: string);
  63073. /**
  63074. * Gets the current class name
  63075. * @returns the class name
  63076. */
  63077. getClassName(): string;
  63078. /**
  63079. * Gets the position input component
  63080. */
  63081. get position(): NodeMaterialConnectionPoint;
  63082. /**
  63083. * Gets the world position input component
  63084. */
  63085. get worldPosition(): NodeMaterialConnectionPoint;
  63086. /**
  63087. * Gets the world normal input component
  63088. */
  63089. get worldNormal(): NodeMaterialConnectionPoint;
  63090. /**
  63091. * Gets the world input component
  63092. */
  63093. get world(): NodeMaterialConnectionPoint;
  63094. /**
  63095. * Gets the camera (or eye) position component
  63096. */
  63097. get cameraPosition(): NodeMaterialConnectionPoint;
  63098. /**
  63099. * Gets the view input component
  63100. */
  63101. get view(): NodeMaterialConnectionPoint;
  63102. /**
  63103. * Gets the color input component
  63104. */
  63105. get color(): NodeMaterialConnectionPoint;
  63106. /**
  63107. * Gets the reflection object output component
  63108. */
  63109. get reflection(): NodeMaterialConnectionPoint;
  63110. /**
  63111. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63112. */
  63113. get hasTexture(): boolean;
  63114. /**
  63115. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63116. */
  63117. get reflectionColor(): string;
  63118. protected _getTexture(): Nullable<BaseTexture>;
  63119. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63120. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63121. /**
  63122. * Gets the code to inject in the vertex shader
  63123. * @param state current state of the node material building
  63124. * @returns the shader code
  63125. */
  63126. handleVertexSide(state: NodeMaterialBuildState): string;
  63127. /**
  63128. * Gets the main code of the block (fragment side)
  63129. * @param state current state of the node material building
  63130. * @param normalVarName name of the existing variable corresponding to the normal
  63131. * @returns the shader code
  63132. */
  63133. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63134. protected _buildBlock(state: NodeMaterialBuildState): this;
  63135. protected _dumpPropertiesCode(): string;
  63136. serialize(): any;
  63137. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63138. }
  63139. }
  63140. declare module BABYLON {
  63141. /**
  63142. * Block used to implement the sheen module of the PBR material
  63143. */
  63144. export class SheenBlock extends NodeMaterialBlock {
  63145. /**
  63146. * Create a new SheenBlock
  63147. * @param name defines the block name
  63148. */
  63149. constructor(name: string);
  63150. /**
  63151. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63152. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63153. * making it easier to setup and tweak the effect
  63154. */
  63155. albedoScaling: boolean;
  63156. /**
  63157. * Defines if the sheen is linked to the sheen color.
  63158. */
  63159. linkSheenWithAlbedo: boolean;
  63160. /**
  63161. * Initialize the block and prepare the context for build
  63162. * @param state defines the state that will be used for the build
  63163. */
  63164. initialize(state: NodeMaterialBuildState): void;
  63165. /**
  63166. * Gets the current class name
  63167. * @returns the class name
  63168. */
  63169. getClassName(): string;
  63170. /**
  63171. * Gets the intensity input component
  63172. */
  63173. get intensity(): NodeMaterialConnectionPoint;
  63174. /**
  63175. * Gets the color input component
  63176. */
  63177. get color(): NodeMaterialConnectionPoint;
  63178. /**
  63179. * Gets the roughness input component
  63180. */
  63181. get roughness(): NodeMaterialConnectionPoint;
  63182. /**
  63183. * Gets the sheen object output component
  63184. */
  63185. get sheen(): NodeMaterialConnectionPoint;
  63186. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63187. /**
  63188. * Gets the main code of the block (fragment side)
  63189. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63190. * @returns the shader code
  63191. */
  63192. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63193. protected _buildBlock(state: NodeMaterialBuildState): this;
  63194. protected _dumpPropertiesCode(): string;
  63195. serialize(): any;
  63196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63197. }
  63198. }
  63199. declare module BABYLON {
  63200. /**
  63201. * Block used to implement the reflectivity module of the PBR material
  63202. */
  63203. export class ReflectivityBlock extends NodeMaterialBlock {
  63204. private _metallicReflectanceColor;
  63205. private _metallicF0Factor;
  63206. /** @hidden */
  63207. _vMetallicReflectanceFactorsName: string;
  63208. /**
  63209. * The property below is set by the main PBR block prior to calling methods of this class.
  63210. */
  63211. /** @hidden */
  63212. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63213. /**
  63214. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63215. */
  63216. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63217. /**
  63218. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63219. */
  63220. useMetallnessFromMetallicTextureBlue: boolean;
  63221. /**
  63222. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63223. */
  63224. useRoughnessFromMetallicTextureAlpha: boolean;
  63225. /**
  63226. * Specifies if the metallic texture contains the roughness information in its green channel.
  63227. */
  63228. useRoughnessFromMetallicTextureGreen: boolean;
  63229. /**
  63230. * Create a new ReflectivityBlock
  63231. * @param name defines the block name
  63232. */
  63233. constructor(name: string);
  63234. /**
  63235. * Initialize the block and prepare the context for build
  63236. * @param state defines the state that will be used for the build
  63237. */
  63238. initialize(state: NodeMaterialBuildState): void;
  63239. /**
  63240. * Gets the current class name
  63241. * @returns the class name
  63242. */
  63243. getClassName(): string;
  63244. /**
  63245. * Gets the metallic input component
  63246. */
  63247. get metallic(): NodeMaterialConnectionPoint;
  63248. /**
  63249. * Gets the roughness input component
  63250. */
  63251. get roughness(): NodeMaterialConnectionPoint;
  63252. /**
  63253. * Gets the texture input component
  63254. */
  63255. get texture(): NodeMaterialConnectionPoint;
  63256. /**
  63257. * Gets the reflectivity object output component
  63258. */
  63259. get reflectivity(): NodeMaterialConnectionPoint;
  63260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63261. /**
  63262. * Gets the main code of the block (fragment side)
  63263. * @param state current state of the node material building
  63264. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63265. * @returns the shader code
  63266. */
  63267. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63268. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63269. protected _buildBlock(state: NodeMaterialBuildState): this;
  63270. protected _dumpPropertiesCode(): string;
  63271. serialize(): any;
  63272. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63273. }
  63274. }
  63275. declare module BABYLON {
  63276. /**
  63277. * Block used to implement the anisotropy module of the PBR material
  63278. */
  63279. export class AnisotropyBlock extends NodeMaterialBlock {
  63280. /**
  63281. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63282. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63283. * It's less burden on the user side in the editor part.
  63284. */
  63285. /** @hidden */
  63286. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63287. /** @hidden */
  63288. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63289. /**
  63290. * Create a new AnisotropyBlock
  63291. * @param name defines the block name
  63292. */
  63293. constructor(name: string);
  63294. /**
  63295. * Initialize the block and prepare the context for build
  63296. * @param state defines the state that will be used for the build
  63297. */
  63298. initialize(state: NodeMaterialBuildState): void;
  63299. /**
  63300. * Gets the current class name
  63301. * @returns the class name
  63302. */
  63303. getClassName(): string;
  63304. /**
  63305. * Gets the intensity input component
  63306. */
  63307. get intensity(): NodeMaterialConnectionPoint;
  63308. /**
  63309. * Gets the direction input component
  63310. */
  63311. get direction(): NodeMaterialConnectionPoint;
  63312. /**
  63313. * Gets the texture input component
  63314. */
  63315. get texture(): NodeMaterialConnectionPoint;
  63316. /**
  63317. * Gets the uv input component
  63318. */
  63319. get uv(): NodeMaterialConnectionPoint;
  63320. /**
  63321. * Gets the worldTangent input component
  63322. */
  63323. get worldTangent(): NodeMaterialConnectionPoint;
  63324. /**
  63325. * Gets the anisotropy object output component
  63326. */
  63327. get anisotropy(): NodeMaterialConnectionPoint;
  63328. private _generateTBNSpace;
  63329. /**
  63330. * Gets the main code of the block (fragment side)
  63331. * @param state current state of the node material building
  63332. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63333. * @returns the shader code
  63334. */
  63335. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63336. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63337. protected _buildBlock(state: NodeMaterialBuildState): this;
  63338. }
  63339. }
  63340. declare module BABYLON {
  63341. /**
  63342. * Block used to implement the clear coat module of the PBR material
  63343. */
  63344. export class ClearCoatBlock extends NodeMaterialBlock {
  63345. private _scene;
  63346. /**
  63347. * Create a new ClearCoatBlock
  63348. * @param name defines the block name
  63349. */
  63350. constructor(name: string);
  63351. /**
  63352. * Initialize the block and prepare the context for build
  63353. * @param state defines the state that will be used for the build
  63354. */
  63355. initialize(state: NodeMaterialBuildState): void;
  63356. /**
  63357. * Gets the current class name
  63358. * @returns the class name
  63359. */
  63360. getClassName(): string;
  63361. /**
  63362. * Gets the intensity input component
  63363. */
  63364. get intensity(): NodeMaterialConnectionPoint;
  63365. /**
  63366. * Gets the roughness input component
  63367. */
  63368. get roughness(): NodeMaterialConnectionPoint;
  63369. /**
  63370. * Gets the ior input component
  63371. */
  63372. get ior(): NodeMaterialConnectionPoint;
  63373. /**
  63374. * Gets the texture input component
  63375. */
  63376. get texture(): NodeMaterialConnectionPoint;
  63377. /**
  63378. * Gets the bump texture input component
  63379. */
  63380. get bumpTexture(): NodeMaterialConnectionPoint;
  63381. /**
  63382. * Gets the uv input component
  63383. */
  63384. get uv(): NodeMaterialConnectionPoint;
  63385. /**
  63386. * Gets the tint color input component
  63387. */
  63388. get tintColor(): NodeMaterialConnectionPoint;
  63389. /**
  63390. * Gets the tint "at distance" input component
  63391. */
  63392. get tintAtDistance(): NodeMaterialConnectionPoint;
  63393. /**
  63394. * Gets the tint thickness input component
  63395. */
  63396. get tintThickness(): NodeMaterialConnectionPoint;
  63397. /**
  63398. * Gets the world tangent input component
  63399. */
  63400. get worldTangent(): NodeMaterialConnectionPoint;
  63401. /**
  63402. * Gets the clear coat object output component
  63403. */
  63404. get clearcoat(): NodeMaterialConnectionPoint;
  63405. autoConfigure(material: NodeMaterial): void;
  63406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63407. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63408. private _generateTBNSpace;
  63409. /**
  63410. * Gets the main code of the block (fragment side)
  63411. * @param state current state of the node material building
  63412. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63413. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63414. * @param worldPosVarName name of the variable holding the world position
  63415. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63416. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63417. * @param worldNormalVarName name of the variable holding the world normal
  63418. * @returns the shader code
  63419. */
  63420. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63421. protected _buildBlock(state: NodeMaterialBuildState): this;
  63422. }
  63423. }
  63424. declare module BABYLON {
  63425. /**
  63426. * Block used to implement the sub surface module of the PBR material
  63427. */
  63428. export class SubSurfaceBlock extends NodeMaterialBlock {
  63429. /**
  63430. * Create a new SubSurfaceBlock
  63431. * @param name defines the block name
  63432. */
  63433. constructor(name: string);
  63434. /**
  63435. * Stores the intensity of the different subsurface effects in the thickness texture.
  63436. * * the green channel is the translucency intensity.
  63437. * * the blue channel is the scattering intensity.
  63438. * * the alpha channel is the refraction intensity.
  63439. */
  63440. useMaskFromThicknessTexture: boolean;
  63441. /**
  63442. * Initialize the block and prepare the context for build
  63443. * @param state defines the state that will be used for the build
  63444. */
  63445. initialize(state: NodeMaterialBuildState): void;
  63446. /**
  63447. * Gets the current class name
  63448. * @returns the class name
  63449. */
  63450. getClassName(): string;
  63451. /**
  63452. * Gets the min thickness input component
  63453. */
  63454. get minThickness(): NodeMaterialConnectionPoint;
  63455. /**
  63456. * Gets the max thickness input component
  63457. */
  63458. get maxThickness(): NodeMaterialConnectionPoint;
  63459. /**
  63460. * Gets the thickness texture component
  63461. */
  63462. get thicknessTexture(): NodeMaterialConnectionPoint;
  63463. /**
  63464. * Gets the tint color input component
  63465. */
  63466. get tintColor(): NodeMaterialConnectionPoint;
  63467. /**
  63468. * Gets the translucency intensity input component
  63469. */
  63470. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63471. /**
  63472. * Gets the translucency diffusion distance input component
  63473. */
  63474. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63475. /**
  63476. * Gets the refraction object parameters
  63477. */
  63478. get refraction(): NodeMaterialConnectionPoint;
  63479. /**
  63480. * Gets the sub surface object output component
  63481. */
  63482. get subsurface(): NodeMaterialConnectionPoint;
  63483. autoConfigure(material: NodeMaterial): void;
  63484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63485. /**
  63486. * Gets the main code of the block (fragment side)
  63487. * @param state current state of the node material building
  63488. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63489. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63490. * @param worldPosVarName name of the variable holding the world position
  63491. * @returns the shader code
  63492. */
  63493. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63494. protected _buildBlock(state: NodeMaterialBuildState): this;
  63495. }
  63496. }
  63497. declare module BABYLON {
  63498. /**
  63499. * Block used to implement the PBR metallic/roughness model
  63500. */
  63501. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63502. /**
  63503. * Gets or sets the light associated with this block
  63504. */
  63505. light: Nullable<Light>;
  63506. private _lightId;
  63507. private _scene;
  63508. private _environmentBRDFTexture;
  63509. private _environmentBrdfSamplerName;
  63510. private _vNormalWName;
  63511. private _invertNormalName;
  63512. /**
  63513. * Create a new ReflectionBlock
  63514. * @param name defines the block name
  63515. */
  63516. constructor(name: string);
  63517. /**
  63518. * Intensity of the direct lights e.g. the four lights available in your scene.
  63519. * This impacts both the direct diffuse and specular highlights.
  63520. */
  63521. directIntensity: number;
  63522. /**
  63523. * Intensity of the environment e.g. how much the environment will light the object
  63524. * either through harmonics for rough material or through the refelction for shiny ones.
  63525. */
  63526. environmentIntensity: number;
  63527. /**
  63528. * This is a special control allowing the reduction of the specular highlights coming from the
  63529. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63530. */
  63531. specularIntensity: number;
  63532. /**
  63533. * Defines the falloff type used in this material.
  63534. * It by default is Physical.
  63535. */
  63536. lightFalloff: number;
  63537. /**
  63538. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63539. */
  63540. useAlphaFromAlbedoTexture: boolean;
  63541. /**
  63542. * Specifies that alpha test should be used
  63543. */
  63544. useAlphaTest: boolean;
  63545. /**
  63546. * Defines the alpha limits in alpha test mode.
  63547. */
  63548. alphaTestCutoff: number;
  63549. /**
  63550. * Specifies that alpha blending should be used
  63551. */
  63552. useAlphaBlending: boolean;
  63553. /**
  63554. * Defines if the alpha value should be determined via the rgb values.
  63555. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63556. */
  63557. opacityRGB: boolean;
  63558. /**
  63559. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63560. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63561. */
  63562. useRadianceOverAlpha: boolean;
  63563. /**
  63564. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63565. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63566. */
  63567. useSpecularOverAlpha: boolean;
  63568. /**
  63569. * Enables specular anti aliasing in the PBR shader.
  63570. * It will both interacts on the Geometry for analytical and IBL lighting.
  63571. * It also prefilter the roughness map based on the bump values.
  63572. */
  63573. enableSpecularAntiAliasing: boolean;
  63574. /**
  63575. * Enables realtime filtering on the texture.
  63576. */
  63577. realTimeFiltering: boolean;
  63578. /**
  63579. * Quality switch for realtime filtering
  63580. */
  63581. realTimeFilteringQuality: number;
  63582. /**
  63583. * Defines if the material uses energy conservation.
  63584. */
  63585. useEnergyConservation: boolean;
  63586. /**
  63587. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63588. * too much the area relying on ambient texture to define their ambient occlusion.
  63589. */
  63590. useRadianceOcclusion: boolean;
  63591. /**
  63592. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63593. * makes the reflect vector face the model (under horizon).
  63594. */
  63595. useHorizonOcclusion: boolean;
  63596. /**
  63597. * If set to true, no lighting calculations will be applied.
  63598. */
  63599. unlit: boolean;
  63600. /**
  63601. * Force normal to face away from face.
  63602. */
  63603. forceNormalForward: boolean;
  63604. /**
  63605. * Defines the material debug mode.
  63606. * It helps seeing only some components of the material while troubleshooting.
  63607. */
  63608. debugMode: number;
  63609. /**
  63610. * Specify from where on screen the debug mode should start.
  63611. * The value goes from -1 (full screen) to 1 (not visible)
  63612. * It helps with side by side comparison against the final render
  63613. * This defaults to 0
  63614. */
  63615. debugLimit: number;
  63616. /**
  63617. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63618. * You can use the factor to better multiply the final value.
  63619. */
  63620. debugFactor: number;
  63621. /**
  63622. * Initialize the block and prepare the context for build
  63623. * @param state defines the state that will be used for the build
  63624. */
  63625. initialize(state: NodeMaterialBuildState): void;
  63626. /**
  63627. * Gets the current class name
  63628. * @returns the class name
  63629. */
  63630. getClassName(): string;
  63631. /**
  63632. * Gets the world position input component
  63633. */
  63634. get worldPosition(): NodeMaterialConnectionPoint;
  63635. /**
  63636. * Gets the world normal input component
  63637. */
  63638. get worldNormal(): NodeMaterialConnectionPoint;
  63639. /**
  63640. * Gets the perturbed normal input component
  63641. */
  63642. get perturbedNormal(): NodeMaterialConnectionPoint;
  63643. /**
  63644. * Gets the camera position input component
  63645. */
  63646. get cameraPosition(): NodeMaterialConnectionPoint;
  63647. /**
  63648. * Gets the base color input component
  63649. */
  63650. get baseColor(): NodeMaterialConnectionPoint;
  63651. /**
  63652. * Gets the opacity texture input component
  63653. */
  63654. get opacityTexture(): NodeMaterialConnectionPoint;
  63655. /**
  63656. * Gets the ambient color input component
  63657. */
  63658. get ambientColor(): NodeMaterialConnectionPoint;
  63659. /**
  63660. * Gets the reflectivity object parameters
  63661. */
  63662. get reflectivity(): NodeMaterialConnectionPoint;
  63663. /**
  63664. * Gets the ambient occlusion object parameters
  63665. */
  63666. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63667. /**
  63668. * Gets the reflection object parameters
  63669. */
  63670. get reflection(): NodeMaterialConnectionPoint;
  63671. /**
  63672. * Gets the sheen object parameters
  63673. */
  63674. get sheen(): NodeMaterialConnectionPoint;
  63675. /**
  63676. * Gets the clear coat object parameters
  63677. */
  63678. get clearcoat(): NodeMaterialConnectionPoint;
  63679. /**
  63680. * Gets the sub surface object parameters
  63681. */
  63682. get subsurface(): NodeMaterialConnectionPoint;
  63683. /**
  63684. * Gets the anisotropy object parameters
  63685. */
  63686. get anisotropy(): NodeMaterialConnectionPoint;
  63687. /**
  63688. * Gets the ambient output component
  63689. */
  63690. get ambient(): NodeMaterialConnectionPoint;
  63691. /**
  63692. * Gets the diffuse output component
  63693. */
  63694. get diffuse(): NodeMaterialConnectionPoint;
  63695. /**
  63696. * Gets the specular output component
  63697. */
  63698. get specular(): NodeMaterialConnectionPoint;
  63699. /**
  63700. * Gets the sheen output component
  63701. */
  63702. get sheenDir(): NodeMaterialConnectionPoint;
  63703. /**
  63704. * Gets the clear coat output component
  63705. */
  63706. get clearcoatDir(): NodeMaterialConnectionPoint;
  63707. /**
  63708. * Gets the indirect diffuse output component
  63709. */
  63710. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63711. /**
  63712. * Gets the indirect specular output component
  63713. */
  63714. get specularIndirect(): NodeMaterialConnectionPoint;
  63715. /**
  63716. * Gets the indirect sheen output component
  63717. */
  63718. get sheenIndirect(): NodeMaterialConnectionPoint;
  63719. /**
  63720. * Gets the indirect clear coat output component
  63721. */
  63722. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63723. /**
  63724. * Gets the refraction output component
  63725. */
  63726. get refraction(): NodeMaterialConnectionPoint;
  63727. /**
  63728. * Gets the global lighting output component
  63729. */
  63730. get lighting(): NodeMaterialConnectionPoint;
  63731. /**
  63732. * Gets the shadow output component
  63733. */
  63734. get shadow(): NodeMaterialConnectionPoint;
  63735. /**
  63736. * Gets the alpha output component
  63737. */
  63738. get alpha(): NodeMaterialConnectionPoint;
  63739. autoConfigure(material: NodeMaterial): void;
  63740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63741. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63742. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63743. private _injectVertexCode;
  63744. /**
  63745. * Gets the code corresponding to the albedo/opacity module
  63746. * @returns the shader code
  63747. */
  63748. getAlbedoOpacityCode(): string;
  63749. protected _buildBlock(state: NodeMaterialBuildState): this;
  63750. protected _dumpPropertiesCode(): string;
  63751. serialize(): any;
  63752. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63753. }
  63754. }
  63755. declare module BABYLON {
  63756. /**
  63757. * Block used to compute value of one parameter modulo another
  63758. */
  63759. export class ModBlock extends NodeMaterialBlock {
  63760. /**
  63761. * Creates a new ModBlock
  63762. * @param name defines the block name
  63763. */
  63764. constructor(name: string);
  63765. /**
  63766. * Gets the current class name
  63767. * @returns the class name
  63768. */
  63769. getClassName(): string;
  63770. /**
  63771. * Gets the left operand input component
  63772. */
  63773. get left(): NodeMaterialConnectionPoint;
  63774. /**
  63775. * Gets the right operand input component
  63776. */
  63777. get right(): NodeMaterialConnectionPoint;
  63778. /**
  63779. * Gets the output component
  63780. */
  63781. get output(): NodeMaterialConnectionPoint;
  63782. protected _buildBlock(state: NodeMaterialBuildState): this;
  63783. }
  63784. }
  63785. declare module BABYLON {
  63786. /**
  63787. * Helper class to push actions to a pool of workers.
  63788. */
  63789. export class WorkerPool implements IDisposable {
  63790. private _workerInfos;
  63791. private _pendingActions;
  63792. /**
  63793. * Constructor
  63794. * @param workers Array of workers to use for actions
  63795. */
  63796. constructor(workers: Array<Worker>);
  63797. /**
  63798. * Terminates all workers and clears any pending actions.
  63799. */
  63800. dispose(): void;
  63801. /**
  63802. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63803. * pended until a worker has completed its action.
  63804. * @param action The action to perform. Call onComplete when the action is complete.
  63805. */
  63806. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63807. private _execute;
  63808. }
  63809. }
  63810. declare module BABYLON {
  63811. /**
  63812. * Configuration for Draco compression
  63813. */
  63814. export interface IDracoCompressionConfiguration {
  63815. /**
  63816. * Configuration for the decoder.
  63817. */
  63818. decoder: {
  63819. /**
  63820. * The url to the WebAssembly module.
  63821. */
  63822. wasmUrl?: string;
  63823. /**
  63824. * The url to the WebAssembly binary.
  63825. */
  63826. wasmBinaryUrl?: string;
  63827. /**
  63828. * The url to the fallback JavaScript module.
  63829. */
  63830. fallbackUrl?: string;
  63831. };
  63832. }
  63833. /**
  63834. * Draco compression (https://google.github.io/draco/)
  63835. *
  63836. * This class wraps the Draco module.
  63837. *
  63838. * **Encoder**
  63839. *
  63840. * The encoder is not currently implemented.
  63841. *
  63842. * **Decoder**
  63843. *
  63844. * 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.
  63845. *
  63846. * To update the configuration, use the following code:
  63847. * ```javascript
  63848. * DracoCompression.Configuration = {
  63849. * decoder: {
  63850. * wasmUrl: "<url to the WebAssembly library>",
  63851. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63852. * fallbackUrl: "<url to the fallback JavaScript library>",
  63853. * }
  63854. * };
  63855. * ```
  63856. *
  63857. * 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.
  63858. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63859. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63860. *
  63861. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63862. * ```javascript
  63863. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63864. * ```
  63865. *
  63866. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63867. */
  63868. export class DracoCompression implements IDisposable {
  63869. private _workerPoolPromise?;
  63870. private _decoderModulePromise?;
  63871. /**
  63872. * The configuration. Defaults to the following urls:
  63873. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63874. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63875. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63876. */
  63877. static Configuration: IDracoCompressionConfiguration;
  63878. /**
  63879. * Returns true if the decoder configuration is available.
  63880. */
  63881. static get DecoderAvailable(): boolean;
  63882. /**
  63883. * Default number of workers to create when creating the draco compression object.
  63884. */
  63885. static DefaultNumWorkers: number;
  63886. private static GetDefaultNumWorkers;
  63887. private static _Default;
  63888. /**
  63889. * Default instance for the draco compression object.
  63890. */
  63891. static get Default(): DracoCompression;
  63892. /**
  63893. * Constructor
  63894. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63895. */
  63896. constructor(numWorkers?: number);
  63897. /**
  63898. * Stop all async operations and release resources.
  63899. */
  63900. dispose(): void;
  63901. /**
  63902. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63903. * @returns a promise that resolves when ready
  63904. */
  63905. whenReadyAsync(): Promise<void>;
  63906. /**
  63907. * Decode Draco compressed mesh data to vertex data.
  63908. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63909. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63910. * @returns A promise that resolves with the decoded vertex data
  63911. */
  63912. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63913. [kind: string]: number;
  63914. }): Promise<VertexData>;
  63915. }
  63916. }
  63917. declare module BABYLON {
  63918. /**
  63919. * Class for building Constructive Solid Geometry
  63920. */
  63921. export class CSG {
  63922. private polygons;
  63923. /**
  63924. * The world matrix
  63925. */
  63926. matrix: Matrix;
  63927. /**
  63928. * Stores the position
  63929. */
  63930. position: Vector3;
  63931. /**
  63932. * Stores the rotation
  63933. */
  63934. rotation: Vector3;
  63935. /**
  63936. * Stores the rotation quaternion
  63937. */
  63938. rotationQuaternion: Nullable<Quaternion>;
  63939. /**
  63940. * Stores the scaling vector
  63941. */
  63942. scaling: Vector3;
  63943. /**
  63944. * Convert the Mesh to CSG
  63945. * @param mesh The Mesh to convert to CSG
  63946. * @returns A new CSG from the Mesh
  63947. */
  63948. static FromMesh(mesh: Mesh): CSG;
  63949. /**
  63950. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63951. * @param polygons Polygons used to construct a CSG solid
  63952. */
  63953. private static FromPolygons;
  63954. /**
  63955. * Clones, or makes a deep copy, of the CSG
  63956. * @returns A new CSG
  63957. */
  63958. clone(): CSG;
  63959. /**
  63960. * Unions this CSG with another CSG
  63961. * @param csg The CSG to union against this CSG
  63962. * @returns The unioned CSG
  63963. */
  63964. union(csg: CSG): CSG;
  63965. /**
  63966. * Unions this CSG with another CSG in place
  63967. * @param csg The CSG to union against this CSG
  63968. */
  63969. unionInPlace(csg: CSG): void;
  63970. /**
  63971. * Subtracts this CSG with another CSG
  63972. * @param csg The CSG to subtract against this CSG
  63973. * @returns A new CSG
  63974. */
  63975. subtract(csg: CSG): CSG;
  63976. /**
  63977. * Subtracts this CSG with another CSG in place
  63978. * @param csg The CSG to subtact against this CSG
  63979. */
  63980. subtractInPlace(csg: CSG): void;
  63981. /**
  63982. * Intersect this CSG with another CSG
  63983. * @param csg The CSG to intersect against this CSG
  63984. * @returns A new CSG
  63985. */
  63986. intersect(csg: CSG): CSG;
  63987. /**
  63988. * Intersects this CSG with another CSG in place
  63989. * @param csg The CSG to intersect against this CSG
  63990. */
  63991. intersectInPlace(csg: CSG): void;
  63992. /**
  63993. * Return a new CSG solid with solid and empty space switched. This solid is
  63994. * not modified.
  63995. * @returns A new CSG solid with solid and empty space switched
  63996. */
  63997. inverse(): CSG;
  63998. /**
  63999. * Inverses the CSG in place
  64000. */
  64001. inverseInPlace(): void;
  64002. /**
  64003. * This is used to keep meshes transformations so they can be restored
  64004. * when we build back a Babylon Mesh
  64005. * NB : All CSG operations are performed in world coordinates
  64006. * @param csg The CSG to copy the transform attributes from
  64007. * @returns This CSG
  64008. */
  64009. copyTransformAttributes(csg: CSG): CSG;
  64010. /**
  64011. * Build Raw mesh from CSG
  64012. * Coordinates here are in world space
  64013. * @param name The name of the mesh geometry
  64014. * @param scene The Scene
  64015. * @param keepSubMeshes Specifies if the submeshes should be kept
  64016. * @returns A new Mesh
  64017. */
  64018. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64019. /**
  64020. * Build Mesh from CSG taking material and transforms into account
  64021. * @param name The name of the Mesh
  64022. * @param material The material of the Mesh
  64023. * @param scene The Scene
  64024. * @param keepSubMeshes Specifies if submeshes should be kept
  64025. * @returns The new Mesh
  64026. */
  64027. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64028. }
  64029. }
  64030. declare module BABYLON {
  64031. /**
  64032. * Class used to create a trail following a mesh
  64033. */
  64034. export class TrailMesh extends Mesh {
  64035. private _generator;
  64036. private _autoStart;
  64037. private _running;
  64038. private _diameter;
  64039. private _length;
  64040. private _sectionPolygonPointsCount;
  64041. private _sectionVectors;
  64042. private _sectionNormalVectors;
  64043. private _beforeRenderObserver;
  64044. /**
  64045. * @constructor
  64046. * @param name The value used by scene.getMeshByName() to do a lookup.
  64047. * @param generator The mesh or transform node to generate a trail.
  64048. * @param scene The scene to add this mesh to.
  64049. * @param diameter Diameter of trailing mesh. Default is 1.
  64050. * @param length Length of trailing mesh. Default is 60.
  64051. * @param autoStart Automatically start trailing mesh. Default true.
  64052. */
  64053. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64054. /**
  64055. * "TrailMesh"
  64056. * @returns "TrailMesh"
  64057. */
  64058. getClassName(): string;
  64059. private _createMesh;
  64060. /**
  64061. * Start trailing mesh.
  64062. */
  64063. start(): void;
  64064. /**
  64065. * Stop trailing mesh.
  64066. */
  64067. stop(): void;
  64068. /**
  64069. * Update trailing mesh geometry.
  64070. */
  64071. update(): void;
  64072. /**
  64073. * Returns a new TrailMesh object.
  64074. * @param name is a string, the name given to the new mesh
  64075. * @param newGenerator use new generator object for cloned trail mesh
  64076. * @returns a new mesh
  64077. */
  64078. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64079. /**
  64080. * Serializes this trail mesh
  64081. * @param serializationObject object to write serialization to
  64082. */
  64083. serialize(serializationObject: any): void;
  64084. /**
  64085. * Parses a serialized trail mesh
  64086. * @param parsedMesh the serialized mesh
  64087. * @param scene the scene to create the trail mesh in
  64088. * @returns the created trail mesh
  64089. */
  64090. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64091. }
  64092. }
  64093. declare module BABYLON {
  64094. /**
  64095. * Class containing static functions to help procedurally build meshes
  64096. */
  64097. export class TiledBoxBuilder {
  64098. /**
  64099. * Creates a box mesh
  64100. * 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)
  64101. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64103. * * 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
  64104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64105. * @param name defines the name of the mesh
  64106. * @param options defines the options used to create the mesh
  64107. * @param scene defines the hosting scene
  64108. * @returns the box mesh
  64109. */
  64110. static CreateTiledBox(name: string, options: {
  64111. pattern?: number;
  64112. width?: number;
  64113. height?: number;
  64114. depth?: number;
  64115. tileSize?: number;
  64116. tileWidth?: number;
  64117. tileHeight?: number;
  64118. alignHorizontal?: number;
  64119. alignVertical?: number;
  64120. faceUV?: Vector4[];
  64121. faceColors?: Color4[];
  64122. sideOrientation?: number;
  64123. updatable?: boolean;
  64124. }, scene?: Nullable<Scene>): Mesh;
  64125. }
  64126. }
  64127. declare module BABYLON {
  64128. /**
  64129. * Class containing static functions to help procedurally build meshes
  64130. */
  64131. export class TorusKnotBuilder {
  64132. /**
  64133. * Creates a torus knot mesh
  64134. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64135. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64136. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64137. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64139. * * 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
  64140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64141. * @param name defines the name of the mesh
  64142. * @param options defines the options used to create the mesh
  64143. * @param scene defines the hosting scene
  64144. * @returns the torus knot mesh
  64145. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64146. */
  64147. static CreateTorusKnot(name: string, options: {
  64148. radius?: number;
  64149. tube?: number;
  64150. radialSegments?: number;
  64151. tubularSegments?: number;
  64152. p?: number;
  64153. q?: number;
  64154. updatable?: boolean;
  64155. sideOrientation?: number;
  64156. frontUVs?: Vector4;
  64157. backUVs?: Vector4;
  64158. }, scene: any): Mesh;
  64159. }
  64160. }
  64161. declare module BABYLON {
  64162. /**
  64163. * Polygon
  64164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64165. */
  64166. export class Polygon {
  64167. /**
  64168. * Creates a rectangle
  64169. * @param xmin bottom X coord
  64170. * @param ymin bottom Y coord
  64171. * @param xmax top X coord
  64172. * @param ymax top Y coord
  64173. * @returns points that make the resulting rectation
  64174. */
  64175. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64176. /**
  64177. * Creates a circle
  64178. * @param radius radius of circle
  64179. * @param cx scale in x
  64180. * @param cy scale in y
  64181. * @param numberOfSides number of sides that make up the circle
  64182. * @returns points that make the resulting circle
  64183. */
  64184. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64185. /**
  64186. * Creates a polygon from input string
  64187. * @param input Input polygon data
  64188. * @returns the parsed points
  64189. */
  64190. static Parse(input: string): Vector2[];
  64191. /**
  64192. * Starts building a polygon from x and y coordinates
  64193. * @param x x coordinate
  64194. * @param y y coordinate
  64195. * @returns the started path2
  64196. */
  64197. static StartingAt(x: number, y: number): Path2;
  64198. }
  64199. /**
  64200. * Builds a polygon
  64201. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64202. */
  64203. export class PolygonMeshBuilder {
  64204. private _points;
  64205. private _outlinepoints;
  64206. private _holes;
  64207. private _name;
  64208. private _scene;
  64209. private _epoints;
  64210. private _eholes;
  64211. private _addToepoint;
  64212. /**
  64213. * Babylon reference to the earcut plugin.
  64214. */
  64215. bjsEarcut: any;
  64216. /**
  64217. * Creates a PolygonMeshBuilder
  64218. * @param name name of the builder
  64219. * @param contours Path of the polygon
  64220. * @param scene scene to add to when creating the mesh
  64221. * @param earcutInjection can be used to inject your own earcut reference
  64222. */
  64223. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64224. /**
  64225. * Adds a whole within the polygon
  64226. * @param hole Array of points defining the hole
  64227. * @returns this
  64228. */
  64229. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64230. /**
  64231. * Creates the polygon
  64232. * @param updatable If the mesh should be updatable
  64233. * @param depth The depth of the mesh created
  64234. * @returns the created mesh
  64235. */
  64236. build(updatable?: boolean, depth?: number): Mesh;
  64237. /**
  64238. * Creates the polygon
  64239. * @param depth The depth of the mesh created
  64240. * @returns the created VertexData
  64241. */
  64242. buildVertexData(depth?: number): VertexData;
  64243. /**
  64244. * Adds a side to the polygon
  64245. * @param positions points that make the polygon
  64246. * @param normals normals of the polygon
  64247. * @param uvs uvs of the polygon
  64248. * @param indices indices of the polygon
  64249. * @param bounds bounds of the polygon
  64250. * @param points points of the polygon
  64251. * @param depth depth of the polygon
  64252. * @param flip flip of the polygon
  64253. */
  64254. private addSide;
  64255. }
  64256. }
  64257. declare module BABYLON {
  64258. /**
  64259. * Class containing static functions to help procedurally build meshes
  64260. */
  64261. export class PolygonBuilder {
  64262. /**
  64263. * Creates a polygon mesh
  64264. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64265. * * 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
  64266. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64268. * * 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)
  64269. * * Remember you can only change the shape positions, not their number when updating a polygon
  64270. * @param name defines the name of the mesh
  64271. * @param options defines the options used to create the mesh
  64272. * @param scene defines the hosting scene
  64273. * @param earcutInjection can be used to inject your own earcut reference
  64274. * @returns the polygon mesh
  64275. */
  64276. static CreatePolygon(name: string, options: {
  64277. shape: Vector3[];
  64278. holes?: Vector3[][];
  64279. depth?: number;
  64280. faceUV?: Vector4[];
  64281. faceColors?: Color4[];
  64282. updatable?: boolean;
  64283. sideOrientation?: number;
  64284. frontUVs?: Vector4;
  64285. backUVs?: Vector4;
  64286. wrap?: boolean;
  64287. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64288. /**
  64289. * Creates an extruded polygon mesh, with depth in the Y direction.
  64290. * * 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)
  64291. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64292. * @param name defines the name of the mesh
  64293. * @param options defines the options used to create the mesh
  64294. * @param scene defines the hosting scene
  64295. * @param earcutInjection can be used to inject your own earcut reference
  64296. * @returns the polygon mesh
  64297. */
  64298. static ExtrudePolygon(name: string, options: {
  64299. shape: Vector3[];
  64300. holes?: Vector3[][];
  64301. depth?: number;
  64302. faceUV?: Vector4[];
  64303. faceColors?: Color4[];
  64304. updatable?: boolean;
  64305. sideOrientation?: number;
  64306. frontUVs?: Vector4;
  64307. backUVs?: Vector4;
  64308. wrap?: boolean;
  64309. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64310. }
  64311. }
  64312. declare module BABYLON {
  64313. /**
  64314. * Class containing static functions to help procedurally build meshes
  64315. */
  64316. export class LatheBuilder {
  64317. /**
  64318. * Creates lathe mesh.
  64319. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64320. * * 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
  64321. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64322. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64323. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64324. * * 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
  64325. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64326. * * 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
  64327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64328. * * 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
  64329. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64331. * @param name defines the name of the mesh
  64332. * @param options defines the options used to create the mesh
  64333. * @param scene defines the hosting scene
  64334. * @returns the lathe mesh
  64335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64336. */
  64337. static CreateLathe(name: string, options: {
  64338. shape: Vector3[];
  64339. radius?: number;
  64340. tessellation?: number;
  64341. clip?: number;
  64342. arc?: number;
  64343. closed?: boolean;
  64344. updatable?: boolean;
  64345. sideOrientation?: number;
  64346. frontUVs?: Vector4;
  64347. backUVs?: Vector4;
  64348. cap?: number;
  64349. invertUV?: boolean;
  64350. }, scene?: Nullable<Scene>): Mesh;
  64351. }
  64352. }
  64353. declare module BABYLON {
  64354. /**
  64355. * Class containing static functions to help procedurally build meshes
  64356. */
  64357. export class TiledPlaneBuilder {
  64358. /**
  64359. * Creates a tiled plane mesh
  64360. * * The parameter `pattern` will, depending on value, do nothing or
  64361. * * * flip (reflect about central vertical) alternate tiles across and up
  64362. * * * flip every tile on alternate rows
  64363. * * * rotate (180 degs) alternate tiles across and up
  64364. * * * rotate every tile on alternate rows
  64365. * * * flip and rotate alternate tiles across and up
  64366. * * * flip and rotate every tile on alternate rows
  64367. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64368. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64369. * * 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
  64370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64371. * * 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)
  64372. * * 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)
  64373. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64374. * @param name defines the name of the mesh
  64375. * @param options defines the options used to create the mesh
  64376. * @param scene defines the hosting scene
  64377. * @returns the box mesh
  64378. */
  64379. static CreateTiledPlane(name: string, options: {
  64380. pattern?: number;
  64381. tileSize?: number;
  64382. tileWidth?: number;
  64383. tileHeight?: number;
  64384. size?: number;
  64385. width?: number;
  64386. height?: number;
  64387. alignHorizontal?: number;
  64388. alignVertical?: number;
  64389. sideOrientation?: number;
  64390. frontUVs?: Vector4;
  64391. backUVs?: Vector4;
  64392. updatable?: boolean;
  64393. }, scene?: Nullable<Scene>): Mesh;
  64394. }
  64395. }
  64396. declare module BABYLON {
  64397. /**
  64398. * Class containing static functions to help procedurally build meshes
  64399. */
  64400. export class TubeBuilder {
  64401. /**
  64402. * Creates a tube mesh.
  64403. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64404. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64405. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64406. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64407. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64408. * * 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)
  64409. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64410. * * 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
  64411. * * 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
  64412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64413. * * 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
  64414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64416. * @param name defines the name of the mesh
  64417. * @param options defines the options used to create the mesh
  64418. * @param scene defines the hosting scene
  64419. * @returns the tube mesh
  64420. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64421. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64422. */
  64423. static CreateTube(name: string, options: {
  64424. path: Vector3[];
  64425. radius?: number;
  64426. tessellation?: number;
  64427. radiusFunction?: {
  64428. (i: number, distance: number): number;
  64429. };
  64430. cap?: number;
  64431. arc?: number;
  64432. updatable?: boolean;
  64433. sideOrientation?: number;
  64434. frontUVs?: Vector4;
  64435. backUVs?: Vector4;
  64436. instance?: Mesh;
  64437. invertUV?: boolean;
  64438. }, scene?: Nullable<Scene>): Mesh;
  64439. }
  64440. }
  64441. declare module BABYLON {
  64442. /**
  64443. * Class containing static functions to help procedurally build meshes
  64444. */
  64445. export class IcoSphereBuilder {
  64446. /**
  64447. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64448. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64449. * * 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`)
  64450. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64451. * * 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
  64452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64453. * * 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
  64454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64455. * @param name defines the name of the mesh
  64456. * @param options defines the options used to create the mesh
  64457. * @param scene defines the hosting scene
  64458. * @returns the icosahedron mesh
  64459. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64460. */
  64461. static CreateIcoSphere(name: string, options: {
  64462. radius?: number;
  64463. radiusX?: number;
  64464. radiusY?: number;
  64465. radiusZ?: number;
  64466. flat?: boolean;
  64467. subdivisions?: number;
  64468. sideOrientation?: number;
  64469. frontUVs?: Vector4;
  64470. backUVs?: Vector4;
  64471. updatable?: boolean;
  64472. }, scene?: Nullable<Scene>): Mesh;
  64473. }
  64474. }
  64475. declare module BABYLON {
  64476. /**
  64477. * Class containing static functions to help procedurally build meshes
  64478. */
  64479. export class DecalBuilder {
  64480. /**
  64481. * Creates a decal mesh.
  64482. * 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
  64483. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64484. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64485. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64486. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64487. * @param name defines the name of the mesh
  64488. * @param sourceMesh defines the mesh where the decal must be applied
  64489. * @param options defines the options used to create the mesh
  64490. * @param scene defines the hosting scene
  64491. * @returns the decal mesh
  64492. * @see https://doc.babylonjs.com/how_to/decals
  64493. */
  64494. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64495. position?: Vector3;
  64496. normal?: Vector3;
  64497. size?: Vector3;
  64498. angle?: number;
  64499. }): Mesh;
  64500. }
  64501. }
  64502. declare module BABYLON {
  64503. /**
  64504. * Class containing static functions to help procedurally build meshes
  64505. */
  64506. export class MeshBuilder {
  64507. /**
  64508. * Creates a box mesh
  64509. * * The parameter `size` sets the size (float) of each box side (default 1)
  64510. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64511. * * 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)
  64512. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64514. * * 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
  64515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64516. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64517. * @param name defines the name of the mesh
  64518. * @param options defines the options used to create the mesh
  64519. * @param scene defines the hosting scene
  64520. * @returns the box mesh
  64521. */
  64522. static CreateBox(name: string, options: {
  64523. size?: number;
  64524. width?: number;
  64525. height?: number;
  64526. depth?: number;
  64527. faceUV?: Vector4[];
  64528. faceColors?: Color4[];
  64529. sideOrientation?: number;
  64530. frontUVs?: Vector4;
  64531. backUVs?: Vector4;
  64532. wrap?: boolean;
  64533. topBaseAt?: number;
  64534. bottomBaseAt?: number;
  64535. updatable?: boolean;
  64536. }, scene?: Nullable<Scene>): Mesh;
  64537. /**
  64538. * Creates a tiled box mesh
  64539. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64541. * @param name defines the name of the mesh
  64542. * @param options defines the options used to create the mesh
  64543. * @param scene defines the hosting scene
  64544. * @returns the tiled box mesh
  64545. */
  64546. static CreateTiledBox(name: string, options: {
  64547. pattern?: number;
  64548. size?: number;
  64549. width?: number;
  64550. height?: number;
  64551. depth: number;
  64552. tileSize?: number;
  64553. tileWidth?: number;
  64554. tileHeight?: number;
  64555. faceUV?: Vector4[];
  64556. faceColors?: Color4[];
  64557. alignHorizontal?: number;
  64558. alignVertical?: number;
  64559. sideOrientation?: number;
  64560. updatable?: boolean;
  64561. }, scene?: Nullable<Scene>): Mesh;
  64562. /**
  64563. * Creates a sphere mesh
  64564. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64565. * * 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`)
  64566. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64567. * * 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
  64568. * * 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)
  64569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64570. * * 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
  64571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64572. * @param name defines the name of the mesh
  64573. * @param options defines the options used to create the mesh
  64574. * @param scene defines the hosting scene
  64575. * @returns the sphere mesh
  64576. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64577. */
  64578. static CreateSphere(name: string, options: {
  64579. segments?: number;
  64580. diameter?: number;
  64581. diameterX?: number;
  64582. diameterY?: number;
  64583. diameterZ?: number;
  64584. arc?: number;
  64585. slice?: number;
  64586. sideOrientation?: number;
  64587. frontUVs?: Vector4;
  64588. backUVs?: Vector4;
  64589. updatable?: boolean;
  64590. }, scene?: Nullable<Scene>): Mesh;
  64591. /**
  64592. * Creates a plane polygonal mesh. By default, this is a disc
  64593. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64594. * * 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
  64595. * * 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
  64596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64597. * * 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
  64598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64599. * @param name defines the name of the mesh
  64600. * @param options defines the options used to create the mesh
  64601. * @param scene defines the hosting scene
  64602. * @returns the plane polygonal mesh
  64603. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64604. */
  64605. static CreateDisc(name: string, options: {
  64606. radius?: number;
  64607. tessellation?: number;
  64608. arc?: number;
  64609. updatable?: boolean;
  64610. sideOrientation?: number;
  64611. frontUVs?: Vector4;
  64612. backUVs?: Vector4;
  64613. }, scene?: Nullable<Scene>): Mesh;
  64614. /**
  64615. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64616. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64617. * * 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`)
  64618. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64619. * * 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
  64620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64621. * * 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
  64622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64623. * @param name defines the name of the mesh
  64624. * @param options defines the options used to create the mesh
  64625. * @param scene defines the hosting scene
  64626. * @returns the icosahedron mesh
  64627. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64628. */
  64629. static CreateIcoSphere(name: string, options: {
  64630. radius?: number;
  64631. radiusX?: number;
  64632. radiusY?: number;
  64633. radiusZ?: number;
  64634. flat?: boolean;
  64635. subdivisions?: number;
  64636. sideOrientation?: number;
  64637. frontUVs?: Vector4;
  64638. backUVs?: Vector4;
  64639. updatable?: boolean;
  64640. }, scene?: Nullable<Scene>): Mesh;
  64641. /**
  64642. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64643. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64644. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64645. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64646. * * 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
  64647. * * 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
  64648. * * 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
  64649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64650. * * 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
  64651. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64652. * * 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
  64653. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64654. * * 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
  64655. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64657. * @param name defines the name of the mesh
  64658. * @param options defines the options used to create the mesh
  64659. * @param scene defines the hosting scene
  64660. * @returns the ribbon mesh
  64661. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64662. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64663. */
  64664. static CreateRibbon(name: string, options: {
  64665. pathArray: Vector3[][];
  64666. closeArray?: boolean;
  64667. closePath?: boolean;
  64668. offset?: number;
  64669. updatable?: boolean;
  64670. sideOrientation?: number;
  64671. frontUVs?: Vector4;
  64672. backUVs?: Vector4;
  64673. instance?: Mesh;
  64674. invertUV?: boolean;
  64675. uvs?: Vector2[];
  64676. colors?: Color4[];
  64677. }, scene?: Nullable<Scene>): Mesh;
  64678. /**
  64679. * Creates a cylinder or a cone mesh
  64680. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64681. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64682. * * 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.
  64683. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64684. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64685. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64686. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64687. * * 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).
  64688. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64689. * * 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).
  64690. * * 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
  64691. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64692. * * 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
  64693. * * 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.
  64694. * * If `enclose` is false, a ring surface is one element.
  64695. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64696. * * 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
  64697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64698. * * 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
  64699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64700. * @param name defines the name of the mesh
  64701. * @param options defines the options used to create the mesh
  64702. * @param scene defines the hosting scene
  64703. * @returns the cylinder mesh
  64704. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64705. */
  64706. static CreateCylinder(name: string, options: {
  64707. height?: number;
  64708. diameterTop?: number;
  64709. diameterBottom?: number;
  64710. diameter?: number;
  64711. tessellation?: number;
  64712. subdivisions?: number;
  64713. arc?: number;
  64714. faceColors?: Color4[];
  64715. faceUV?: Vector4[];
  64716. updatable?: boolean;
  64717. hasRings?: boolean;
  64718. enclose?: boolean;
  64719. cap?: number;
  64720. sideOrientation?: number;
  64721. frontUVs?: Vector4;
  64722. backUVs?: Vector4;
  64723. }, scene?: Nullable<Scene>): Mesh;
  64724. /**
  64725. * Creates a torus mesh
  64726. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64727. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64728. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64730. * * 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
  64731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64732. * @param name defines the name of the mesh
  64733. * @param options defines the options used to create the mesh
  64734. * @param scene defines the hosting scene
  64735. * @returns the torus mesh
  64736. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64737. */
  64738. static CreateTorus(name: string, options: {
  64739. diameter?: number;
  64740. thickness?: number;
  64741. tessellation?: number;
  64742. updatable?: boolean;
  64743. sideOrientation?: number;
  64744. frontUVs?: Vector4;
  64745. backUVs?: Vector4;
  64746. }, scene?: Nullable<Scene>): Mesh;
  64747. /**
  64748. * Creates a torus knot mesh
  64749. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64750. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64751. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64752. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64754. * * 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
  64755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64756. * @param name defines the name of the mesh
  64757. * @param options defines the options used to create the mesh
  64758. * @param scene defines the hosting scene
  64759. * @returns the torus knot mesh
  64760. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64761. */
  64762. static CreateTorusKnot(name: string, options: {
  64763. radius?: number;
  64764. tube?: number;
  64765. radialSegments?: number;
  64766. tubularSegments?: number;
  64767. p?: number;
  64768. q?: number;
  64769. updatable?: boolean;
  64770. sideOrientation?: number;
  64771. frontUVs?: Vector4;
  64772. backUVs?: Vector4;
  64773. }, scene?: Nullable<Scene>): Mesh;
  64774. /**
  64775. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64776. * * 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
  64777. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64778. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64779. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64780. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64781. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64782. * * 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
  64783. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64786. * @param name defines the name of the new line system
  64787. * @param options defines the options used to create the line system
  64788. * @param scene defines the hosting scene
  64789. * @returns a new line system mesh
  64790. */
  64791. static CreateLineSystem(name: string, options: {
  64792. lines: Vector3[][];
  64793. updatable?: boolean;
  64794. instance?: Nullable<LinesMesh>;
  64795. colors?: Nullable<Color4[][]>;
  64796. useVertexAlpha?: boolean;
  64797. }, scene: Nullable<Scene>): LinesMesh;
  64798. /**
  64799. * Creates a line mesh
  64800. * 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
  64801. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64802. * * The parameter `points` is an array successive Vector3
  64803. * * 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
  64804. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64805. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64806. * * When updating an instance, remember that only point positions can change, not the number of points
  64807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64808. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64809. * @param name defines the name of the new line system
  64810. * @param options defines the options used to create the line system
  64811. * @param scene defines the hosting scene
  64812. * @returns a new line mesh
  64813. */
  64814. static CreateLines(name: string, options: {
  64815. points: Vector3[];
  64816. updatable?: boolean;
  64817. instance?: Nullable<LinesMesh>;
  64818. colors?: Color4[];
  64819. useVertexAlpha?: boolean;
  64820. }, scene?: Nullable<Scene>): LinesMesh;
  64821. /**
  64822. * Creates a dashed line mesh
  64823. * * 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
  64824. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64825. * * The parameter `points` is an array successive Vector3
  64826. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64827. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64828. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64829. * * 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
  64830. * * When updating an instance, remember that only point positions can change, not the number of points
  64831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64832. * @param name defines the name of the mesh
  64833. * @param options defines the options used to create the mesh
  64834. * @param scene defines the hosting scene
  64835. * @returns the dashed line mesh
  64836. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64837. */
  64838. static CreateDashedLines(name: string, options: {
  64839. points: Vector3[];
  64840. dashSize?: number;
  64841. gapSize?: number;
  64842. dashNb?: number;
  64843. updatable?: boolean;
  64844. instance?: LinesMesh;
  64845. }, scene?: Nullable<Scene>): LinesMesh;
  64846. /**
  64847. * 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.
  64848. * * 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.
  64849. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64850. * * 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.
  64851. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64852. * * 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
  64853. * * 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
  64854. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64856. * * 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
  64857. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64859. * @param name defines the name of the mesh
  64860. * @param options defines the options used to create the mesh
  64861. * @param scene defines the hosting scene
  64862. * @returns the extruded shape mesh
  64863. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64864. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64865. */
  64866. static ExtrudeShape(name: string, options: {
  64867. shape: Vector3[];
  64868. path: Vector3[];
  64869. scale?: number;
  64870. rotation?: number;
  64871. cap?: number;
  64872. updatable?: boolean;
  64873. sideOrientation?: number;
  64874. frontUVs?: Vector4;
  64875. backUVs?: Vector4;
  64876. instance?: Mesh;
  64877. invertUV?: boolean;
  64878. }, scene?: Nullable<Scene>): Mesh;
  64879. /**
  64880. * Creates an custom extruded shape mesh.
  64881. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64882. * * 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.
  64883. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64884. * * 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
  64885. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64886. * * 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
  64887. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64888. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64889. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64890. * * 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
  64891. * * 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
  64892. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64894. * * 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
  64895. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64897. * @param name defines the name of the mesh
  64898. * @param options defines the options used to create the mesh
  64899. * @param scene defines the hosting scene
  64900. * @returns the custom extruded shape mesh
  64901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64902. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64904. */
  64905. static ExtrudeShapeCustom(name: string, options: {
  64906. shape: Vector3[];
  64907. path: Vector3[];
  64908. scaleFunction?: any;
  64909. rotationFunction?: any;
  64910. ribbonCloseArray?: boolean;
  64911. ribbonClosePath?: boolean;
  64912. cap?: number;
  64913. updatable?: boolean;
  64914. sideOrientation?: number;
  64915. frontUVs?: Vector4;
  64916. backUVs?: Vector4;
  64917. instance?: Mesh;
  64918. invertUV?: boolean;
  64919. }, scene?: Nullable<Scene>): Mesh;
  64920. /**
  64921. * Creates lathe mesh.
  64922. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64923. * * 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
  64924. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64925. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64926. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64927. * * 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
  64928. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64929. * * 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
  64930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64931. * * 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
  64932. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64934. * @param name defines the name of the mesh
  64935. * @param options defines the options used to create the mesh
  64936. * @param scene defines the hosting scene
  64937. * @returns the lathe mesh
  64938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64939. */
  64940. static CreateLathe(name: string, options: {
  64941. shape: Vector3[];
  64942. radius?: number;
  64943. tessellation?: number;
  64944. clip?: number;
  64945. arc?: number;
  64946. closed?: boolean;
  64947. updatable?: boolean;
  64948. sideOrientation?: number;
  64949. frontUVs?: Vector4;
  64950. backUVs?: Vector4;
  64951. cap?: number;
  64952. invertUV?: boolean;
  64953. }, scene?: Nullable<Scene>): Mesh;
  64954. /**
  64955. * Creates a tiled plane mesh
  64956. * * You can set a limited pattern arrangement with the tiles
  64957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64958. * * 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
  64959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64960. * @param name defines the name of the mesh
  64961. * @param options defines the options used to create the mesh
  64962. * @param scene defines the hosting scene
  64963. * @returns the plane mesh
  64964. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64965. */
  64966. static CreateTiledPlane(name: string, options: {
  64967. pattern?: number;
  64968. tileSize?: number;
  64969. tileWidth?: number;
  64970. tileHeight?: number;
  64971. size?: number;
  64972. width?: number;
  64973. height?: number;
  64974. alignHorizontal?: number;
  64975. alignVertical?: number;
  64976. sideOrientation?: number;
  64977. frontUVs?: Vector4;
  64978. backUVs?: Vector4;
  64979. updatable?: boolean;
  64980. }, scene?: Nullable<Scene>): Mesh;
  64981. /**
  64982. * Creates a plane mesh
  64983. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64984. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64985. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64987. * * 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
  64988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64989. * @param name defines the name of the mesh
  64990. * @param options defines the options used to create the mesh
  64991. * @param scene defines the hosting scene
  64992. * @returns the plane mesh
  64993. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64994. */
  64995. static CreatePlane(name: string, options: {
  64996. size?: number;
  64997. width?: number;
  64998. height?: number;
  64999. sideOrientation?: number;
  65000. frontUVs?: Vector4;
  65001. backUVs?: Vector4;
  65002. updatable?: boolean;
  65003. sourcePlane?: Plane;
  65004. }, scene?: Nullable<Scene>): Mesh;
  65005. /**
  65006. * Creates a ground mesh
  65007. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65008. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65010. * @param name defines the name of the mesh
  65011. * @param options defines the options used to create the mesh
  65012. * @param scene defines the hosting scene
  65013. * @returns the ground mesh
  65014. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65015. */
  65016. static CreateGround(name: string, options: {
  65017. width?: number;
  65018. height?: number;
  65019. subdivisions?: number;
  65020. subdivisionsX?: number;
  65021. subdivisionsY?: number;
  65022. updatable?: boolean;
  65023. }, scene?: Nullable<Scene>): Mesh;
  65024. /**
  65025. * Creates a tiled ground mesh
  65026. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65027. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65028. * * 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
  65029. * * 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
  65030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65031. * @param name defines the name of the mesh
  65032. * @param options defines the options used to create the mesh
  65033. * @param scene defines the hosting scene
  65034. * @returns the tiled ground mesh
  65035. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65036. */
  65037. static CreateTiledGround(name: string, options: {
  65038. xmin: number;
  65039. zmin: number;
  65040. xmax: number;
  65041. zmax: number;
  65042. subdivisions?: {
  65043. w: number;
  65044. h: number;
  65045. };
  65046. precision?: {
  65047. w: number;
  65048. h: number;
  65049. };
  65050. updatable?: boolean;
  65051. }, scene?: Nullable<Scene>): Mesh;
  65052. /**
  65053. * Creates a ground mesh from a height map
  65054. * * The parameter `url` sets the URL of the height map image resource.
  65055. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65056. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65057. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65058. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65059. * * 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.
  65060. * * 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).
  65061. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65063. * @param name defines the name of the mesh
  65064. * @param url defines the url to the height map
  65065. * @param options defines the options used to create the mesh
  65066. * @param scene defines the hosting scene
  65067. * @returns the ground mesh
  65068. * @see https://doc.babylonjs.com/babylon101/height_map
  65069. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65070. */
  65071. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65072. width?: number;
  65073. height?: number;
  65074. subdivisions?: number;
  65075. minHeight?: number;
  65076. maxHeight?: number;
  65077. colorFilter?: Color3;
  65078. alphaFilter?: number;
  65079. updatable?: boolean;
  65080. onReady?: (mesh: GroundMesh) => void;
  65081. }, scene?: Nullable<Scene>): GroundMesh;
  65082. /**
  65083. * Creates a polygon mesh
  65084. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65085. * * 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
  65086. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65088. * * 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)
  65089. * * Remember you can only change the shape positions, not their number when updating a polygon
  65090. * @param name defines the name of the mesh
  65091. * @param options defines the options used to create the mesh
  65092. * @param scene defines the hosting scene
  65093. * @param earcutInjection can be used to inject your own earcut reference
  65094. * @returns the polygon mesh
  65095. */
  65096. static CreatePolygon(name: string, options: {
  65097. shape: Vector3[];
  65098. holes?: Vector3[][];
  65099. depth?: number;
  65100. faceUV?: Vector4[];
  65101. faceColors?: Color4[];
  65102. updatable?: boolean;
  65103. sideOrientation?: number;
  65104. frontUVs?: Vector4;
  65105. backUVs?: Vector4;
  65106. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65107. /**
  65108. * Creates an extruded polygon mesh, with depth in the Y direction.
  65109. * * 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)
  65110. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65111. * @param name defines the name of the mesh
  65112. * @param options defines the options used to create the mesh
  65113. * @param scene defines the hosting scene
  65114. * @param earcutInjection can be used to inject your own earcut reference
  65115. * @returns the polygon mesh
  65116. */
  65117. static ExtrudePolygon(name: string, options: {
  65118. shape: Vector3[];
  65119. holes?: Vector3[][];
  65120. depth?: number;
  65121. faceUV?: Vector4[];
  65122. faceColors?: Color4[];
  65123. updatable?: boolean;
  65124. sideOrientation?: number;
  65125. frontUVs?: Vector4;
  65126. backUVs?: Vector4;
  65127. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65128. /**
  65129. * Creates a tube mesh.
  65130. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65131. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65132. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65133. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65134. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65135. * * 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)
  65136. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65137. * * 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
  65138. * * 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
  65139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65140. * * 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
  65141. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65143. * @param name defines the name of the mesh
  65144. * @param options defines the options used to create the mesh
  65145. * @param scene defines the hosting scene
  65146. * @returns the tube mesh
  65147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65148. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65149. */
  65150. static CreateTube(name: string, options: {
  65151. path: Vector3[];
  65152. radius?: number;
  65153. tessellation?: number;
  65154. radiusFunction?: {
  65155. (i: number, distance: number): number;
  65156. };
  65157. cap?: number;
  65158. arc?: number;
  65159. updatable?: boolean;
  65160. sideOrientation?: number;
  65161. frontUVs?: Vector4;
  65162. backUVs?: Vector4;
  65163. instance?: Mesh;
  65164. invertUV?: boolean;
  65165. }, scene?: Nullable<Scene>): Mesh;
  65166. /**
  65167. * Creates a polyhedron mesh
  65168. * * 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
  65169. * * The parameter `size` (positive float, default 1) sets the polygon size
  65170. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65171. * * 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`
  65172. * * 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
  65173. * * 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)`)
  65174. * * 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
  65175. * * 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
  65176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65177. * * 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
  65178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65179. * @param name defines the name of the mesh
  65180. * @param options defines the options used to create the mesh
  65181. * @param scene defines the hosting scene
  65182. * @returns the polyhedron mesh
  65183. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65184. */
  65185. static CreatePolyhedron(name: string, options: {
  65186. type?: number;
  65187. size?: number;
  65188. sizeX?: number;
  65189. sizeY?: number;
  65190. sizeZ?: number;
  65191. custom?: any;
  65192. faceUV?: Vector4[];
  65193. faceColors?: Color4[];
  65194. flat?: boolean;
  65195. updatable?: boolean;
  65196. sideOrientation?: number;
  65197. frontUVs?: Vector4;
  65198. backUVs?: Vector4;
  65199. }, scene?: Nullable<Scene>): Mesh;
  65200. /**
  65201. * Creates a decal mesh.
  65202. * 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
  65203. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65204. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65205. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65206. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65207. * @param name defines the name of the mesh
  65208. * @param sourceMesh defines the mesh where the decal must be applied
  65209. * @param options defines the options used to create the mesh
  65210. * @param scene defines the hosting scene
  65211. * @returns the decal mesh
  65212. * @see https://doc.babylonjs.com/how_to/decals
  65213. */
  65214. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65215. position?: Vector3;
  65216. normal?: Vector3;
  65217. size?: Vector3;
  65218. angle?: number;
  65219. }): Mesh;
  65220. }
  65221. }
  65222. declare module BABYLON {
  65223. /**
  65224. * A simplifier interface for future simplification implementations
  65225. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65226. */
  65227. export interface ISimplifier {
  65228. /**
  65229. * Simplification of a given mesh according to the given settings.
  65230. * Since this requires computation, it is assumed that the function runs async.
  65231. * @param settings The settings of the simplification, including quality and distance
  65232. * @param successCallback A callback that will be called after the mesh was simplified.
  65233. * @param errorCallback in case of an error, this callback will be called. optional.
  65234. */
  65235. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65236. }
  65237. /**
  65238. * Expected simplification settings.
  65239. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65240. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65241. */
  65242. export interface ISimplificationSettings {
  65243. /**
  65244. * Gets or sets the expected quality
  65245. */
  65246. quality: number;
  65247. /**
  65248. * Gets or sets the distance when this optimized version should be used
  65249. */
  65250. distance: number;
  65251. /**
  65252. * Gets an already optimized mesh
  65253. */
  65254. optimizeMesh?: boolean;
  65255. }
  65256. /**
  65257. * Class used to specify simplification options
  65258. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65259. */
  65260. export class SimplificationSettings implements ISimplificationSettings {
  65261. /** expected quality */
  65262. quality: number;
  65263. /** distance when this optimized version should be used */
  65264. distance: number;
  65265. /** already optimized mesh */
  65266. optimizeMesh?: boolean | undefined;
  65267. /**
  65268. * Creates a SimplificationSettings
  65269. * @param quality expected quality
  65270. * @param distance distance when this optimized version should be used
  65271. * @param optimizeMesh already optimized mesh
  65272. */
  65273. constructor(
  65274. /** expected quality */
  65275. quality: number,
  65276. /** distance when this optimized version should be used */
  65277. distance: number,
  65278. /** already optimized mesh */
  65279. optimizeMesh?: boolean | undefined);
  65280. }
  65281. /**
  65282. * Interface used to define a simplification task
  65283. */
  65284. export interface ISimplificationTask {
  65285. /**
  65286. * Array of settings
  65287. */
  65288. settings: Array<ISimplificationSettings>;
  65289. /**
  65290. * Simplification type
  65291. */
  65292. simplificationType: SimplificationType;
  65293. /**
  65294. * Mesh to simplify
  65295. */
  65296. mesh: Mesh;
  65297. /**
  65298. * Callback called on success
  65299. */
  65300. successCallback?: () => void;
  65301. /**
  65302. * Defines if parallel processing can be used
  65303. */
  65304. parallelProcessing: boolean;
  65305. }
  65306. /**
  65307. * Queue used to order the simplification tasks
  65308. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65309. */
  65310. export class SimplificationQueue {
  65311. private _simplificationArray;
  65312. /**
  65313. * Gets a boolean indicating that the process is still running
  65314. */
  65315. running: boolean;
  65316. /**
  65317. * Creates a new queue
  65318. */
  65319. constructor();
  65320. /**
  65321. * Adds a new simplification task
  65322. * @param task defines a task to add
  65323. */
  65324. addTask(task: ISimplificationTask): void;
  65325. /**
  65326. * Execute next task
  65327. */
  65328. executeNext(): void;
  65329. /**
  65330. * Execute a simplification task
  65331. * @param task defines the task to run
  65332. */
  65333. runSimplification(task: ISimplificationTask): void;
  65334. private getSimplifier;
  65335. }
  65336. /**
  65337. * The implemented types of simplification
  65338. * At the moment only Quadratic Error Decimation is implemented
  65339. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65340. */
  65341. export enum SimplificationType {
  65342. /** Quadratic error decimation */
  65343. QUADRATIC = 0
  65344. }
  65345. /**
  65346. * An implementation of the Quadratic Error simplification algorithm.
  65347. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65348. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65349. * @author RaananW
  65350. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65351. */
  65352. export class QuadraticErrorSimplification implements ISimplifier {
  65353. private _mesh;
  65354. private triangles;
  65355. private vertices;
  65356. private references;
  65357. private _reconstructedMesh;
  65358. /** Gets or sets the number pf sync interations */
  65359. syncIterations: number;
  65360. /** Gets or sets the aggressiveness of the simplifier */
  65361. aggressiveness: number;
  65362. /** Gets or sets the number of allowed iterations for decimation */
  65363. decimationIterations: number;
  65364. /** Gets or sets the espilon to use for bounding box computation */
  65365. boundingBoxEpsilon: number;
  65366. /**
  65367. * Creates a new QuadraticErrorSimplification
  65368. * @param _mesh defines the target mesh
  65369. */
  65370. constructor(_mesh: Mesh);
  65371. /**
  65372. * Simplification of a given mesh according to the given settings.
  65373. * Since this requires computation, it is assumed that the function runs async.
  65374. * @param settings The settings of the simplification, including quality and distance
  65375. * @param successCallback A callback that will be called after the mesh was simplified.
  65376. */
  65377. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65378. private runDecimation;
  65379. private initWithMesh;
  65380. private init;
  65381. private reconstructMesh;
  65382. private initDecimatedMesh;
  65383. private isFlipped;
  65384. private updateTriangles;
  65385. private identifyBorder;
  65386. private updateMesh;
  65387. private vertexError;
  65388. private calculateError;
  65389. }
  65390. }
  65391. declare module BABYLON {
  65392. interface Scene {
  65393. /** @hidden (Backing field) */
  65394. _simplificationQueue: SimplificationQueue;
  65395. /**
  65396. * Gets or sets the simplification queue attached to the scene
  65397. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65398. */
  65399. simplificationQueue: SimplificationQueue;
  65400. }
  65401. interface Mesh {
  65402. /**
  65403. * Simplify the mesh according to the given array of settings.
  65404. * Function will return immediately and will simplify async
  65405. * @param settings a collection of simplification settings
  65406. * @param parallelProcessing should all levels calculate parallel or one after the other
  65407. * @param simplificationType the type of simplification to run
  65408. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65409. * @returns the current mesh
  65410. */
  65411. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65412. }
  65413. /**
  65414. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65415. * created in a scene
  65416. */
  65417. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65418. /**
  65419. * The component name helpfull to identify the component in the list of scene components.
  65420. */
  65421. readonly name: string;
  65422. /**
  65423. * The scene the component belongs to.
  65424. */
  65425. scene: Scene;
  65426. /**
  65427. * Creates a new instance of the component for the given scene
  65428. * @param scene Defines the scene to register the component in
  65429. */
  65430. constructor(scene: Scene);
  65431. /**
  65432. * Registers the component in a given scene
  65433. */
  65434. register(): void;
  65435. /**
  65436. * Rebuilds the elements related to this component in case of
  65437. * context lost for instance.
  65438. */
  65439. rebuild(): void;
  65440. /**
  65441. * Disposes the component and the associated ressources
  65442. */
  65443. dispose(): void;
  65444. private _beforeCameraUpdate;
  65445. }
  65446. }
  65447. declare module BABYLON {
  65448. interface Mesh {
  65449. /**
  65450. * Creates a new thin instance
  65451. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65452. * @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
  65453. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65454. */
  65455. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65456. /**
  65457. * Adds the transformation (matrix) of the current mesh as a thin instance
  65458. * @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
  65459. * @returns the thin instance index number
  65460. */
  65461. thinInstanceAddSelf(refresh: boolean): number;
  65462. /**
  65463. * Registers a custom attribute to be used with thin instances
  65464. * @param kind name of the attribute
  65465. * @param stride size in floats of the attribute
  65466. */
  65467. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65468. /**
  65469. * Sets the matrix of a thin instance
  65470. * @param index index of the thin instance
  65471. * @param matrix matrix to set
  65472. * @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
  65473. */
  65474. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65475. /**
  65476. * Sets the value of a custom attribute for a thin instance
  65477. * @param kind name of the attribute
  65478. * @param index index of the thin instance
  65479. * @param value value to set
  65480. * @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
  65481. */
  65482. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65483. /**
  65484. * 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.
  65485. */
  65486. thinInstanceCount: number;
  65487. /**
  65488. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65489. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65490. * @param buffer buffer to set
  65491. * @param stride size in floats of each value of the buffer
  65492. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65493. */
  65494. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65495. /**
  65496. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65497. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65498. */
  65499. thinInstanceBufferUpdated(kind: string): void;
  65500. /**
  65501. * Refreshes the bounding info, taking into account all the thin instances defined
  65502. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65503. */
  65504. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65505. /** @hidden */
  65506. _thinInstanceInitializeUserStorage(): void;
  65507. /** @hidden */
  65508. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65509. /** @hidden */
  65510. _userThinInstanceBuffersStorage: {
  65511. data: {
  65512. [key: string]: Float32Array;
  65513. };
  65514. sizes: {
  65515. [key: string]: number;
  65516. };
  65517. vertexBuffers: {
  65518. [key: string]: Nullable<VertexBuffer>;
  65519. };
  65520. strides: {
  65521. [key: string]: number;
  65522. };
  65523. };
  65524. }
  65525. }
  65526. declare module BABYLON {
  65527. /**
  65528. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65529. */
  65530. export interface INavigationEnginePlugin {
  65531. /**
  65532. * plugin name
  65533. */
  65534. name: string;
  65535. /**
  65536. * Creates a navigation mesh
  65537. * @param meshes array of all the geometry used to compute the navigatio mesh
  65538. * @param parameters bunch of parameters used to filter geometry
  65539. */
  65540. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65541. /**
  65542. * Create a navigation mesh debug mesh
  65543. * @param scene is where the mesh will be added
  65544. * @returns debug display mesh
  65545. */
  65546. createDebugNavMesh(scene: Scene): Mesh;
  65547. /**
  65548. * Get a navigation mesh constrained position, closest to the parameter position
  65549. * @param position world position
  65550. * @returns the closest point to position constrained by the navigation mesh
  65551. */
  65552. getClosestPoint(position: Vector3): Vector3;
  65553. /**
  65554. * Get a navigation mesh constrained position, closest to the parameter position
  65555. * @param position world position
  65556. * @param result output the closest point to position constrained by the navigation mesh
  65557. */
  65558. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65559. /**
  65560. * Get a navigation mesh constrained position, within a particular radius
  65561. * @param position world position
  65562. * @param maxRadius the maximum distance to the constrained world position
  65563. * @returns the closest point to position constrained by the navigation mesh
  65564. */
  65565. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65566. /**
  65567. * Get a navigation mesh constrained position, within a particular radius
  65568. * @param position world position
  65569. * @param maxRadius the maximum distance to the constrained world position
  65570. * @param result output the closest point to position constrained by the navigation mesh
  65571. */
  65572. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65573. /**
  65574. * Compute the final position from a segment made of destination-position
  65575. * @param position world position
  65576. * @param destination world position
  65577. * @returns the resulting point along the navmesh
  65578. */
  65579. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65580. /**
  65581. * Compute the final position from a segment made of destination-position
  65582. * @param position world position
  65583. * @param destination world position
  65584. * @param result output the resulting point along the navmesh
  65585. */
  65586. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65587. /**
  65588. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65589. * @param start world position
  65590. * @param end world position
  65591. * @returns array containing world position composing the path
  65592. */
  65593. computePath(start: Vector3, end: Vector3): Vector3[];
  65594. /**
  65595. * If this plugin is supported
  65596. * @returns true if plugin is supported
  65597. */
  65598. isSupported(): boolean;
  65599. /**
  65600. * Create a new Crowd so you can add agents
  65601. * @param maxAgents the maximum agent count in the crowd
  65602. * @param maxAgentRadius the maximum radius an agent can have
  65603. * @param scene to attach the crowd to
  65604. * @returns the crowd you can add agents to
  65605. */
  65606. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65607. /**
  65608. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65609. * The queries will try to find a solution within those bounds
  65610. * default is (1,1,1)
  65611. * @param extent x,y,z value that define the extent around the queries point of reference
  65612. */
  65613. setDefaultQueryExtent(extent: Vector3): void;
  65614. /**
  65615. * Get the Bounding box extent specified by setDefaultQueryExtent
  65616. * @returns the box extent values
  65617. */
  65618. getDefaultQueryExtent(): Vector3;
  65619. /**
  65620. * build the navmesh from a previously saved state using getNavmeshData
  65621. * @param data the Uint8Array returned by getNavmeshData
  65622. */
  65623. buildFromNavmeshData(data: Uint8Array): void;
  65624. /**
  65625. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65626. * @returns data the Uint8Array that can be saved and reused
  65627. */
  65628. getNavmeshData(): Uint8Array;
  65629. /**
  65630. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65631. * @param result output the box extent values
  65632. */
  65633. getDefaultQueryExtentToRef(result: Vector3): void;
  65634. /**
  65635. * Release all resources
  65636. */
  65637. dispose(): void;
  65638. }
  65639. /**
  65640. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65641. */
  65642. export interface ICrowd {
  65643. /**
  65644. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65645. * You can attach anything to that node. The node position is updated in the scene update tick.
  65646. * @param pos world position that will be constrained by the navigation mesh
  65647. * @param parameters agent parameters
  65648. * @param transform hooked to the agent that will be update by the scene
  65649. * @returns agent index
  65650. */
  65651. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65652. /**
  65653. * Returns the agent position in world space
  65654. * @param index agent index returned by addAgent
  65655. * @returns world space position
  65656. */
  65657. getAgentPosition(index: number): Vector3;
  65658. /**
  65659. * Gets the agent position result in world space
  65660. * @param index agent index returned by addAgent
  65661. * @param result output world space position
  65662. */
  65663. getAgentPositionToRef(index: number, result: Vector3): void;
  65664. /**
  65665. * Gets the agent velocity in world space
  65666. * @param index agent index returned by addAgent
  65667. * @returns world space velocity
  65668. */
  65669. getAgentVelocity(index: number): Vector3;
  65670. /**
  65671. * Gets the agent velocity result in world space
  65672. * @param index agent index returned by addAgent
  65673. * @param result output world space velocity
  65674. */
  65675. getAgentVelocityToRef(index: number, result: Vector3): void;
  65676. /**
  65677. * remove a particular agent previously created
  65678. * @param index agent index returned by addAgent
  65679. */
  65680. removeAgent(index: number): void;
  65681. /**
  65682. * get the list of all agents attached to this crowd
  65683. * @returns list of agent indices
  65684. */
  65685. getAgents(): number[];
  65686. /**
  65687. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65688. * @param deltaTime in seconds
  65689. */
  65690. update(deltaTime: number): void;
  65691. /**
  65692. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65693. * @param index agent index returned by addAgent
  65694. * @param destination targeted world position
  65695. */
  65696. agentGoto(index: number, destination: Vector3): void;
  65697. /**
  65698. * Teleport the agent to a new position
  65699. * @param index agent index returned by addAgent
  65700. * @param destination targeted world position
  65701. */
  65702. agentTeleport(index: number, destination: Vector3): void;
  65703. /**
  65704. * Update agent parameters
  65705. * @param index agent index returned by addAgent
  65706. * @param parameters agent parameters
  65707. */
  65708. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65709. /**
  65710. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65711. * The queries will try to find a solution within those bounds
  65712. * default is (1,1,1)
  65713. * @param extent x,y,z value that define the extent around the queries point of reference
  65714. */
  65715. setDefaultQueryExtent(extent: Vector3): void;
  65716. /**
  65717. * Get the Bounding box extent specified by setDefaultQueryExtent
  65718. * @returns the box extent values
  65719. */
  65720. getDefaultQueryExtent(): Vector3;
  65721. /**
  65722. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65723. * @param result output the box extent values
  65724. */
  65725. getDefaultQueryExtentToRef(result: Vector3): void;
  65726. /**
  65727. * Release all resources
  65728. */
  65729. dispose(): void;
  65730. }
  65731. /**
  65732. * Configures an agent
  65733. */
  65734. export interface IAgentParameters {
  65735. /**
  65736. * Agent radius. [Limit: >= 0]
  65737. */
  65738. radius: number;
  65739. /**
  65740. * Agent height. [Limit: > 0]
  65741. */
  65742. height: number;
  65743. /**
  65744. * Maximum allowed acceleration. [Limit: >= 0]
  65745. */
  65746. maxAcceleration: number;
  65747. /**
  65748. * Maximum allowed speed. [Limit: >= 0]
  65749. */
  65750. maxSpeed: number;
  65751. /**
  65752. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65753. */
  65754. collisionQueryRange: number;
  65755. /**
  65756. * The path visibility optimization range. [Limit: > 0]
  65757. */
  65758. pathOptimizationRange: number;
  65759. /**
  65760. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65761. */
  65762. separationWeight: number;
  65763. }
  65764. /**
  65765. * Configures the navigation mesh creation
  65766. */
  65767. export interface INavMeshParameters {
  65768. /**
  65769. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65770. */
  65771. cs: number;
  65772. /**
  65773. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65774. */
  65775. ch: number;
  65776. /**
  65777. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65778. */
  65779. walkableSlopeAngle: number;
  65780. /**
  65781. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65782. * be considered walkable. [Limit: >= 3] [Units: vx]
  65783. */
  65784. walkableHeight: number;
  65785. /**
  65786. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65787. */
  65788. walkableClimb: number;
  65789. /**
  65790. * The distance to erode/shrink the walkable area of the heightfield away from
  65791. * obstructions. [Limit: >=0] [Units: vx]
  65792. */
  65793. walkableRadius: number;
  65794. /**
  65795. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65796. */
  65797. maxEdgeLen: number;
  65798. /**
  65799. * The maximum distance a simplfied contour's border edges should deviate
  65800. * the original raw contour. [Limit: >=0] [Units: vx]
  65801. */
  65802. maxSimplificationError: number;
  65803. /**
  65804. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65805. */
  65806. minRegionArea: number;
  65807. /**
  65808. * Any regions with a span count smaller than this value will, if possible,
  65809. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65810. */
  65811. mergeRegionArea: number;
  65812. /**
  65813. * The maximum number of vertices allowed for polygons generated during the
  65814. * contour to polygon conversion process. [Limit: >= 3]
  65815. */
  65816. maxVertsPerPoly: number;
  65817. /**
  65818. * Sets the sampling distance to use when generating the detail mesh.
  65819. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65820. */
  65821. detailSampleDist: number;
  65822. /**
  65823. * The maximum distance the detail mesh surface should deviate from heightfield
  65824. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65825. */
  65826. detailSampleMaxError: number;
  65827. }
  65828. }
  65829. declare module BABYLON {
  65830. /**
  65831. * RecastJS navigation plugin
  65832. */
  65833. export class RecastJSPlugin implements INavigationEnginePlugin {
  65834. /**
  65835. * Reference to the Recast library
  65836. */
  65837. bjsRECAST: any;
  65838. /**
  65839. * plugin name
  65840. */
  65841. name: string;
  65842. /**
  65843. * the first navmesh created. We might extend this to support multiple navmeshes
  65844. */
  65845. navMesh: any;
  65846. /**
  65847. * Initializes the recastJS plugin
  65848. * @param recastInjection can be used to inject your own recast reference
  65849. */
  65850. constructor(recastInjection?: any);
  65851. /**
  65852. * Creates a navigation mesh
  65853. * @param meshes array of all the geometry used to compute the navigatio mesh
  65854. * @param parameters bunch of parameters used to filter geometry
  65855. */
  65856. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65857. /**
  65858. * Create a navigation mesh debug mesh
  65859. * @param scene is where the mesh will be added
  65860. * @returns debug display mesh
  65861. */
  65862. createDebugNavMesh(scene: Scene): Mesh;
  65863. /**
  65864. * Get a navigation mesh constrained position, closest to the parameter position
  65865. * @param position world position
  65866. * @returns the closest point to position constrained by the navigation mesh
  65867. */
  65868. getClosestPoint(position: Vector3): Vector3;
  65869. /**
  65870. * Get a navigation mesh constrained position, closest to the parameter position
  65871. * @param position world position
  65872. * @param result output the closest point to position constrained by the navigation mesh
  65873. */
  65874. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65875. /**
  65876. * Get a navigation mesh constrained position, within a particular radius
  65877. * @param position world position
  65878. * @param maxRadius the maximum distance to the constrained world position
  65879. * @returns the closest point to position constrained by the navigation mesh
  65880. */
  65881. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65882. /**
  65883. * Get a navigation mesh constrained position, within a particular radius
  65884. * @param position world position
  65885. * @param maxRadius the maximum distance to the constrained world position
  65886. * @param result output the closest point to position constrained by the navigation mesh
  65887. */
  65888. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65889. /**
  65890. * Compute the final position from a segment made of destination-position
  65891. * @param position world position
  65892. * @param destination world position
  65893. * @returns the resulting point along the navmesh
  65894. */
  65895. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65896. /**
  65897. * Compute the final position from a segment made of destination-position
  65898. * @param position world position
  65899. * @param destination world position
  65900. * @param result output the resulting point along the navmesh
  65901. */
  65902. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65903. /**
  65904. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65905. * @param start world position
  65906. * @param end world position
  65907. * @returns array containing world position composing the path
  65908. */
  65909. computePath(start: Vector3, end: Vector3): Vector3[];
  65910. /**
  65911. * Create a new Crowd so you can add agents
  65912. * @param maxAgents the maximum agent count in the crowd
  65913. * @param maxAgentRadius the maximum radius an agent can have
  65914. * @param scene to attach the crowd to
  65915. * @returns the crowd you can add agents to
  65916. */
  65917. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65918. /**
  65919. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65920. * The queries will try to find a solution within those bounds
  65921. * default is (1,1,1)
  65922. * @param extent x,y,z value that define the extent around the queries point of reference
  65923. */
  65924. setDefaultQueryExtent(extent: Vector3): void;
  65925. /**
  65926. * Get the Bounding box extent specified by setDefaultQueryExtent
  65927. * @returns the box extent values
  65928. */
  65929. getDefaultQueryExtent(): Vector3;
  65930. /**
  65931. * build the navmesh from a previously saved state using getNavmeshData
  65932. * @param data the Uint8Array returned by getNavmeshData
  65933. */
  65934. buildFromNavmeshData(data: Uint8Array): void;
  65935. /**
  65936. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65937. * @returns data the Uint8Array that can be saved and reused
  65938. */
  65939. getNavmeshData(): Uint8Array;
  65940. /**
  65941. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65942. * @param result output the box extent values
  65943. */
  65944. getDefaultQueryExtentToRef(result: Vector3): void;
  65945. /**
  65946. * Disposes
  65947. */
  65948. dispose(): void;
  65949. /**
  65950. * If this plugin is supported
  65951. * @returns true if plugin is supported
  65952. */
  65953. isSupported(): boolean;
  65954. }
  65955. /**
  65956. * Recast detour crowd implementation
  65957. */
  65958. export class RecastJSCrowd implements ICrowd {
  65959. /**
  65960. * Recast/detour plugin
  65961. */
  65962. bjsRECASTPlugin: RecastJSPlugin;
  65963. /**
  65964. * Link to the detour crowd
  65965. */
  65966. recastCrowd: any;
  65967. /**
  65968. * One transform per agent
  65969. */
  65970. transforms: TransformNode[];
  65971. /**
  65972. * All agents created
  65973. */
  65974. agents: number[];
  65975. /**
  65976. * Link to the scene is kept to unregister the crowd from the scene
  65977. */
  65978. private _scene;
  65979. /**
  65980. * Observer for crowd updates
  65981. */
  65982. private _onBeforeAnimationsObserver;
  65983. /**
  65984. * Constructor
  65985. * @param plugin recastJS plugin
  65986. * @param maxAgents the maximum agent count in the crowd
  65987. * @param maxAgentRadius the maximum radius an agent can have
  65988. * @param scene to attach the crowd to
  65989. * @returns the crowd you can add agents to
  65990. */
  65991. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65992. /**
  65993. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65994. * You can attach anything to that node. The node position is updated in the scene update tick.
  65995. * @param pos world position that will be constrained by the navigation mesh
  65996. * @param parameters agent parameters
  65997. * @param transform hooked to the agent that will be update by the scene
  65998. * @returns agent index
  65999. */
  66000. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66001. /**
  66002. * Returns the agent position in world space
  66003. * @param index agent index returned by addAgent
  66004. * @returns world space position
  66005. */
  66006. getAgentPosition(index: number): Vector3;
  66007. /**
  66008. * Returns the agent position result in world space
  66009. * @param index agent index returned by addAgent
  66010. * @param result output world space position
  66011. */
  66012. getAgentPositionToRef(index: number, result: Vector3): void;
  66013. /**
  66014. * Returns the agent velocity in world space
  66015. * @param index agent index returned by addAgent
  66016. * @returns world space velocity
  66017. */
  66018. getAgentVelocity(index: number): Vector3;
  66019. /**
  66020. * Returns the agent velocity result in world space
  66021. * @param index agent index returned by addAgent
  66022. * @param result output world space velocity
  66023. */
  66024. getAgentVelocityToRef(index: number, result: Vector3): void;
  66025. /**
  66026. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66027. * @param index agent index returned by addAgent
  66028. * @param destination targeted world position
  66029. */
  66030. agentGoto(index: number, destination: Vector3): void;
  66031. /**
  66032. * Teleport the agent to a new position
  66033. * @param index agent index returned by addAgent
  66034. * @param destination targeted world position
  66035. */
  66036. agentTeleport(index: number, destination: Vector3): void;
  66037. /**
  66038. * Update agent parameters
  66039. * @param index agent index returned by addAgent
  66040. * @param parameters agent parameters
  66041. */
  66042. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66043. /**
  66044. * remove a particular agent previously created
  66045. * @param index agent index returned by addAgent
  66046. */
  66047. removeAgent(index: number): void;
  66048. /**
  66049. * get the list of all agents attached to this crowd
  66050. * @returns list of agent indices
  66051. */
  66052. getAgents(): number[];
  66053. /**
  66054. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66055. * @param deltaTime in seconds
  66056. */
  66057. update(deltaTime: number): void;
  66058. /**
  66059. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66060. * The queries will try to find a solution within those bounds
  66061. * default is (1,1,1)
  66062. * @param extent x,y,z value that define the extent around the queries point of reference
  66063. */
  66064. setDefaultQueryExtent(extent: Vector3): void;
  66065. /**
  66066. * Get the Bounding box extent specified by setDefaultQueryExtent
  66067. * @returns the box extent values
  66068. */
  66069. getDefaultQueryExtent(): Vector3;
  66070. /**
  66071. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66072. * @param result output the box extent values
  66073. */
  66074. getDefaultQueryExtentToRef(result: Vector3): void;
  66075. /**
  66076. * Release all resources
  66077. */
  66078. dispose(): void;
  66079. }
  66080. }
  66081. declare module BABYLON {
  66082. /**
  66083. * Class used to enable access to IndexedDB
  66084. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66085. */
  66086. export class Database implements IOfflineProvider {
  66087. private _callbackManifestChecked;
  66088. private _currentSceneUrl;
  66089. private _db;
  66090. private _enableSceneOffline;
  66091. private _enableTexturesOffline;
  66092. private _manifestVersionFound;
  66093. private _mustUpdateRessources;
  66094. private _hasReachedQuota;
  66095. private _isSupported;
  66096. private _idbFactory;
  66097. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66098. private static IsUASupportingBlobStorage;
  66099. /**
  66100. * Gets a boolean indicating if Database storate is enabled (off by default)
  66101. */
  66102. static IDBStorageEnabled: boolean;
  66103. /**
  66104. * Gets a boolean indicating if scene must be saved in the database
  66105. */
  66106. get enableSceneOffline(): boolean;
  66107. /**
  66108. * Gets a boolean indicating if textures must be saved in the database
  66109. */
  66110. get enableTexturesOffline(): boolean;
  66111. /**
  66112. * Creates a new Database
  66113. * @param urlToScene defines the url to load the scene
  66114. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66115. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66116. */
  66117. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66118. private static _ParseURL;
  66119. private static _ReturnFullUrlLocation;
  66120. private _checkManifestFile;
  66121. /**
  66122. * Open the database and make it available
  66123. * @param successCallback defines the callback to call on success
  66124. * @param errorCallback defines the callback to call on error
  66125. */
  66126. open(successCallback: () => void, errorCallback: () => void): void;
  66127. /**
  66128. * Loads an image from the database
  66129. * @param url defines the url to load from
  66130. * @param image defines the target DOM image
  66131. */
  66132. loadImage(url: string, image: HTMLImageElement): void;
  66133. private _loadImageFromDBAsync;
  66134. private _saveImageIntoDBAsync;
  66135. private _checkVersionFromDB;
  66136. private _loadVersionFromDBAsync;
  66137. private _saveVersionIntoDBAsync;
  66138. /**
  66139. * Loads a file from database
  66140. * @param url defines the URL to load from
  66141. * @param sceneLoaded defines a callback to call on success
  66142. * @param progressCallBack defines a callback to call when progress changed
  66143. * @param errorCallback defines a callback to call on error
  66144. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66145. */
  66146. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66147. private _loadFileAsync;
  66148. private _saveFileAsync;
  66149. /**
  66150. * Validates if xhr data is correct
  66151. * @param xhr defines the request to validate
  66152. * @param dataType defines the expected data type
  66153. * @returns true if data is correct
  66154. */
  66155. private static _ValidateXHRData;
  66156. }
  66157. }
  66158. declare module BABYLON {
  66159. /** @hidden */
  66160. export var gpuUpdateParticlesPixelShader: {
  66161. name: string;
  66162. shader: string;
  66163. };
  66164. }
  66165. declare module BABYLON {
  66166. /** @hidden */
  66167. export var gpuUpdateParticlesVertexShader: {
  66168. name: string;
  66169. shader: string;
  66170. };
  66171. }
  66172. declare module BABYLON {
  66173. /** @hidden */
  66174. export var clipPlaneFragmentDeclaration2: {
  66175. name: string;
  66176. shader: string;
  66177. };
  66178. }
  66179. declare module BABYLON {
  66180. /** @hidden */
  66181. export var gpuRenderParticlesPixelShader: {
  66182. name: string;
  66183. shader: string;
  66184. };
  66185. }
  66186. declare module BABYLON {
  66187. /** @hidden */
  66188. export var clipPlaneVertexDeclaration2: {
  66189. name: string;
  66190. shader: string;
  66191. };
  66192. }
  66193. declare module BABYLON {
  66194. /** @hidden */
  66195. export var gpuRenderParticlesVertexShader: {
  66196. name: string;
  66197. shader: string;
  66198. };
  66199. }
  66200. declare module BABYLON {
  66201. /**
  66202. * This represents a GPU particle system in Babylon
  66203. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66204. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66205. */
  66206. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66207. /**
  66208. * The layer mask we are rendering the particles through.
  66209. */
  66210. layerMask: number;
  66211. private _capacity;
  66212. private _activeCount;
  66213. private _currentActiveCount;
  66214. private _accumulatedCount;
  66215. private _renderEffect;
  66216. private _updateEffect;
  66217. private _buffer0;
  66218. private _buffer1;
  66219. private _spriteBuffer;
  66220. private _updateVAO;
  66221. private _renderVAO;
  66222. private _targetIndex;
  66223. private _sourceBuffer;
  66224. private _targetBuffer;
  66225. private _engine;
  66226. private _currentRenderId;
  66227. private _started;
  66228. private _stopped;
  66229. private _timeDelta;
  66230. private _randomTexture;
  66231. private _randomTexture2;
  66232. private _attributesStrideSize;
  66233. private _updateEffectOptions;
  66234. private _randomTextureSize;
  66235. private _actualFrame;
  66236. private _customEffect;
  66237. private readonly _rawTextureWidth;
  66238. /**
  66239. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66240. */
  66241. static get IsSupported(): boolean;
  66242. /**
  66243. * An event triggered when the system is disposed.
  66244. */
  66245. onDisposeObservable: Observable<IParticleSystem>;
  66246. /**
  66247. * Gets the maximum number of particles active at the same time.
  66248. * @returns The max number of active particles.
  66249. */
  66250. getCapacity(): number;
  66251. /**
  66252. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66253. * to override the particles.
  66254. */
  66255. forceDepthWrite: boolean;
  66256. /**
  66257. * Gets or set the number of active particles
  66258. */
  66259. get activeParticleCount(): number;
  66260. set activeParticleCount(value: number);
  66261. private _preWarmDone;
  66262. /**
  66263. * Specifies if the particles are updated in emitter local space or world space.
  66264. */
  66265. isLocal: boolean;
  66266. /**
  66267. * Is this system ready to be used/rendered
  66268. * @return true if the system is ready
  66269. */
  66270. isReady(): boolean;
  66271. /**
  66272. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66273. * @returns True if it has been started, otherwise false.
  66274. */
  66275. isStarted(): boolean;
  66276. /**
  66277. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66278. * @returns True if it has been stopped, otherwise false.
  66279. */
  66280. isStopped(): boolean;
  66281. /**
  66282. * Gets a boolean indicating that the system is stopping
  66283. * @returns true if the system is currently stopping
  66284. */
  66285. isStopping(): boolean;
  66286. /**
  66287. * Gets the number of particles active at the same time.
  66288. * @returns The number of active particles.
  66289. */
  66290. getActiveCount(): number;
  66291. /**
  66292. * Starts the particle system and begins to emit
  66293. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66294. */
  66295. start(delay?: number): void;
  66296. /**
  66297. * Stops the particle system.
  66298. */
  66299. stop(): void;
  66300. /**
  66301. * Remove all active particles
  66302. */
  66303. reset(): void;
  66304. /**
  66305. * Returns the string "GPUParticleSystem"
  66306. * @returns a string containing the class name
  66307. */
  66308. getClassName(): string;
  66309. /**
  66310. * Gets the custom effect used to render the particles
  66311. * @param blendMode Blend mode for which the effect should be retrieved
  66312. * @returns The effect
  66313. */
  66314. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66315. /**
  66316. * Sets the custom effect used to render the particles
  66317. * @param effect The effect to set
  66318. * @param blendMode Blend mode for which the effect should be set
  66319. */
  66320. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66321. /** @hidden */
  66322. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66323. /**
  66324. * Observable that will be called just before the particles are drawn
  66325. */
  66326. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66327. /**
  66328. * Gets the name of the particle vertex shader
  66329. */
  66330. get vertexShaderName(): string;
  66331. private _colorGradientsTexture;
  66332. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66333. /**
  66334. * Adds a new color gradient
  66335. * @param gradient defines the gradient to use (between 0 and 1)
  66336. * @param color1 defines the color to affect to the specified gradient
  66337. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66338. * @returns the current particle system
  66339. */
  66340. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66341. private _refreshColorGradient;
  66342. /** Force the system to rebuild all gradients that need to be resync */
  66343. forceRefreshGradients(): void;
  66344. /**
  66345. * Remove a specific color gradient
  66346. * @param gradient defines the gradient to remove
  66347. * @returns the current particle system
  66348. */
  66349. removeColorGradient(gradient: number): GPUParticleSystem;
  66350. private _angularSpeedGradientsTexture;
  66351. private _sizeGradientsTexture;
  66352. private _velocityGradientsTexture;
  66353. private _limitVelocityGradientsTexture;
  66354. private _dragGradientsTexture;
  66355. private _addFactorGradient;
  66356. /**
  66357. * Adds a new size gradient
  66358. * @param gradient defines the gradient to use (between 0 and 1)
  66359. * @param factor defines the size factor to affect to the specified gradient
  66360. * @returns the current particle system
  66361. */
  66362. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66363. /**
  66364. * Remove a specific size gradient
  66365. * @param gradient defines the gradient to remove
  66366. * @returns the current particle system
  66367. */
  66368. removeSizeGradient(gradient: number): GPUParticleSystem;
  66369. private _refreshFactorGradient;
  66370. /**
  66371. * Adds a new angular speed gradient
  66372. * @param gradient defines the gradient to use (between 0 and 1)
  66373. * @param factor defines the angular speed to affect to the specified gradient
  66374. * @returns the current particle system
  66375. */
  66376. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66377. /**
  66378. * Remove a specific angular speed gradient
  66379. * @param gradient defines the gradient to remove
  66380. * @returns the current particle system
  66381. */
  66382. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66383. /**
  66384. * Adds a new velocity gradient
  66385. * @param gradient defines the gradient to use (between 0 and 1)
  66386. * @param factor defines the velocity to affect to the specified gradient
  66387. * @returns the current particle system
  66388. */
  66389. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66390. /**
  66391. * Remove a specific velocity gradient
  66392. * @param gradient defines the gradient to remove
  66393. * @returns the current particle system
  66394. */
  66395. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66396. /**
  66397. * Adds a new limit velocity gradient
  66398. * @param gradient defines the gradient to use (between 0 and 1)
  66399. * @param factor defines the limit velocity value to affect to the specified gradient
  66400. * @returns the current particle system
  66401. */
  66402. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66403. /**
  66404. * Remove a specific limit velocity gradient
  66405. * @param gradient defines the gradient to remove
  66406. * @returns the current particle system
  66407. */
  66408. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66409. /**
  66410. * Adds a new drag gradient
  66411. * @param gradient defines the gradient to use (between 0 and 1)
  66412. * @param factor defines the drag value to affect to the specified gradient
  66413. * @returns the current particle system
  66414. */
  66415. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66416. /**
  66417. * Remove a specific drag gradient
  66418. * @param gradient defines the gradient to remove
  66419. * @returns the current particle system
  66420. */
  66421. removeDragGradient(gradient: number): GPUParticleSystem;
  66422. /**
  66423. * Not supported by GPUParticleSystem
  66424. * @param gradient defines the gradient to use (between 0 and 1)
  66425. * @param factor defines the emit rate value to affect to the specified gradient
  66426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66427. * @returns the current particle system
  66428. */
  66429. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66430. /**
  66431. * Not supported by GPUParticleSystem
  66432. * @param gradient defines the gradient to remove
  66433. * @returns the current particle system
  66434. */
  66435. removeEmitRateGradient(gradient: number): IParticleSystem;
  66436. /**
  66437. * Not supported by GPUParticleSystem
  66438. * @param gradient defines the gradient to use (between 0 and 1)
  66439. * @param factor defines the start size value to affect to the specified gradient
  66440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66441. * @returns the current particle system
  66442. */
  66443. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66444. /**
  66445. * Not supported by GPUParticleSystem
  66446. * @param gradient defines the gradient to remove
  66447. * @returns the current particle system
  66448. */
  66449. removeStartSizeGradient(gradient: number): IParticleSystem;
  66450. /**
  66451. * Not supported by GPUParticleSystem
  66452. * @param gradient defines the gradient to use (between 0 and 1)
  66453. * @param min defines the color remap minimal range
  66454. * @param max defines the color remap maximal range
  66455. * @returns the current particle system
  66456. */
  66457. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66458. /**
  66459. * Not supported by GPUParticleSystem
  66460. * @param gradient defines the gradient to remove
  66461. * @returns the current particle system
  66462. */
  66463. removeColorRemapGradient(): IParticleSystem;
  66464. /**
  66465. * Not supported by GPUParticleSystem
  66466. * @param gradient defines the gradient to use (between 0 and 1)
  66467. * @param min defines the alpha remap minimal range
  66468. * @param max defines the alpha remap maximal range
  66469. * @returns the current particle system
  66470. */
  66471. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66472. /**
  66473. * Not supported by GPUParticleSystem
  66474. * @param gradient defines the gradient to remove
  66475. * @returns the current particle system
  66476. */
  66477. removeAlphaRemapGradient(): IParticleSystem;
  66478. /**
  66479. * Not supported by GPUParticleSystem
  66480. * @param gradient defines the gradient to use (between 0 and 1)
  66481. * @param color defines the color to affect to the specified gradient
  66482. * @returns the current particle system
  66483. */
  66484. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66485. /**
  66486. * Not supported by GPUParticleSystem
  66487. * @param gradient defines the gradient to remove
  66488. * @returns the current particle system
  66489. */
  66490. removeRampGradient(): IParticleSystem;
  66491. /**
  66492. * Not supported by GPUParticleSystem
  66493. * @returns the list of ramp gradients
  66494. */
  66495. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66496. /**
  66497. * Not supported by GPUParticleSystem
  66498. * Gets or sets a boolean indicating that ramp gradients must be used
  66499. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66500. */
  66501. get useRampGradients(): boolean;
  66502. set useRampGradients(value: boolean);
  66503. /**
  66504. * Not supported by GPUParticleSystem
  66505. * @param gradient defines the gradient to use (between 0 and 1)
  66506. * @param factor defines the life time factor to affect to the specified gradient
  66507. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66508. * @returns the current particle system
  66509. */
  66510. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66511. /**
  66512. * Not supported by GPUParticleSystem
  66513. * @param gradient defines the gradient to remove
  66514. * @returns the current particle system
  66515. */
  66516. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66517. /**
  66518. * Instantiates a GPU particle system.
  66519. * 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.
  66520. * @param name The name of the particle system
  66521. * @param options The options used to create the system
  66522. * @param scene The scene the particle system belongs to
  66523. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66524. * @param customEffect a custom effect used to change the way particles are rendered by default
  66525. */
  66526. constructor(name: string, options: Partial<{
  66527. capacity: number;
  66528. randomTextureSize: number;
  66529. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66530. protected _reset(): void;
  66531. private _createUpdateVAO;
  66532. private _createRenderVAO;
  66533. private _initialize;
  66534. /** @hidden */
  66535. _recreateUpdateEffect(): void;
  66536. private _getEffect;
  66537. /**
  66538. * Fill the defines array according to the current settings of the particle system
  66539. * @param defines Array to be updated
  66540. * @param blendMode blend mode to take into account when updating the array
  66541. */
  66542. fillDefines(defines: Array<string>, blendMode?: number): void;
  66543. /**
  66544. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66545. * @param uniforms Uniforms array to fill
  66546. * @param attributes Attributes array to fill
  66547. * @param samplers Samplers array to fill
  66548. */
  66549. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66550. /** @hidden */
  66551. _recreateRenderEffect(): Effect;
  66552. /**
  66553. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66554. * @param preWarm defines if we are in the pre-warmimg phase
  66555. */
  66556. animate(preWarm?: boolean): void;
  66557. private _createFactorGradientTexture;
  66558. private _createSizeGradientTexture;
  66559. private _createAngularSpeedGradientTexture;
  66560. private _createVelocityGradientTexture;
  66561. private _createLimitVelocityGradientTexture;
  66562. private _createDragGradientTexture;
  66563. private _createColorGradientTexture;
  66564. /**
  66565. * Renders the particle system in its current state
  66566. * @param preWarm defines if the system should only update the particles but not render them
  66567. * @returns the current number of particles
  66568. */
  66569. render(preWarm?: boolean): number;
  66570. /**
  66571. * Rebuilds the particle system
  66572. */
  66573. rebuild(): void;
  66574. private _releaseBuffers;
  66575. private _releaseVAOs;
  66576. /**
  66577. * Disposes the particle system and free the associated resources
  66578. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66579. */
  66580. dispose(disposeTexture?: boolean): void;
  66581. /**
  66582. * Clones the particle system.
  66583. * @param name The name of the cloned object
  66584. * @param newEmitter The new emitter to use
  66585. * @returns the cloned particle system
  66586. */
  66587. clone(name: string, newEmitter: any): GPUParticleSystem;
  66588. /**
  66589. * Serializes the particle system to a JSON object
  66590. * @param serializeTexture defines if the texture must be serialized as well
  66591. * @returns the JSON object
  66592. */
  66593. serialize(serializeTexture?: boolean): any;
  66594. /**
  66595. * Parses a JSON object to create a GPU particle system.
  66596. * @param parsedParticleSystem The JSON object to parse
  66597. * @param scene The scene to create the particle system in
  66598. * @param rootUrl The root url to use to load external dependencies like texture
  66599. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66600. * @returns the parsed GPU particle system
  66601. */
  66602. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66603. }
  66604. }
  66605. declare module BABYLON {
  66606. /**
  66607. * Represents a set of particle systems working together to create a specific effect
  66608. */
  66609. export class ParticleSystemSet implements IDisposable {
  66610. /**
  66611. * Gets or sets base Assets URL
  66612. */
  66613. static BaseAssetsUrl: string;
  66614. private _emitterCreationOptions;
  66615. private _emitterNode;
  66616. /**
  66617. * Gets the particle system list
  66618. */
  66619. systems: IParticleSystem[];
  66620. /**
  66621. * Gets the emitter node used with this set
  66622. */
  66623. get emitterNode(): Nullable<TransformNode>;
  66624. /**
  66625. * Creates a new emitter mesh as a sphere
  66626. * @param options defines the options used to create the sphere
  66627. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66628. * @param scene defines the hosting scene
  66629. */
  66630. setEmitterAsSphere(options: {
  66631. diameter: number;
  66632. segments: number;
  66633. color: Color3;
  66634. }, renderingGroupId: number, scene: Scene): void;
  66635. /**
  66636. * Starts all particle systems of the set
  66637. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66638. */
  66639. start(emitter?: AbstractMesh): void;
  66640. /**
  66641. * Release all associated resources
  66642. */
  66643. dispose(): void;
  66644. /**
  66645. * Serialize the set into a JSON compatible object
  66646. * @param serializeTexture defines if the texture must be serialized as well
  66647. * @returns a JSON compatible representation of the set
  66648. */
  66649. serialize(serializeTexture?: boolean): any;
  66650. /**
  66651. * Parse a new ParticleSystemSet from a serialized source
  66652. * @param data defines a JSON compatible representation of the set
  66653. * @param scene defines the hosting scene
  66654. * @param gpu defines if we want GPU particles or CPU particles
  66655. * @returns a new ParticleSystemSet
  66656. */
  66657. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66658. }
  66659. }
  66660. declare module BABYLON {
  66661. /**
  66662. * This class is made for on one-liner static method to help creating particle system set.
  66663. */
  66664. export class ParticleHelper {
  66665. /**
  66666. * Gets or sets base Assets URL
  66667. */
  66668. static BaseAssetsUrl: string;
  66669. /** Define the Url to load snippets */
  66670. static SnippetUrl: string;
  66671. /**
  66672. * Create a default particle system that you can tweak
  66673. * @param emitter defines the emitter to use
  66674. * @param capacity defines the system capacity (default is 500 particles)
  66675. * @param scene defines the hosting scene
  66676. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66677. * @returns the new Particle system
  66678. */
  66679. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66680. /**
  66681. * This is the main static method (one-liner) of this helper to create different particle systems
  66682. * @param type This string represents the type to the particle system to create
  66683. * @param scene The scene where the particle system should live
  66684. * @param gpu If the system will use gpu
  66685. * @returns the ParticleSystemSet created
  66686. */
  66687. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66688. /**
  66689. * Static function used to export a particle system to a ParticleSystemSet variable.
  66690. * Please note that the emitter shape is not exported
  66691. * @param systems defines the particle systems to export
  66692. * @returns the created particle system set
  66693. */
  66694. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66695. /**
  66696. * Creates a particle system from a snippet saved in a remote file
  66697. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66698. * @param url defines the url to load from
  66699. * @param scene defines the hosting scene
  66700. * @param gpu If the system will use gpu
  66701. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66702. * @returns a promise that will resolve to the new particle system
  66703. */
  66704. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66705. /**
  66706. * Creates a particle system from a snippet saved by the particle system editor
  66707. * @param snippetId defines the snippet to load
  66708. * @param scene defines the hosting scene
  66709. * @param gpu If the system will use gpu
  66710. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66711. * @returns a promise that will resolve to the new particle system
  66712. */
  66713. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66714. }
  66715. }
  66716. declare module BABYLON {
  66717. interface Engine {
  66718. /**
  66719. * Create an effect to use with particle systems.
  66720. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66721. * the particle system for which you want to create a custom effect in the last parameter
  66722. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66723. * @param uniformsNames defines a list of attribute names
  66724. * @param samplers defines an array of string used to represent textures
  66725. * @param defines defines the string containing the defines to use to compile the shaders
  66726. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66727. * @param onCompiled defines a function to call when the effect creation is successful
  66728. * @param onError defines a function to call when the effect creation has failed
  66729. * @param particleSystem the particle system you want to create the effect for
  66730. * @returns the new Effect
  66731. */
  66732. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66733. }
  66734. interface Mesh {
  66735. /**
  66736. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66737. * @returns an array of IParticleSystem
  66738. */
  66739. getEmittedParticleSystems(): IParticleSystem[];
  66740. /**
  66741. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66742. * @returns an array of IParticleSystem
  66743. */
  66744. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66745. }
  66746. }
  66747. declare module BABYLON {
  66748. /** Defines the 4 color options */
  66749. export enum PointColor {
  66750. /** color value */
  66751. Color = 2,
  66752. /** uv value */
  66753. UV = 1,
  66754. /** random value */
  66755. Random = 0,
  66756. /** stated value */
  66757. Stated = 3
  66758. }
  66759. /**
  66760. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66761. * 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.
  66762. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66763. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66764. *
  66765. * Full documentation here : TO BE ENTERED
  66766. */
  66767. export class PointsCloudSystem implements IDisposable {
  66768. /**
  66769. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66770. * Example : var p = SPS.particles[i];
  66771. */
  66772. particles: CloudPoint[];
  66773. /**
  66774. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66775. */
  66776. nbParticles: number;
  66777. /**
  66778. * This a counter for your own usage. It's not set by any SPS functions.
  66779. */
  66780. counter: number;
  66781. /**
  66782. * The PCS name. This name is also given to the underlying mesh.
  66783. */
  66784. name: string;
  66785. /**
  66786. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66787. */
  66788. mesh: Mesh;
  66789. /**
  66790. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66791. * Please read :
  66792. */
  66793. vars: any;
  66794. /**
  66795. * @hidden
  66796. */
  66797. _size: number;
  66798. private _scene;
  66799. private _promises;
  66800. private _positions;
  66801. private _indices;
  66802. private _normals;
  66803. private _colors;
  66804. private _uvs;
  66805. private _indices32;
  66806. private _positions32;
  66807. private _colors32;
  66808. private _uvs32;
  66809. private _updatable;
  66810. private _isVisibilityBoxLocked;
  66811. private _alwaysVisible;
  66812. private _groups;
  66813. private _groupCounter;
  66814. private _computeParticleColor;
  66815. private _computeParticleTexture;
  66816. private _computeParticleRotation;
  66817. private _computeBoundingBox;
  66818. private _isReady;
  66819. /**
  66820. * Creates a PCS (Points Cloud System) object
  66821. * @param name (String) is the PCS name, this will be the underlying mesh name
  66822. * @param pointSize (number) is the size for each point
  66823. * @param scene (Scene) is the scene in which the PCS is added
  66824. * @param options defines the options of the PCS e.g.
  66825. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66826. */
  66827. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66828. updatable?: boolean;
  66829. });
  66830. /**
  66831. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66832. * If no points were added to the PCS, the returned mesh is just a single point.
  66833. * @returns a promise for the created mesh
  66834. */
  66835. buildMeshAsync(): Promise<Mesh>;
  66836. /**
  66837. * @hidden
  66838. */
  66839. private _buildMesh;
  66840. private _addParticle;
  66841. private _randomUnitVector;
  66842. private _getColorIndicesForCoord;
  66843. private _setPointsColorOrUV;
  66844. private _colorFromTexture;
  66845. private _calculateDensity;
  66846. /**
  66847. * Adds points to the PCS in random positions within a unit sphere
  66848. * @param nb (positive integer) the number of particles to be created from this model
  66849. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66850. * @returns the number of groups in the system
  66851. */
  66852. addPoints(nb: number, pointFunction?: any): number;
  66853. /**
  66854. * Adds points to the PCS from the surface of the model shape
  66855. * @param mesh is any Mesh object that will be used as a surface model for the points
  66856. * @param nb (positive integer) the number of particles to be created from this model
  66857. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66858. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66859. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66860. * @returns the number of groups in the system
  66861. */
  66862. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66863. /**
  66864. * Adds points to the PCS inside the model shape
  66865. * @param mesh is any Mesh object that will be used as a surface model for the points
  66866. * @param nb (positive integer) the number of particles to be created from this model
  66867. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66868. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66869. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66870. * @returns the number of groups in the system
  66871. */
  66872. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66873. /**
  66874. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66875. * This method calls `updateParticle()` for each particle of the SPS.
  66876. * For an animated SPS, it is usually called within the render loop.
  66877. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66878. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66879. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66880. * @returns the PCS.
  66881. */
  66882. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66883. /**
  66884. * Disposes the PCS.
  66885. */
  66886. dispose(): void;
  66887. /**
  66888. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66889. * doc :
  66890. * @returns the PCS.
  66891. */
  66892. refreshVisibleSize(): PointsCloudSystem;
  66893. /**
  66894. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66895. * @param size the size (float) of the visibility box
  66896. * note : this doesn't lock the PCS mesh bounding box.
  66897. * doc :
  66898. */
  66899. setVisibilityBox(size: number): void;
  66900. /**
  66901. * Gets whether the PCS is always visible or not
  66902. * doc :
  66903. */
  66904. get isAlwaysVisible(): boolean;
  66905. /**
  66906. * Sets the PCS as always visible or not
  66907. * doc :
  66908. */
  66909. set isAlwaysVisible(val: boolean);
  66910. /**
  66911. * Tells to `setParticles()` to compute the particle rotations or not
  66912. * Default value : false. The PCS is faster when it's set to false
  66913. * Note : particle rotations are only applied to parent particles
  66914. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66915. */
  66916. set computeParticleRotation(val: boolean);
  66917. /**
  66918. * Tells to `setParticles()` to compute the particle colors or not.
  66919. * Default value : true. The PCS is faster when it's set to false.
  66920. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66921. */
  66922. set computeParticleColor(val: boolean);
  66923. set computeParticleTexture(val: boolean);
  66924. /**
  66925. * Gets if `setParticles()` computes the particle colors or not.
  66926. * Default value : false. The PCS is faster when it's set to false.
  66927. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66928. */
  66929. get computeParticleColor(): boolean;
  66930. /**
  66931. * Gets if `setParticles()` computes the particle textures or not.
  66932. * Default value : false. The PCS is faster when it's set to false.
  66933. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66934. */
  66935. get computeParticleTexture(): boolean;
  66936. /**
  66937. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66938. */
  66939. set computeBoundingBox(val: boolean);
  66940. /**
  66941. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66942. */
  66943. get computeBoundingBox(): boolean;
  66944. /**
  66945. * This function does nothing. It may be overwritten to set all the particle first values.
  66946. * The PCS doesn't call this function, you may have to call it by your own.
  66947. * doc :
  66948. */
  66949. initParticles(): void;
  66950. /**
  66951. * This function does nothing. It may be overwritten to recycle a particle
  66952. * The PCS doesn't call this function, you can to call it
  66953. * doc :
  66954. * @param particle The particle to recycle
  66955. * @returns the recycled particle
  66956. */
  66957. recycleParticle(particle: CloudPoint): CloudPoint;
  66958. /**
  66959. * Updates a particle : this function should be overwritten by the user.
  66960. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66961. * doc :
  66962. * @example : just set a particle position or velocity and recycle conditions
  66963. * @param particle The particle to update
  66964. * @returns the updated particle
  66965. */
  66966. updateParticle(particle: CloudPoint): CloudPoint;
  66967. /**
  66968. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66969. * This does nothing and may be overwritten by the user.
  66970. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66971. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66972. * @param update the boolean update value actually passed to setParticles()
  66973. */
  66974. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66975. /**
  66976. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66977. * This will be passed three parameters.
  66978. * This does nothing and may be overwritten by the user.
  66979. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66980. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66981. * @param update the boolean update value actually passed to setParticles()
  66982. */
  66983. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66984. }
  66985. }
  66986. declare module BABYLON {
  66987. /**
  66988. * Represents one particle of a points cloud system.
  66989. */
  66990. export class CloudPoint {
  66991. /**
  66992. * particle global index
  66993. */
  66994. idx: number;
  66995. /**
  66996. * The color of the particle
  66997. */
  66998. color: Nullable<Color4>;
  66999. /**
  67000. * The world space position of the particle.
  67001. */
  67002. position: Vector3;
  67003. /**
  67004. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67005. */
  67006. rotation: Vector3;
  67007. /**
  67008. * The world space rotation quaternion of the particle.
  67009. */
  67010. rotationQuaternion: Nullable<Quaternion>;
  67011. /**
  67012. * The uv of the particle.
  67013. */
  67014. uv: Nullable<Vector2>;
  67015. /**
  67016. * The current speed of the particle.
  67017. */
  67018. velocity: Vector3;
  67019. /**
  67020. * The pivot point in the particle local space.
  67021. */
  67022. pivot: Vector3;
  67023. /**
  67024. * Must the particle be translated from its pivot point in its local space ?
  67025. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67026. * Default : false
  67027. */
  67028. translateFromPivot: boolean;
  67029. /**
  67030. * Index of this particle in the global "positions" array (Internal use)
  67031. * @hidden
  67032. */
  67033. _pos: number;
  67034. /**
  67035. * @hidden Index of this particle in the global "indices" array (Internal use)
  67036. */
  67037. _ind: number;
  67038. /**
  67039. * Group this particle belongs to
  67040. */
  67041. _group: PointsGroup;
  67042. /**
  67043. * Group id of this particle
  67044. */
  67045. groupId: number;
  67046. /**
  67047. * Index of the particle in its group id (Internal use)
  67048. */
  67049. idxInGroup: number;
  67050. /**
  67051. * @hidden Particle BoundingInfo object (Internal use)
  67052. */
  67053. _boundingInfo: BoundingInfo;
  67054. /**
  67055. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67056. */
  67057. _pcs: PointsCloudSystem;
  67058. /**
  67059. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67060. */
  67061. _stillInvisible: boolean;
  67062. /**
  67063. * @hidden Last computed particle rotation matrix
  67064. */
  67065. _rotationMatrix: number[];
  67066. /**
  67067. * Parent particle Id, if any.
  67068. * Default null.
  67069. */
  67070. parentId: Nullable<number>;
  67071. /**
  67072. * @hidden Internal global position in the PCS.
  67073. */
  67074. _globalPosition: Vector3;
  67075. /**
  67076. * Creates a Point Cloud object.
  67077. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67078. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67079. * @param group (PointsGroup) is the group the particle belongs to
  67080. * @param groupId (integer) is the group identifier in the PCS.
  67081. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67082. * @param pcs defines the PCS it is associated to
  67083. */
  67084. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67085. /**
  67086. * get point size
  67087. */
  67088. get size(): Vector3;
  67089. /**
  67090. * Set point size
  67091. */
  67092. set size(scale: Vector3);
  67093. /**
  67094. * Legacy support, changed quaternion to rotationQuaternion
  67095. */
  67096. get quaternion(): Nullable<Quaternion>;
  67097. /**
  67098. * Legacy support, changed quaternion to rotationQuaternion
  67099. */
  67100. set quaternion(q: Nullable<Quaternion>);
  67101. /**
  67102. * Returns a boolean. True if the particle intersects a mesh, else false
  67103. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67104. * @param target is the object (point or mesh) what the intersection is computed against
  67105. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67106. * @returns true if it intersects
  67107. */
  67108. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67109. /**
  67110. * get the rotation matrix of the particle
  67111. * @hidden
  67112. */
  67113. getRotationMatrix(m: Matrix): void;
  67114. }
  67115. /**
  67116. * Represents a group of points in a points cloud system
  67117. * * PCS internal tool, don't use it manually.
  67118. */
  67119. export class PointsGroup {
  67120. /**
  67121. * The group id
  67122. * @hidden
  67123. */
  67124. groupID: number;
  67125. /**
  67126. * image data for group (internal use)
  67127. * @hidden
  67128. */
  67129. _groupImageData: Nullable<ArrayBufferView>;
  67130. /**
  67131. * Image Width (internal use)
  67132. * @hidden
  67133. */
  67134. _groupImgWidth: number;
  67135. /**
  67136. * Image Height (internal use)
  67137. * @hidden
  67138. */
  67139. _groupImgHeight: number;
  67140. /**
  67141. * Custom position function (internal use)
  67142. * @hidden
  67143. */
  67144. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67145. /**
  67146. * density per facet for surface points
  67147. * @hidden
  67148. */
  67149. _groupDensity: number[];
  67150. /**
  67151. * Only when points are colored by texture carries pointer to texture list array
  67152. * @hidden
  67153. */
  67154. _textureNb: number;
  67155. /**
  67156. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67157. * PCS internal tool, don't use it manually.
  67158. * @hidden
  67159. */
  67160. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67161. }
  67162. }
  67163. declare module BABYLON {
  67164. interface Scene {
  67165. /** @hidden (Backing field) */
  67166. _physicsEngine: Nullable<IPhysicsEngine>;
  67167. /** @hidden */
  67168. _physicsTimeAccumulator: number;
  67169. /**
  67170. * Gets the current physics engine
  67171. * @returns a IPhysicsEngine or null if none attached
  67172. */
  67173. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67174. /**
  67175. * Enables physics to the current scene
  67176. * @param gravity defines the scene's gravity for the physics engine
  67177. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67178. * @return a boolean indicating if the physics engine was initialized
  67179. */
  67180. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67181. /**
  67182. * Disables and disposes the physics engine associated with the scene
  67183. */
  67184. disablePhysicsEngine(): void;
  67185. /**
  67186. * Gets a boolean indicating if there is an active physics engine
  67187. * @returns a boolean indicating if there is an active physics engine
  67188. */
  67189. isPhysicsEnabled(): boolean;
  67190. /**
  67191. * Deletes a physics compound impostor
  67192. * @param compound defines the compound to delete
  67193. */
  67194. deleteCompoundImpostor(compound: any): void;
  67195. /**
  67196. * An event triggered when physic simulation is about to be run
  67197. */
  67198. onBeforePhysicsObservable: Observable<Scene>;
  67199. /**
  67200. * An event triggered when physic simulation has been done
  67201. */
  67202. onAfterPhysicsObservable: Observable<Scene>;
  67203. }
  67204. interface AbstractMesh {
  67205. /** @hidden */
  67206. _physicsImpostor: Nullable<PhysicsImpostor>;
  67207. /**
  67208. * Gets or sets impostor used for physic simulation
  67209. * @see http://doc.babylonjs.com/features/physics_engine
  67210. */
  67211. physicsImpostor: Nullable<PhysicsImpostor>;
  67212. /**
  67213. * Gets the current physics impostor
  67214. * @see http://doc.babylonjs.com/features/physics_engine
  67215. * @returns a physics impostor or null
  67216. */
  67217. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67218. /** Apply a physic impulse to the mesh
  67219. * @param force defines the force to apply
  67220. * @param contactPoint defines where to apply the force
  67221. * @returns the current mesh
  67222. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67223. */
  67224. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67225. /**
  67226. * Creates a physic joint between two meshes
  67227. * @param otherMesh defines the other mesh to use
  67228. * @param pivot1 defines the pivot to use on this mesh
  67229. * @param pivot2 defines the pivot to use on the other mesh
  67230. * @param options defines additional options (can be plugin dependent)
  67231. * @returns the current mesh
  67232. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67233. */
  67234. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67235. /** @hidden */
  67236. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67237. }
  67238. /**
  67239. * Defines the physics engine scene component responsible to manage a physics engine
  67240. */
  67241. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67242. /**
  67243. * The component name helpful to identify the component in the list of scene components.
  67244. */
  67245. readonly name: string;
  67246. /**
  67247. * The scene the component belongs to.
  67248. */
  67249. scene: Scene;
  67250. /**
  67251. * Creates a new instance of the component for the given scene
  67252. * @param scene Defines the scene to register the component in
  67253. */
  67254. constructor(scene: Scene);
  67255. /**
  67256. * Registers the component in a given scene
  67257. */
  67258. register(): void;
  67259. /**
  67260. * Rebuilds the elements related to this component in case of
  67261. * context lost for instance.
  67262. */
  67263. rebuild(): void;
  67264. /**
  67265. * Disposes the component and the associated ressources
  67266. */
  67267. dispose(): void;
  67268. }
  67269. }
  67270. declare module BABYLON {
  67271. /**
  67272. * A helper for physics simulations
  67273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67274. */
  67275. export class PhysicsHelper {
  67276. private _scene;
  67277. private _physicsEngine;
  67278. /**
  67279. * Initializes the Physics helper
  67280. * @param scene Babylon.js scene
  67281. */
  67282. constructor(scene: Scene);
  67283. /**
  67284. * Applies a radial explosion impulse
  67285. * @param origin the origin of the explosion
  67286. * @param radiusOrEventOptions the radius or the options of radial explosion
  67287. * @param strength the explosion strength
  67288. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67289. * @returns A physics radial explosion event, or null
  67290. */
  67291. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67292. /**
  67293. * Applies a radial explosion force
  67294. * @param origin the origin of the explosion
  67295. * @param radiusOrEventOptions the radius or the options of radial explosion
  67296. * @param strength the explosion strength
  67297. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67298. * @returns A physics radial explosion event, or null
  67299. */
  67300. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67301. /**
  67302. * Creates a gravitational field
  67303. * @param origin the origin of the explosion
  67304. * @param radiusOrEventOptions the radius or the options of radial explosion
  67305. * @param strength the explosion strength
  67306. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67307. * @returns A physics gravitational field event, or null
  67308. */
  67309. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67310. /**
  67311. * Creates a physics updraft event
  67312. * @param origin the origin of the updraft
  67313. * @param radiusOrEventOptions the radius or the options of the updraft
  67314. * @param strength the strength of the updraft
  67315. * @param height the height of the updraft
  67316. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67317. * @returns A physics updraft event, or null
  67318. */
  67319. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67320. /**
  67321. * Creates a physics vortex event
  67322. * @param origin the of the vortex
  67323. * @param radiusOrEventOptions the radius or the options of the vortex
  67324. * @param strength the strength of the vortex
  67325. * @param height the height of the vortex
  67326. * @returns a Physics vortex event, or null
  67327. * A physics vortex event or null
  67328. */
  67329. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67330. }
  67331. /**
  67332. * Represents a physics radial explosion event
  67333. */
  67334. class PhysicsRadialExplosionEvent {
  67335. private _scene;
  67336. private _options;
  67337. private _sphere;
  67338. private _dataFetched;
  67339. /**
  67340. * Initializes a radial explosioin event
  67341. * @param _scene BabylonJS scene
  67342. * @param _options The options for the vortex event
  67343. */
  67344. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67345. /**
  67346. * Returns the data related to the radial explosion event (sphere).
  67347. * @returns The radial explosion event data
  67348. */
  67349. getData(): PhysicsRadialExplosionEventData;
  67350. /**
  67351. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67352. * @param impostor A physics imposter
  67353. * @param origin the origin of the explosion
  67354. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67355. */
  67356. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67357. /**
  67358. * Triggers affecterd impostors callbacks
  67359. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67360. */
  67361. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67362. /**
  67363. * Disposes the sphere.
  67364. * @param force Specifies if the sphere should be disposed by force
  67365. */
  67366. dispose(force?: boolean): void;
  67367. /*** Helpers ***/
  67368. private _prepareSphere;
  67369. private _intersectsWithSphere;
  67370. }
  67371. /**
  67372. * Represents a gravitational field event
  67373. */
  67374. class PhysicsGravitationalFieldEvent {
  67375. private _physicsHelper;
  67376. private _scene;
  67377. private _origin;
  67378. private _options;
  67379. private _tickCallback;
  67380. private _sphere;
  67381. private _dataFetched;
  67382. /**
  67383. * Initializes the physics gravitational field event
  67384. * @param _physicsHelper A physics helper
  67385. * @param _scene BabylonJS scene
  67386. * @param _origin The origin position of the gravitational field event
  67387. * @param _options The options for the vortex event
  67388. */
  67389. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67390. /**
  67391. * Returns the data related to the gravitational field event (sphere).
  67392. * @returns A gravitational field event
  67393. */
  67394. getData(): PhysicsGravitationalFieldEventData;
  67395. /**
  67396. * Enables the gravitational field.
  67397. */
  67398. enable(): void;
  67399. /**
  67400. * Disables the gravitational field.
  67401. */
  67402. disable(): void;
  67403. /**
  67404. * Disposes the sphere.
  67405. * @param force The force to dispose from the gravitational field event
  67406. */
  67407. dispose(force?: boolean): void;
  67408. private _tick;
  67409. }
  67410. /**
  67411. * Represents a physics updraft event
  67412. */
  67413. class PhysicsUpdraftEvent {
  67414. private _scene;
  67415. private _origin;
  67416. private _options;
  67417. private _physicsEngine;
  67418. private _originTop;
  67419. private _originDirection;
  67420. private _tickCallback;
  67421. private _cylinder;
  67422. private _cylinderPosition;
  67423. private _dataFetched;
  67424. /**
  67425. * Initializes the physics updraft event
  67426. * @param _scene BabylonJS scene
  67427. * @param _origin The origin position of the updraft
  67428. * @param _options The options for the updraft event
  67429. */
  67430. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67431. /**
  67432. * Returns the data related to the updraft event (cylinder).
  67433. * @returns A physics updraft event
  67434. */
  67435. getData(): PhysicsUpdraftEventData;
  67436. /**
  67437. * Enables the updraft.
  67438. */
  67439. enable(): void;
  67440. /**
  67441. * Disables the updraft.
  67442. */
  67443. disable(): void;
  67444. /**
  67445. * Disposes the cylinder.
  67446. * @param force Specifies if the updraft should be disposed by force
  67447. */
  67448. dispose(force?: boolean): void;
  67449. private getImpostorHitData;
  67450. private _tick;
  67451. /*** Helpers ***/
  67452. private _prepareCylinder;
  67453. private _intersectsWithCylinder;
  67454. }
  67455. /**
  67456. * Represents a physics vortex event
  67457. */
  67458. class PhysicsVortexEvent {
  67459. private _scene;
  67460. private _origin;
  67461. private _options;
  67462. private _physicsEngine;
  67463. private _originTop;
  67464. private _tickCallback;
  67465. private _cylinder;
  67466. private _cylinderPosition;
  67467. private _dataFetched;
  67468. /**
  67469. * Initializes the physics vortex event
  67470. * @param _scene The BabylonJS scene
  67471. * @param _origin The origin position of the vortex
  67472. * @param _options The options for the vortex event
  67473. */
  67474. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67475. /**
  67476. * Returns the data related to the vortex event (cylinder).
  67477. * @returns The physics vortex event data
  67478. */
  67479. getData(): PhysicsVortexEventData;
  67480. /**
  67481. * Enables the vortex.
  67482. */
  67483. enable(): void;
  67484. /**
  67485. * Disables the cortex.
  67486. */
  67487. disable(): void;
  67488. /**
  67489. * Disposes the sphere.
  67490. * @param force
  67491. */
  67492. dispose(force?: boolean): void;
  67493. private getImpostorHitData;
  67494. private _tick;
  67495. /*** Helpers ***/
  67496. private _prepareCylinder;
  67497. private _intersectsWithCylinder;
  67498. }
  67499. /**
  67500. * Options fot the radial explosion event
  67501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67502. */
  67503. export class PhysicsRadialExplosionEventOptions {
  67504. /**
  67505. * The radius of the sphere for the radial explosion.
  67506. */
  67507. radius: number;
  67508. /**
  67509. * The strenth of the explosion.
  67510. */
  67511. strength: number;
  67512. /**
  67513. * The strenght of the force in correspondence to the distance of the affected object
  67514. */
  67515. falloff: PhysicsRadialImpulseFalloff;
  67516. /**
  67517. * Sphere options for the radial explosion.
  67518. */
  67519. sphere: {
  67520. segments: number;
  67521. diameter: number;
  67522. };
  67523. /**
  67524. * Sphere options for the radial explosion.
  67525. */
  67526. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67527. }
  67528. /**
  67529. * Options fot the updraft event
  67530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67531. */
  67532. export class PhysicsUpdraftEventOptions {
  67533. /**
  67534. * The radius of the cylinder for the vortex
  67535. */
  67536. radius: number;
  67537. /**
  67538. * The strenth of the updraft.
  67539. */
  67540. strength: number;
  67541. /**
  67542. * The height of the cylinder for the updraft.
  67543. */
  67544. height: number;
  67545. /**
  67546. * The mode for the the updraft.
  67547. */
  67548. updraftMode: PhysicsUpdraftMode;
  67549. }
  67550. /**
  67551. * Options fot the vortex event
  67552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67553. */
  67554. export class PhysicsVortexEventOptions {
  67555. /**
  67556. * The radius of the cylinder for the vortex
  67557. */
  67558. radius: number;
  67559. /**
  67560. * The strenth of the vortex.
  67561. */
  67562. strength: number;
  67563. /**
  67564. * The height of the cylinder for the vortex.
  67565. */
  67566. height: number;
  67567. /**
  67568. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67569. */
  67570. centripetalForceThreshold: number;
  67571. /**
  67572. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67573. */
  67574. centripetalForceMultiplier: number;
  67575. /**
  67576. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67577. */
  67578. centrifugalForceMultiplier: number;
  67579. /**
  67580. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67581. */
  67582. updraftForceMultiplier: number;
  67583. }
  67584. /**
  67585. * The strenght of the force in correspondence to the distance of the affected object
  67586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67587. */
  67588. export enum PhysicsRadialImpulseFalloff {
  67589. /** Defines that impulse is constant in strength across it's whole radius */
  67590. Constant = 0,
  67591. /** Defines that impulse gets weaker if it's further from the origin */
  67592. Linear = 1
  67593. }
  67594. /**
  67595. * The strength of the force in correspondence to the distance of the affected object
  67596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67597. */
  67598. export enum PhysicsUpdraftMode {
  67599. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67600. Center = 0,
  67601. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67602. Perpendicular = 1
  67603. }
  67604. /**
  67605. * Interface for a physics hit data
  67606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67607. */
  67608. export interface PhysicsHitData {
  67609. /**
  67610. * The force applied at the contact point
  67611. */
  67612. force: Vector3;
  67613. /**
  67614. * The contact point
  67615. */
  67616. contactPoint: Vector3;
  67617. /**
  67618. * The distance from the origin to the contact point
  67619. */
  67620. distanceFromOrigin: number;
  67621. }
  67622. /**
  67623. * Interface for radial explosion event data
  67624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67625. */
  67626. export interface PhysicsRadialExplosionEventData {
  67627. /**
  67628. * A sphere used for the radial explosion event
  67629. */
  67630. sphere: Mesh;
  67631. }
  67632. /**
  67633. * Interface for gravitational field event data
  67634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67635. */
  67636. export interface PhysicsGravitationalFieldEventData {
  67637. /**
  67638. * A sphere mesh used for the gravitational field event
  67639. */
  67640. sphere: Mesh;
  67641. }
  67642. /**
  67643. * Interface for updraft event data
  67644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67645. */
  67646. export interface PhysicsUpdraftEventData {
  67647. /**
  67648. * A cylinder used for the updraft event
  67649. */
  67650. cylinder: Mesh;
  67651. }
  67652. /**
  67653. * Interface for vortex event data
  67654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67655. */
  67656. export interface PhysicsVortexEventData {
  67657. /**
  67658. * A cylinder used for the vortex event
  67659. */
  67660. cylinder: Mesh;
  67661. }
  67662. /**
  67663. * Interface for an affected physics impostor
  67664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67665. */
  67666. export interface PhysicsAffectedImpostorWithData {
  67667. /**
  67668. * The impostor affected by the effect
  67669. */
  67670. impostor: PhysicsImpostor;
  67671. /**
  67672. * The data about the hit/horce from the explosion
  67673. */
  67674. hitData: PhysicsHitData;
  67675. }
  67676. }
  67677. declare module BABYLON {
  67678. /** @hidden */
  67679. export var blackAndWhitePixelShader: {
  67680. name: string;
  67681. shader: string;
  67682. };
  67683. }
  67684. declare module BABYLON {
  67685. /**
  67686. * Post process used to render in black and white
  67687. */
  67688. export class BlackAndWhitePostProcess extends PostProcess {
  67689. /**
  67690. * Linear about to convert he result to black and white (default: 1)
  67691. */
  67692. degree: number;
  67693. /**
  67694. * Creates a black and white post process
  67695. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67696. * @param name The name of the effect.
  67697. * @param options The required width/height ratio to downsize to before computing the render pass.
  67698. * @param camera The camera to apply the render pass to.
  67699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67700. * @param engine The engine which the post process will be applied. (default: current engine)
  67701. * @param reusable If the post process can be reused on the same frame. (default: false)
  67702. */
  67703. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67704. }
  67705. }
  67706. declare module BABYLON {
  67707. /**
  67708. * This represents a set of one or more post processes in Babylon.
  67709. * A post process can be used to apply a shader to a texture after it is rendered.
  67710. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67711. */
  67712. export class PostProcessRenderEffect {
  67713. private _postProcesses;
  67714. private _getPostProcesses;
  67715. private _singleInstance;
  67716. private _cameras;
  67717. private _indicesForCamera;
  67718. /**
  67719. * Name of the effect
  67720. * @hidden
  67721. */
  67722. _name: string;
  67723. /**
  67724. * Instantiates a post process render effect.
  67725. * A post process can be used to apply a shader to a texture after it is rendered.
  67726. * @param engine The engine the effect is tied to
  67727. * @param name The name of the effect
  67728. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67729. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67730. */
  67731. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67732. /**
  67733. * Checks if all the post processes in the effect are supported.
  67734. */
  67735. get isSupported(): boolean;
  67736. /**
  67737. * Updates the current state of the effect
  67738. * @hidden
  67739. */
  67740. _update(): void;
  67741. /**
  67742. * Attaches the effect on cameras
  67743. * @param cameras The camera to attach to.
  67744. * @hidden
  67745. */
  67746. _attachCameras(cameras: Camera): void;
  67747. /**
  67748. * Attaches the effect on cameras
  67749. * @param cameras The camera to attach to.
  67750. * @hidden
  67751. */
  67752. _attachCameras(cameras: Camera[]): void;
  67753. /**
  67754. * Detaches the effect on cameras
  67755. * @param cameras The camera to detatch from.
  67756. * @hidden
  67757. */
  67758. _detachCameras(cameras: Camera): void;
  67759. /**
  67760. * Detatches the effect on cameras
  67761. * @param cameras The camera to detatch from.
  67762. * @hidden
  67763. */
  67764. _detachCameras(cameras: Camera[]): void;
  67765. /**
  67766. * Enables the effect on given cameras
  67767. * @param cameras The camera to enable.
  67768. * @hidden
  67769. */
  67770. _enable(cameras: Camera): void;
  67771. /**
  67772. * Enables the effect on given cameras
  67773. * @param cameras The camera to enable.
  67774. * @hidden
  67775. */
  67776. _enable(cameras: Nullable<Camera[]>): void;
  67777. /**
  67778. * Disables the effect on the given cameras
  67779. * @param cameras The camera to disable.
  67780. * @hidden
  67781. */
  67782. _disable(cameras: Camera): void;
  67783. /**
  67784. * Disables the effect on the given cameras
  67785. * @param cameras The camera to disable.
  67786. * @hidden
  67787. */
  67788. _disable(cameras: Nullable<Camera[]>): void;
  67789. /**
  67790. * Gets a list of the post processes contained in the effect.
  67791. * @param camera The camera to get the post processes on.
  67792. * @returns The list of the post processes in the effect.
  67793. */
  67794. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67795. }
  67796. }
  67797. declare module BABYLON {
  67798. /** @hidden */
  67799. export var extractHighlightsPixelShader: {
  67800. name: string;
  67801. shader: string;
  67802. };
  67803. }
  67804. declare module BABYLON {
  67805. /**
  67806. * 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.
  67807. */
  67808. export class ExtractHighlightsPostProcess extends PostProcess {
  67809. /**
  67810. * The luminance threshold, pixels below this value will be set to black.
  67811. */
  67812. threshold: number;
  67813. /** @hidden */
  67814. _exposure: number;
  67815. /**
  67816. * Post process which has the input texture to be used when performing highlight extraction
  67817. * @hidden
  67818. */
  67819. _inputPostProcess: Nullable<PostProcess>;
  67820. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67821. }
  67822. }
  67823. declare module BABYLON {
  67824. /** @hidden */
  67825. export var bloomMergePixelShader: {
  67826. name: string;
  67827. shader: string;
  67828. };
  67829. }
  67830. declare module BABYLON {
  67831. /**
  67832. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67833. */
  67834. export class BloomMergePostProcess extends PostProcess {
  67835. /** Weight of the bloom to be added to the original input. */
  67836. weight: number;
  67837. /**
  67838. * Creates a new instance of @see BloomMergePostProcess
  67839. * @param name The name of the effect.
  67840. * @param originalFromInput Post process which's input will be used for the merge.
  67841. * @param blurred Blurred highlights post process which's output will be used.
  67842. * @param weight Weight of the bloom to be added to the original input.
  67843. * @param options The required width/height ratio to downsize to before computing the render pass.
  67844. * @param camera The camera to apply the render pass to.
  67845. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67846. * @param engine The engine which the post process will be applied. (default: current engine)
  67847. * @param reusable If the post process can be reused on the same frame. (default: false)
  67848. * @param textureType Type of textures used when performing the post process. (default: 0)
  67849. * @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)
  67850. */
  67851. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67852. /** Weight of the bloom to be added to the original input. */
  67853. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67854. }
  67855. }
  67856. declare module BABYLON {
  67857. /**
  67858. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67859. */
  67860. export class BloomEffect extends PostProcessRenderEffect {
  67861. private bloomScale;
  67862. /**
  67863. * @hidden Internal
  67864. */
  67865. _effects: Array<PostProcess>;
  67866. /**
  67867. * @hidden Internal
  67868. */
  67869. _downscale: ExtractHighlightsPostProcess;
  67870. private _blurX;
  67871. private _blurY;
  67872. private _merge;
  67873. /**
  67874. * The luminance threshold to find bright areas of the image to bloom.
  67875. */
  67876. get threshold(): number;
  67877. set threshold(value: number);
  67878. /**
  67879. * The strength of the bloom.
  67880. */
  67881. get weight(): number;
  67882. set weight(value: number);
  67883. /**
  67884. * Specifies the size of the bloom blur kernel, relative to the final output size
  67885. */
  67886. get kernel(): number;
  67887. set kernel(value: number);
  67888. /**
  67889. * Creates a new instance of @see BloomEffect
  67890. * @param scene The scene the effect belongs to.
  67891. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67892. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67893. * @param bloomWeight The the strength of bloom.
  67894. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67895. * @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)
  67896. */
  67897. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67898. /**
  67899. * Disposes each of the internal effects for a given camera.
  67900. * @param camera The camera to dispose the effect on.
  67901. */
  67902. disposeEffects(camera: Camera): void;
  67903. /**
  67904. * @hidden Internal
  67905. */
  67906. _updateEffects(): void;
  67907. /**
  67908. * Internal
  67909. * @returns if all the contained post processes are ready.
  67910. * @hidden
  67911. */
  67912. _isReady(): boolean;
  67913. }
  67914. }
  67915. declare module BABYLON {
  67916. /** @hidden */
  67917. export var chromaticAberrationPixelShader: {
  67918. name: string;
  67919. shader: string;
  67920. };
  67921. }
  67922. declare module BABYLON {
  67923. /**
  67924. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67925. */
  67926. export class ChromaticAberrationPostProcess extends PostProcess {
  67927. /**
  67928. * The amount of seperation of rgb channels (default: 30)
  67929. */
  67930. aberrationAmount: number;
  67931. /**
  67932. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67933. */
  67934. radialIntensity: number;
  67935. /**
  67936. * 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))
  67937. */
  67938. direction: Vector2;
  67939. /**
  67940. * 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))
  67941. */
  67942. centerPosition: Vector2;
  67943. /**
  67944. * Creates a new instance ChromaticAberrationPostProcess
  67945. * @param name The name of the effect.
  67946. * @param screenWidth The width of the screen to apply the effect on.
  67947. * @param screenHeight The height of the screen to apply the effect on.
  67948. * @param options The required width/height ratio to downsize to before computing the render pass.
  67949. * @param camera The camera to apply the render pass to.
  67950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67951. * @param engine The engine which the post process will be applied. (default: current engine)
  67952. * @param reusable If the post process can be reused on the same frame. (default: false)
  67953. * @param textureType Type of textures used when performing the post process. (default: 0)
  67954. * @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)
  67955. */
  67956. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67957. }
  67958. }
  67959. declare module BABYLON {
  67960. /** @hidden */
  67961. export var circleOfConfusionPixelShader: {
  67962. name: string;
  67963. shader: string;
  67964. };
  67965. }
  67966. declare module BABYLON {
  67967. /**
  67968. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67969. */
  67970. export class CircleOfConfusionPostProcess extends PostProcess {
  67971. /**
  67972. * 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.
  67973. */
  67974. lensSize: number;
  67975. /**
  67976. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67977. */
  67978. fStop: number;
  67979. /**
  67980. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67981. */
  67982. focusDistance: number;
  67983. /**
  67984. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67985. */
  67986. focalLength: number;
  67987. private _depthTexture;
  67988. /**
  67989. * Creates a new instance CircleOfConfusionPostProcess
  67990. * @param name The name of the effect.
  67991. * @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.
  67992. * @param options The required width/height ratio to downsize to before computing the render pass.
  67993. * @param camera The camera to apply the render pass to.
  67994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67995. * @param engine The engine which the post process will be applied. (default: current engine)
  67996. * @param reusable If the post process can be reused on the same frame. (default: false)
  67997. * @param textureType Type of textures used when performing the post process. (default: 0)
  67998. * @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)
  67999. */
  68000. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68001. /**
  68002. * 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.
  68003. */
  68004. set depthTexture(value: RenderTargetTexture);
  68005. }
  68006. }
  68007. declare module BABYLON {
  68008. /** @hidden */
  68009. export var colorCorrectionPixelShader: {
  68010. name: string;
  68011. shader: string;
  68012. };
  68013. }
  68014. declare module BABYLON {
  68015. /**
  68016. *
  68017. * This post-process allows the modification of rendered colors by using
  68018. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68019. *
  68020. * The object needs to be provided an url to a texture containing the color
  68021. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68022. * Use an image editing software to tweak the LUT to match your needs.
  68023. *
  68024. * For an example of a color LUT, see here:
  68025. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68026. * For explanations on color grading, see here:
  68027. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68028. *
  68029. */
  68030. export class ColorCorrectionPostProcess extends PostProcess {
  68031. private _colorTableTexture;
  68032. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68033. }
  68034. }
  68035. declare module BABYLON {
  68036. /** @hidden */
  68037. export var convolutionPixelShader: {
  68038. name: string;
  68039. shader: string;
  68040. };
  68041. }
  68042. declare module BABYLON {
  68043. /**
  68044. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68045. * input texture to perform effects such as edge detection or sharpening
  68046. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68047. */
  68048. export class ConvolutionPostProcess extends PostProcess {
  68049. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68050. kernel: number[];
  68051. /**
  68052. * Creates a new instance ConvolutionPostProcess
  68053. * @param name The name of the effect.
  68054. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68055. * @param options The required width/height ratio to downsize to before computing the render pass.
  68056. * @param camera The camera to apply the render pass to.
  68057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68058. * @param engine The engine which the post process will be applied. (default: current engine)
  68059. * @param reusable If the post process can be reused on the same frame. (default: false)
  68060. * @param textureType Type of textures used when performing the post process. (default: 0)
  68061. */
  68062. constructor(name: string,
  68063. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68064. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68065. /**
  68066. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68067. */
  68068. static EdgeDetect0Kernel: number[];
  68069. /**
  68070. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68071. */
  68072. static EdgeDetect1Kernel: number[];
  68073. /**
  68074. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68075. */
  68076. static EdgeDetect2Kernel: number[];
  68077. /**
  68078. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68079. */
  68080. static SharpenKernel: number[];
  68081. /**
  68082. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68083. */
  68084. static EmbossKernel: number[];
  68085. /**
  68086. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68087. */
  68088. static GaussianKernel: number[];
  68089. }
  68090. }
  68091. declare module BABYLON {
  68092. /**
  68093. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68094. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68095. * based on samples that have a large difference in distance than the center pixel.
  68096. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68097. */
  68098. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68099. direction: Vector2;
  68100. /**
  68101. * Creates a new instance CircleOfConfusionPostProcess
  68102. * @param name The name of the effect.
  68103. * @param scene The scene the effect belongs to.
  68104. * @param direction The direction the blur should be applied.
  68105. * @param kernel The size of the kernel used to blur.
  68106. * @param options The required width/height ratio to downsize to before computing the render pass.
  68107. * @param camera The camera to apply the render pass to.
  68108. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68109. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68111. * @param engine The engine which the post process will be applied. (default: current engine)
  68112. * @param reusable If the post process can be reused on the same frame. (default: false)
  68113. * @param textureType Type of textures used when performing the post process. (default: 0)
  68114. * @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)
  68115. */
  68116. 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);
  68117. }
  68118. }
  68119. declare module BABYLON {
  68120. /** @hidden */
  68121. export var depthOfFieldMergePixelShader: {
  68122. name: string;
  68123. shader: string;
  68124. };
  68125. }
  68126. declare module BABYLON {
  68127. /**
  68128. * Options to be set when merging outputs from the default pipeline.
  68129. */
  68130. export class DepthOfFieldMergePostProcessOptions {
  68131. /**
  68132. * The original image to merge on top of
  68133. */
  68134. originalFromInput: PostProcess;
  68135. /**
  68136. * Parameters to perform the merge of the depth of field effect
  68137. */
  68138. depthOfField?: {
  68139. circleOfConfusion: PostProcess;
  68140. blurSteps: Array<PostProcess>;
  68141. };
  68142. /**
  68143. * Parameters to perform the merge of bloom effect
  68144. */
  68145. bloom?: {
  68146. blurred: PostProcess;
  68147. weight: number;
  68148. };
  68149. }
  68150. /**
  68151. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68152. */
  68153. export class DepthOfFieldMergePostProcess extends PostProcess {
  68154. private blurSteps;
  68155. /**
  68156. * Creates a new instance of DepthOfFieldMergePostProcess
  68157. * @param name The name of the effect.
  68158. * @param originalFromInput Post process which's input will be used for the merge.
  68159. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68160. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68161. * @param options The required width/height ratio to downsize to before computing the render pass.
  68162. * @param camera The camera to apply the render pass to.
  68163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68164. * @param engine The engine which the post process will be applied. (default: current engine)
  68165. * @param reusable If the post process can be reused on the same frame. (default: false)
  68166. * @param textureType Type of textures used when performing the post process. (default: 0)
  68167. * @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)
  68168. */
  68169. 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);
  68170. /**
  68171. * Updates the effect with the current post process compile time values and recompiles the shader.
  68172. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68173. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68174. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68175. * @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
  68176. * @param onCompiled Called when the shader has been compiled.
  68177. * @param onError Called if there is an error when compiling a shader.
  68178. */
  68179. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68180. }
  68181. }
  68182. declare module BABYLON {
  68183. /**
  68184. * Specifies the level of max blur that should be applied when using the depth of field effect
  68185. */
  68186. export enum DepthOfFieldEffectBlurLevel {
  68187. /**
  68188. * Subtle blur
  68189. */
  68190. Low = 0,
  68191. /**
  68192. * Medium blur
  68193. */
  68194. Medium = 1,
  68195. /**
  68196. * Large blur
  68197. */
  68198. High = 2
  68199. }
  68200. /**
  68201. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68202. */
  68203. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68204. private _circleOfConfusion;
  68205. /**
  68206. * @hidden Internal, blurs from high to low
  68207. */
  68208. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68209. private _depthOfFieldBlurY;
  68210. private _dofMerge;
  68211. /**
  68212. * @hidden Internal post processes in depth of field effect
  68213. */
  68214. _effects: Array<PostProcess>;
  68215. /**
  68216. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68217. */
  68218. set focalLength(value: number);
  68219. get focalLength(): number;
  68220. /**
  68221. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68222. */
  68223. set fStop(value: number);
  68224. get fStop(): number;
  68225. /**
  68226. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68227. */
  68228. set focusDistance(value: number);
  68229. get focusDistance(): number;
  68230. /**
  68231. * 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.
  68232. */
  68233. set lensSize(value: number);
  68234. get lensSize(): number;
  68235. /**
  68236. * Creates a new instance DepthOfFieldEffect
  68237. * @param scene The scene the effect belongs to.
  68238. * @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.
  68239. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68240. * @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)
  68241. */
  68242. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68243. /**
  68244. * Get the current class name of the current effet
  68245. * @returns "DepthOfFieldEffect"
  68246. */
  68247. getClassName(): string;
  68248. /**
  68249. * 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.
  68250. */
  68251. set depthTexture(value: RenderTargetTexture);
  68252. /**
  68253. * Disposes each of the internal effects for a given camera.
  68254. * @param camera The camera to dispose the effect on.
  68255. */
  68256. disposeEffects(camera: Camera): void;
  68257. /**
  68258. * @hidden Internal
  68259. */
  68260. _updateEffects(): void;
  68261. /**
  68262. * Internal
  68263. * @returns if all the contained post processes are ready.
  68264. * @hidden
  68265. */
  68266. _isReady(): boolean;
  68267. }
  68268. }
  68269. declare module BABYLON {
  68270. /** @hidden */
  68271. export var displayPassPixelShader: {
  68272. name: string;
  68273. shader: string;
  68274. };
  68275. }
  68276. declare module BABYLON {
  68277. /**
  68278. * DisplayPassPostProcess which produces an output the same as it's input
  68279. */
  68280. export class DisplayPassPostProcess extends PostProcess {
  68281. /**
  68282. * Creates the DisplayPassPostProcess
  68283. * @param name The name of the effect.
  68284. * @param options The required width/height ratio to downsize to before computing the render pass.
  68285. * @param camera The camera to apply the render pass to.
  68286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68287. * @param engine The engine which the post process will be applied. (default: current engine)
  68288. * @param reusable If the post process can be reused on the same frame. (default: false)
  68289. */
  68290. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68291. }
  68292. }
  68293. declare module BABYLON {
  68294. /** @hidden */
  68295. export var filterPixelShader: {
  68296. name: string;
  68297. shader: string;
  68298. };
  68299. }
  68300. declare module BABYLON {
  68301. /**
  68302. * Applies a kernel filter to the image
  68303. */
  68304. export class FilterPostProcess extends PostProcess {
  68305. /** The matrix to be applied to the image */
  68306. kernelMatrix: Matrix;
  68307. /**
  68308. *
  68309. * @param name The name of the effect.
  68310. * @param kernelMatrix The matrix to be applied to the image
  68311. * @param options The required width/height ratio to downsize to before computing the render pass.
  68312. * @param camera The camera to apply the render pass to.
  68313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68314. * @param engine The engine which the post process will be applied. (default: current engine)
  68315. * @param reusable If the post process can be reused on the same frame. (default: false)
  68316. */
  68317. constructor(name: string,
  68318. /** The matrix to be applied to the image */
  68319. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68320. }
  68321. }
  68322. declare module BABYLON {
  68323. /** @hidden */
  68324. export var fxaaPixelShader: {
  68325. name: string;
  68326. shader: string;
  68327. };
  68328. }
  68329. declare module BABYLON {
  68330. /** @hidden */
  68331. export var fxaaVertexShader: {
  68332. name: string;
  68333. shader: string;
  68334. };
  68335. }
  68336. declare module BABYLON {
  68337. /**
  68338. * Fxaa post process
  68339. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68340. */
  68341. export class FxaaPostProcess extends PostProcess {
  68342. /** @hidden */
  68343. texelWidth: number;
  68344. /** @hidden */
  68345. texelHeight: number;
  68346. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68347. private _getDefines;
  68348. }
  68349. }
  68350. declare module BABYLON {
  68351. /** @hidden */
  68352. export var grainPixelShader: {
  68353. name: string;
  68354. shader: string;
  68355. };
  68356. }
  68357. declare module BABYLON {
  68358. /**
  68359. * The GrainPostProcess adds noise to the image at mid luminance levels
  68360. */
  68361. export class GrainPostProcess extends PostProcess {
  68362. /**
  68363. * The intensity of the grain added (default: 30)
  68364. */
  68365. intensity: number;
  68366. /**
  68367. * If the grain should be randomized on every frame
  68368. */
  68369. animated: boolean;
  68370. /**
  68371. * Creates a new instance of @see GrainPostProcess
  68372. * @param name The name of the effect.
  68373. * @param options The required width/height ratio to downsize to before computing the render pass.
  68374. * @param camera The camera to apply the render pass to.
  68375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68376. * @param engine The engine which the post process will be applied. (default: current engine)
  68377. * @param reusable If the post process can be reused on the same frame. (default: false)
  68378. * @param textureType Type of textures used when performing the post process. (default: 0)
  68379. * @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)
  68380. */
  68381. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68382. }
  68383. }
  68384. declare module BABYLON {
  68385. /** @hidden */
  68386. export var highlightsPixelShader: {
  68387. name: string;
  68388. shader: string;
  68389. };
  68390. }
  68391. declare module BABYLON {
  68392. /**
  68393. * Extracts highlights from the image
  68394. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68395. */
  68396. export class HighlightsPostProcess extends PostProcess {
  68397. /**
  68398. * Extracts highlights from the image
  68399. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68400. * @param name The name of the effect.
  68401. * @param options The required width/height ratio to downsize to before computing the render pass.
  68402. * @param camera The camera to apply the render pass to.
  68403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68404. * @param engine The engine which the post process will be applied. (default: current engine)
  68405. * @param reusable If the post process can be reused on the same frame. (default: false)
  68406. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68407. */
  68408. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68409. }
  68410. }
  68411. declare module BABYLON {
  68412. /** @hidden */
  68413. export var mrtFragmentDeclaration: {
  68414. name: string;
  68415. shader: string;
  68416. };
  68417. }
  68418. declare module BABYLON {
  68419. /** @hidden */
  68420. export var geometryPixelShader: {
  68421. name: string;
  68422. shader: string;
  68423. };
  68424. }
  68425. declare module BABYLON {
  68426. /** @hidden */
  68427. export var geometryVertexShader: {
  68428. name: string;
  68429. shader: string;
  68430. };
  68431. }
  68432. declare module BABYLON {
  68433. /** @hidden */
  68434. interface ISavedTransformationMatrix {
  68435. world: Matrix;
  68436. viewProjection: Matrix;
  68437. }
  68438. /**
  68439. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68440. */
  68441. export class GeometryBufferRenderer {
  68442. /**
  68443. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68444. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68445. */
  68446. static readonly POSITION_TEXTURE_TYPE: number;
  68447. /**
  68448. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68449. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68450. */
  68451. static readonly VELOCITY_TEXTURE_TYPE: number;
  68452. /**
  68453. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68454. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68455. */
  68456. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68457. /**
  68458. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68459. * in order to compute objects velocities when enableVelocity is set to "true"
  68460. * @hidden
  68461. */
  68462. _previousTransformationMatrices: {
  68463. [index: number]: ISavedTransformationMatrix;
  68464. };
  68465. /**
  68466. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68467. * in order to compute objects velocities when enableVelocity is set to "true"
  68468. * @hidden
  68469. */
  68470. _previousBonesTransformationMatrices: {
  68471. [index: number]: Float32Array;
  68472. };
  68473. /**
  68474. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68475. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68476. */
  68477. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68478. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68479. renderTransparentMeshes: boolean;
  68480. private _scene;
  68481. private _multiRenderTarget;
  68482. private _ratio;
  68483. private _enablePosition;
  68484. private _enableVelocity;
  68485. private _enableReflectivity;
  68486. private _positionIndex;
  68487. private _velocityIndex;
  68488. private _reflectivityIndex;
  68489. protected _effect: Effect;
  68490. protected _cachedDefines: string;
  68491. /**
  68492. * Set the render list (meshes to be rendered) used in the G buffer.
  68493. */
  68494. set renderList(meshes: Mesh[]);
  68495. /**
  68496. * Gets wether or not G buffer are supported by the running hardware.
  68497. * This requires draw buffer supports
  68498. */
  68499. get isSupported(): boolean;
  68500. /**
  68501. * Returns the index of the given texture type in the G-Buffer textures array
  68502. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68503. * @returns the index of the given texture type in the G-Buffer textures array
  68504. */
  68505. getTextureIndex(textureType: number): number;
  68506. /**
  68507. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68508. */
  68509. get enablePosition(): boolean;
  68510. /**
  68511. * Sets whether or not objects positions are enabled for the G buffer.
  68512. */
  68513. set enablePosition(enable: boolean);
  68514. /**
  68515. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68516. */
  68517. get enableVelocity(): boolean;
  68518. /**
  68519. * Sets wether or not objects velocities are enabled for the G buffer.
  68520. */
  68521. set enableVelocity(enable: boolean);
  68522. /**
  68523. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68524. */
  68525. get enableReflectivity(): boolean;
  68526. /**
  68527. * Sets wether or not objects roughness are enabled for the G buffer.
  68528. */
  68529. set enableReflectivity(enable: boolean);
  68530. /**
  68531. * Gets the scene associated with the buffer.
  68532. */
  68533. get scene(): Scene;
  68534. /**
  68535. * Gets the ratio used by the buffer during its creation.
  68536. * How big is the buffer related to the main canvas.
  68537. */
  68538. get ratio(): number;
  68539. /** @hidden */
  68540. static _SceneComponentInitialization: (scene: Scene) => void;
  68541. /**
  68542. * Creates a new G Buffer for the scene
  68543. * @param scene The scene the buffer belongs to
  68544. * @param ratio How big is the buffer related to the main canvas.
  68545. */
  68546. constructor(scene: Scene, ratio?: number);
  68547. /**
  68548. * Checks wether everything is ready to render a submesh to the G buffer.
  68549. * @param subMesh the submesh to check readiness for
  68550. * @param useInstances is the mesh drawn using instance or not
  68551. * @returns true if ready otherwise false
  68552. */
  68553. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68554. /**
  68555. * Gets the current underlying G Buffer.
  68556. * @returns the buffer
  68557. */
  68558. getGBuffer(): MultiRenderTarget;
  68559. /**
  68560. * Gets the number of samples used to render the buffer (anti aliasing).
  68561. */
  68562. get samples(): number;
  68563. /**
  68564. * Sets the number of samples used to render the buffer (anti aliasing).
  68565. */
  68566. set samples(value: number);
  68567. /**
  68568. * Disposes the renderer and frees up associated resources.
  68569. */
  68570. dispose(): void;
  68571. protected _createRenderTargets(): void;
  68572. private _copyBonesTransformationMatrices;
  68573. }
  68574. }
  68575. declare module BABYLON {
  68576. interface Scene {
  68577. /** @hidden (Backing field) */
  68578. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68579. /**
  68580. * Gets or Sets the current geometry buffer associated to the scene.
  68581. */
  68582. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68583. /**
  68584. * Enables a GeometryBufferRender and associates it with the scene
  68585. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68586. * @returns the GeometryBufferRenderer
  68587. */
  68588. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68589. /**
  68590. * Disables the GeometryBufferRender associated with the scene
  68591. */
  68592. disableGeometryBufferRenderer(): void;
  68593. }
  68594. /**
  68595. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68596. * in several rendering techniques.
  68597. */
  68598. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68599. /**
  68600. * The component name helpful to identify the component in the list of scene components.
  68601. */
  68602. readonly name: string;
  68603. /**
  68604. * The scene the component belongs to.
  68605. */
  68606. scene: Scene;
  68607. /**
  68608. * Creates a new instance of the component for the given scene
  68609. * @param scene Defines the scene to register the component in
  68610. */
  68611. constructor(scene: Scene);
  68612. /**
  68613. * Registers the component in a given scene
  68614. */
  68615. register(): void;
  68616. /**
  68617. * Rebuilds the elements related to this component in case of
  68618. * context lost for instance.
  68619. */
  68620. rebuild(): void;
  68621. /**
  68622. * Disposes the component and the associated ressources
  68623. */
  68624. dispose(): void;
  68625. private _gatherRenderTargets;
  68626. }
  68627. }
  68628. declare module BABYLON {
  68629. /** @hidden */
  68630. export var motionBlurPixelShader: {
  68631. name: string;
  68632. shader: string;
  68633. };
  68634. }
  68635. declare module BABYLON {
  68636. /**
  68637. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68638. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68639. * As an example, all you have to do is to create the post-process:
  68640. * var mb = new BABYLON.MotionBlurPostProcess(
  68641. * 'mb', // The name of the effect.
  68642. * scene, // The scene containing the objects to blur according to their velocity.
  68643. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68644. * camera // The camera to apply the render pass to.
  68645. * );
  68646. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68647. */
  68648. export class MotionBlurPostProcess extends PostProcess {
  68649. /**
  68650. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68651. */
  68652. motionStrength: number;
  68653. /**
  68654. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68655. */
  68656. get motionBlurSamples(): number;
  68657. /**
  68658. * Sets the number of iterations to be used for motion blur quality
  68659. */
  68660. set motionBlurSamples(samples: number);
  68661. private _motionBlurSamples;
  68662. private _geometryBufferRenderer;
  68663. /**
  68664. * Creates a new instance MotionBlurPostProcess
  68665. * @param name The name of the effect.
  68666. * @param scene The scene containing the objects to blur according to their velocity.
  68667. * @param options The required width/height ratio to downsize to before computing the render pass.
  68668. * @param camera The camera to apply the render pass to.
  68669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68670. * @param engine The engine which the post process will be applied. (default: current engine)
  68671. * @param reusable If the post process can be reused on the same frame. (default: false)
  68672. * @param textureType Type of textures used when performing the post process. (default: 0)
  68673. * @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)
  68674. */
  68675. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68676. /**
  68677. * Excludes the given skinned mesh from computing bones velocities.
  68678. * 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.
  68679. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68680. */
  68681. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68682. /**
  68683. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68684. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68685. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68686. */
  68687. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68688. /**
  68689. * Disposes the post process.
  68690. * @param camera The camera to dispose the post process on.
  68691. */
  68692. dispose(camera?: Camera): void;
  68693. }
  68694. }
  68695. declare module BABYLON {
  68696. /** @hidden */
  68697. export var refractionPixelShader: {
  68698. name: string;
  68699. shader: string;
  68700. };
  68701. }
  68702. declare module BABYLON {
  68703. /**
  68704. * Post process which applies a refractin texture
  68705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68706. */
  68707. export class RefractionPostProcess extends PostProcess {
  68708. /** the base color of the refraction (used to taint the rendering) */
  68709. color: Color3;
  68710. /** simulated refraction depth */
  68711. depth: number;
  68712. /** the coefficient of the base color (0 to remove base color tainting) */
  68713. colorLevel: number;
  68714. private _refTexture;
  68715. private _ownRefractionTexture;
  68716. /**
  68717. * Gets or sets the refraction texture
  68718. * Please note that you are responsible for disposing the texture if you set it manually
  68719. */
  68720. get refractionTexture(): Texture;
  68721. set refractionTexture(value: Texture);
  68722. /**
  68723. * Initializes the RefractionPostProcess
  68724. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68725. * @param name The name of the effect.
  68726. * @param refractionTextureUrl Url of the refraction texture to use
  68727. * @param color the base color of the refraction (used to taint the rendering)
  68728. * @param depth simulated refraction depth
  68729. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68730. * @param camera The camera to apply the render pass to.
  68731. * @param options The required width/height ratio to downsize to before computing the render pass.
  68732. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68733. * @param engine The engine which the post process will be applied. (default: current engine)
  68734. * @param reusable If the post process can be reused on the same frame. (default: false)
  68735. */
  68736. constructor(name: string, refractionTextureUrl: string,
  68737. /** the base color of the refraction (used to taint the rendering) */
  68738. color: Color3,
  68739. /** simulated refraction depth */
  68740. depth: number,
  68741. /** the coefficient of the base color (0 to remove base color tainting) */
  68742. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68743. /**
  68744. * Disposes of the post process
  68745. * @param camera Camera to dispose post process on
  68746. */
  68747. dispose(camera: Camera): void;
  68748. }
  68749. }
  68750. declare module BABYLON {
  68751. /** @hidden */
  68752. export var sharpenPixelShader: {
  68753. name: string;
  68754. shader: string;
  68755. };
  68756. }
  68757. declare module BABYLON {
  68758. /**
  68759. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68760. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68761. */
  68762. export class SharpenPostProcess extends PostProcess {
  68763. /**
  68764. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68765. */
  68766. colorAmount: number;
  68767. /**
  68768. * How much sharpness should be applied (default: 0.3)
  68769. */
  68770. edgeAmount: number;
  68771. /**
  68772. * Creates a new instance ConvolutionPostProcess
  68773. * @param name The name of the effect.
  68774. * @param options The required width/height ratio to downsize to before computing the render pass.
  68775. * @param camera The camera to apply the render pass to.
  68776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68777. * @param engine The engine which the post process will be applied. (default: current engine)
  68778. * @param reusable If the post process can be reused on the same frame. (default: false)
  68779. * @param textureType Type of textures used when performing the post process. (default: 0)
  68780. * @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)
  68781. */
  68782. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68783. }
  68784. }
  68785. declare module BABYLON {
  68786. /**
  68787. * PostProcessRenderPipeline
  68788. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68789. */
  68790. export class PostProcessRenderPipeline {
  68791. private engine;
  68792. private _renderEffects;
  68793. private _renderEffectsForIsolatedPass;
  68794. /**
  68795. * List of inspectable custom properties (used by the Inspector)
  68796. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68797. */
  68798. inspectableCustomProperties: IInspectable[];
  68799. /**
  68800. * @hidden
  68801. */
  68802. protected _cameras: Camera[];
  68803. /** @hidden */
  68804. _name: string;
  68805. /**
  68806. * Gets pipeline name
  68807. */
  68808. get name(): string;
  68809. /** Gets the list of attached cameras */
  68810. get cameras(): Camera[];
  68811. /**
  68812. * Initializes a PostProcessRenderPipeline
  68813. * @param engine engine to add the pipeline to
  68814. * @param name name of the pipeline
  68815. */
  68816. constructor(engine: Engine, name: string);
  68817. /**
  68818. * Gets the class name
  68819. * @returns "PostProcessRenderPipeline"
  68820. */
  68821. getClassName(): string;
  68822. /**
  68823. * If all the render effects in the pipeline are supported
  68824. */
  68825. get isSupported(): boolean;
  68826. /**
  68827. * Adds an effect to the pipeline
  68828. * @param renderEffect the effect to add
  68829. */
  68830. addEffect(renderEffect: PostProcessRenderEffect): void;
  68831. /** @hidden */
  68832. _rebuild(): void;
  68833. /** @hidden */
  68834. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68835. /** @hidden */
  68836. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68837. /** @hidden */
  68838. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68839. /** @hidden */
  68840. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68841. /** @hidden */
  68842. _attachCameras(cameras: Camera, unique: boolean): void;
  68843. /** @hidden */
  68844. _attachCameras(cameras: Camera[], unique: boolean): void;
  68845. /** @hidden */
  68846. _detachCameras(cameras: Camera): void;
  68847. /** @hidden */
  68848. _detachCameras(cameras: Nullable<Camera[]>): void;
  68849. /** @hidden */
  68850. _update(): void;
  68851. /** @hidden */
  68852. _reset(): void;
  68853. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68854. /**
  68855. * Disposes of the pipeline
  68856. */
  68857. dispose(): void;
  68858. }
  68859. }
  68860. declare module BABYLON {
  68861. /**
  68862. * PostProcessRenderPipelineManager class
  68863. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68864. */
  68865. export class PostProcessRenderPipelineManager {
  68866. private _renderPipelines;
  68867. /**
  68868. * Initializes a PostProcessRenderPipelineManager
  68869. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68870. */
  68871. constructor();
  68872. /**
  68873. * Gets the list of supported render pipelines
  68874. */
  68875. get supportedPipelines(): PostProcessRenderPipeline[];
  68876. /**
  68877. * Adds a pipeline to the manager
  68878. * @param renderPipeline The pipeline to add
  68879. */
  68880. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68881. /**
  68882. * Attaches a camera to the pipeline
  68883. * @param renderPipelineName The name of the pipeline to attach to
  68884. * @param cameras the camera to attach
  68885. * @param unique if the camera can be attached multiple times to the pipeline
  68886. */
  68887. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68888. /**
  68889. * Detaches a camera from the pipeline
  68890. * @param renderPipelineName The name of the pipeline to detach from
  68891. * @param cameras the camera to detach
  68892. */
  68893. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68894. /**
  68895. * Enables an effect by name on a pipeline
  68896. * @param renderPipelineName the name of the pipeline to enable the effect in
  68897. * @param renderEffectName the name of the effect to enable
  68898. * @param cameras the cameras that the effect should be enabled on
  68899. */
  68900. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68901. /**
  68902. * Disables an effect by name on a pipeline
  68903. * @param renderPipelineName the name of the pipeline to disable the effect in
  68904. * @param renderEffectName the name of the effect to disable
  68905. * @param cameras the cameras that the effect should be disabled on
  68906. */
  68907. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68908. /**
  68909. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68910. */
  68911. update(): void;
  68912. /** @hidden */
  68913. _rebuild(): void;
  68914. /**
  68915. * Disposes of the manager and pipelines
  68916. */
  68917. dispose(): void;
  68918. }
  68919. }
  68920. declare module BABYLON {
  68921. interface Scene {
  68922. /** @hidden (Backing field) */
  68923. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68924. /**
  68925. * Gets the postprocess render pipeline manager
  68926. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68927. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68928. */
  68929. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68930. }
  68931. /**
  68932. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68933. */
  68934. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68935. /**
  68936. * The component name helpfull to identify the component in the list of scene components.
  68937. */
  68938. readonly name: string;
  68939. /**
  68940. * The scene the component belongs to.
  68941. */
  68942. scene: Scene;
  68943. /**
  68944. * Creates a new instance of the component for the given scene
  68945. * @param scene Defines the scene to register the component in
  68946. */
  68947. constructor(scene: Scene);
  68948. /**
  68949. * Registers the component in a given scene
  68950. */
  68951. register(): void;
  68952. /**
  68953. * Rebuilds the elements related to this component in case of
  68954. * context lost for instance.
  68955. */
  68956. rebuild(): void;
  68957. /**
  68958. * Disposes the component and the associated ressources
  68959. */
  68960. dispose(): void;
  68961. private _gatherRenderTargets;
  68962. }
  68963. }
  68964. declare module BABYLON {
  68965. /**
  68966. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68967. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68968. */
  68969. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68970. private _scene;
  68971. private _camerasToBeAttached;
  68972. /**
  68973. * ID of the sharpen post process,
  68974. */
  68975. private readonly SharpenPostProcessId;
  68976. /**
  68977. * @ignore
  68978. * ID of the image processing post process;
  68979. */
  68980. readonly ImageProcessingPostProcessId: string;
  68981. /**
  68982. * @ignore
  68983. * ID of the Fast Approximate Anti-Aliasing post process;
  68984. */
  68985. readonly FxaaPostProcessId: string;
  68986. /**
  68987. * ID of the chromatic aberration post process,
  68988. */
  68989. private readonly ChromaticAberrationPostProcessId;
  68990. /**
  68991. * ID of the grain post process
  68992. */
  68993. private readonly GrainPostProcessId;
  68994. /**
  68995. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68996. */
  68997. sharpen: SharpenPostProcess;
  68998. private _sharpenEffect;
  68999. private bloom;
  69000. /**
  69001. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69002. */
  69003. depthOfField: DepthOfFieldEffect;
  69004. /**
  69005. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69006. */
  69007. fxaa: FxaaPostProcess;
  69008. /**
  69009. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69010. */
  69011. imageProcessing: ImageProcessingPostProcess;
  69012. /**
  69013. * Chromatic aberration post process which will shift rgb colors in the image
  69014. */
  69015. chromaticAberration: ChromaticAberrationPostProcess;
  69016. private _chromaticAberrationEffect;
  69017. /**
  69018. * Grain post process which add noise to the image
  69019. */
  69020. grain: GrainPostProcess;
  69021. private _grainEffect;
  69022. /**
  69023. * Glow post process which adds a glow to emissive areas of the image
  69024. */
  69025. private _glowLayer;
  69026. /**
  69027. * Animations which can be used to tweak settings over a period of time
  69028. */
  69029. animations: Animation[];
  69030. private _imageProcessingConfigurationObserver;
  69031. private _sharpenEnabled;
  69032. private _bloomEnabled;
  69033. private _depthOfFieldEnabled;
  69034. private _depthOfFieldBlurLevel;
  69035. private _fxaaEnabled;
  69036. private _imageProcessingEnabled;
  69037. private _defaultPipelineTextureType;
  69038. private _bloomScale;
  69039. private _chromaticAberrationEnabled;
  69040. private _grainEnabled;
  69041. private _buildAllowed;
  69042. /**
  69043. * Gets active scene
  69044. */
  69045. get scene(): Scene;
  69046. /**
  69047. * Enable or disable the sharpen process from the pipeline
  69048. */
  69049. set sharpenEnabled(enabled: boolean);
  69050. get sharpenEnabled(): boolean;
  69051. private _resizeObserver;
  69052. private _hardwareScaleLevel;
  69053. private _bloomKernel;
  69054. /**
  69055. * Specifies the size of the bloom blur kernel, relative to the final output size
  69056. */
  69057. get bloomKernel(): number;
  69058. set bloomKernel(value: number);
  69059. /**
  69060. * Specifies the weight of the bloom in the final rendering
  69061. */
  69062. private _bloomWeight;
  69063. /**
  69064. * Specifies the luma threshold for the area that will be blurred by the bloom
  69065. */
  69066. private _bloomThreshold;
  69067. private _hdr;
  69068. /**
  69069. * The strength of the bloom.
  69070. */
  69071. set bloomWeight(value: number);
  69072. get bloomWeight(): number;
  69073. /**
  69074. * The strength of the bloom.
  69075. */
  69076. set bloomThreshold(value: number);
  69077. get bloomThreshold(): number;
  69078. /**
  69079. * The scale of the bloom, lower value will provide better performance.
  69080. */
  69081. set bloomScale(value: number);
  69082. get bloomScale(): number;
  69083. /**
  69084. * Enable or disable the bloom from the pipeline
  69085. */
  69086. set bloomEnabled(enabled: boolean);
  69087. get bloomEnabled(): boolean;
  69088. private _rebuildBloom;
  69089. /**
  69090. * If the depth of field is enabled.
  69091. */
  69092. get depthOfFieldEnabled(): boolean;
  69093. set depthOfFieldEnabled(enabled: boolean);
  69094. /**
  69095. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69096. */
  69097. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69098. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69099. /**
  69100. * If the anti aliasing is enabled.
  69101. */
  69102. set fxaaEnabled(enabled: boolean);
  69103. get fxaaEnabled(): boolean;
  69104. private _samples;
  69105. /**
  69106. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69107. */
  69108. set samples(sampleCount: number);
  69109. get samples(): number;
  69110. /**
  69111. * If image processing is enabled.
  69112. */
  69113. set imageProcessingEnabled(enabled: boolean);
  69114. get imageProcessingEnabled(): boolean;
  69115. /**
  69116. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69117. */
  69118. set glowLayerEnabled(enabled: boolean);
  69119. get glowLayerEnabled(): boolean;
  69120. /**
  69121. * Gets the glow layer (or null if not defined)
  69122. */
  69123. get glowLayer(): Nullable<GlowLayer>;
  69124. /**
  69125. * Enable or disable the chromaticAberration process from the pipeline
  69126. */
  69127. set chromaticAberrationEnabled(enabled: boolean);
  69128. get chromaticAberrationEnabled(): boolean;
  69129. /**
  69130. * Enable or disable the grain process from the pipeline
  69131. */
  69132. set grainEnabled(enabled: boolean);
  69133. get grainEnabled(): boolean;
  69134. /**
  69135. * @constructor
  69136. * @param name - The rendering pipeline name (default: "")
  69137. * @param hdr - If high dynamic range textures should be used (default: true)
  69138. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69139. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69140. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69141. */
  69142. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69143. /**
  69144. * Get the class name
  69145. * @returns "DefaultRenderingPipeline"
  69146. */
  69147. getClassName(): string;
  69148. /**
  69149. * Force the compilation of the entire pipeline.
  69150. */
  69151. prepare(): void;
  69152. private _hasCleared;
  69153. private _prevPostProcess;
  69154. private _prevPrevPostProcess;
  69155. private _setAutoClearAndTextureSharing;
  69156. private _depthOfFieldSceneObserver;
  69157. private _buildPipeline;
  69158. private _disposePostProcesses;
  69159. /**
  69160. * Adds a camera to the pipeline
  69161. * @param camera the camera to be added
  69162. */
  69163. addCamera(camera: Camera): void;
  69164. /**
  69165. * Removes a camera from the pipeline
  69166. * @param camera the camera to remove
  69167. */
  69168. removeCamera(camera: Camera): void;
  69169. /**
  69170. * Dispose of the pipeline and stop all post processes
  69171. */
  69172. dispose(): void;
  69173. /**
  69174. * Serialize the rendering pipeline (Used when exporting)
  69175. * @returns the serialized object
  69176. */
  69177. serialize(): any;
  69178. /**
  69179. * Parse the serialized pipeline
  69180. * @param source Source pipeline.
  69181. * @param scene The scene to load the pipeline to.
  69182. * @param rootUrl The URL of the serialized pipeline.
  69183. * @returns An instantiated pipeline from the serialized object.
  69184. */
  69185. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69186. }
  69187. }
  69188. declare module BABYLON {
  69189. /** @hidden */
  69190. export var lensHighlightsPixelShader: {
  69191. name: string;
  69192. shader: string;
  69193. };
  69194. }
  69195. declare module BABYLON {
  69196. /** @hidden */
  69197. export var depthOfFieldPixelShader: {
  69198. name: string;
  69199. shader: string;
  69200. };
  69201. }
  69202. declare module BABYLON {
  69203. /**
  69204. * BABYLON.JS Chromatic Aberration GLSL Shader
  69205. * Author: Olivier Guyot
  69206. * Separates very slightly R, G and B colors on the edges of the screen
  69207. * Inspired by Francois Tarlier & Martins Upitis
  69208. */
  69209. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69210. /**
  69211. * @ignore
  69212. * The chromatic aberration PostProcess id in the pipeline
  69213. */
  69214. LensChromaticAberrationEffect: string;
  69215. /**
  69216. * @ignore
  69217. * The highlights enhancing PostProcess id in the pipeline
  69218. */
  69219. HighlightsEnhancingEffect: string;
  69220. /**
  69221. * @ignore
  69222. * The depth-of-field PostProcess id in the pipeline
  69223. */
  69224. LensDepthOfFieldEffect: string;
  69225. private _scene;
  69226. private _depthTexture;
  69227. private _grainTexture;
  69228. private _chromaticAberrationPostProcess;
  69229. private _highlightsPostProcess;
  69230. private _depthOfFieldPostProcess;
  69231. private _edgeBlur;
  69232. private _grainAmount;
  69233. private _chromaticAberration;
  69234. private _distortion;
  69235. private _highlightsGain;
  69236. private _highlightsThreshold;
  69237. private _dofDistance;
  69238. private _dofAperture;
  69239. private _dofDarken;
  69240. private _dofPentagon;
  69241. private _blurNoise;
  69242. /**
  69243. * @constructor
  69244. *
  69245. * Effect parameters are as follow:
  69246. * {
  69247. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69248. * edge_blur: number; // from 0 to x (1 for realism)
  69249. * distortion: number; // from 0 to x (1 for realism)
  69250. * grain_amount: number; // from 0 to 1
  69251. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69252. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69253. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69254. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69255. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69256. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69257. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69258. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69259. * }
  69260. * Note: if an effect parameter is unset, effect is disabled
  69261. *
  69262. * @param name The rendering pipeline name
  69263. * @param parameters - An object containing all parameters (see above)
  69264. * @param scene The scene linked to this pipeline
  69265. * @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)
  69266. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69267. */
  69268. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69269. /**
  69270. * Get the class name
  69271. * @returns "LensRenderingPipeline"
  69272. */
  69273. getClassName(): string;
  69274. /**
  69275. * Gets associated scene
  69276. */
  69277. get scene(): Scene;
  69278. /**
  69279. * Gets or sets the edge blur
  69280. */
  69281. get edgeBlur(): number;
  69282. set edgeBlur(value: number);
  69283. /**
  69284. * Gets or sets the grain amount
  69285. */
  69286. get grainAmount(): number;
  69287. set grainAmount(value: number);
  69288. /**
  69289. * Gets or sets the chromatic aberration amount
  69290. */
  69291. get chromaticAberration(): number;
  69292. set chromaticAberration(value: number);
  69293. /**
  69294. * Gets or sets the depth of field aperture
  69295. */
  69296. get dofAperture(): number;
  69297. set dofAperture(value: number);
  69298. /**
  69299. * Gets or sets the edge distortion
  69300. */
  69301. get edgeDistortion(): number;
  69302. set edgeDistortion(value: number);
  69303. /**
  69304. * Gets or sets the depth of field distortion
  69305. */
  69306. get dofDistortion(): number;
  69307. set dofDistortion(value: number);
  69308. /**
  69309. * Gets or sets the darken out of focus amount
  69310. */
  69311. get darkenOutOfFocus(): number;
  69312. set darkenOutOfFocus(value: number);
  69313. /**
  69314. * Gets or sets a boolean indicating if blur noise is enabled
  69315. */
  69316. get blurNoise(): boolean;
  69317. set blurNoise(value: boolean);
  69318. /**
  69319. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69320. */
  69321. get pentagonBokeh(): boolean;
  69322. set pentagonBokeh(value: boolean);
  69323. /**
  69324. * Gets or sets the highlight grain amount
  69325. */
  69326. get highlightsGain(): number;
  69327. set highlightsGain(value: number);
  69328. /**
  69329. * Gets or sets the highlight threshold
  69330. */
  69331. get highlightsThreshold(): number;
  69332. set highlightsThreshold(value: number);
  69333. /**
  69334. * Sets the amount of blur at the edges
  69335. * @param amount blur amount
  69336. */
  69337. setEdgeBlur(amount: number): void;
  69338. /**
  69339. * Sets edge blur to 0
  69340. */
  69341. disableEdgeBlur(): void;
  69342. /**
  69343. * Sets the amout of grain
  69344. * @param amount Amount of grain
  69345. */
  69346. setGrainAmount(amount: number): void;
  69347. /**
  69348. * Set grain amount to 0
  69349. */
  69350. disableGrain(): void;
  69351. /**
  69352. * Sets the chromatic aberration amount
  69353. * @param amount amount of chromatic aberration
  69354. */
  69355. setChromaticAberration(amount: number): void;
  69356. /**
  69357. * Sets chromatic aberration amount to 0
  69358. */
  69359. disableChromaticAberration(): void;
  69360. /**
  69361. * Sets the EdgeDistortion amount
  69362. * @param amount amount of EdgeDistortion
  69363. */
  69364. setEdgeDistortion(amount: number): void;
  69365. /**
  69366. * Sets edge distortion to 0
  69367. */
  69368. disableEdgeDistortion(): void;
  69369. /**
  69370. * Sets the FocusDistance amount
  69371. * @param amount amount of FocusDistance
  69372. */
  69373. setFocusDistance(amount: number): void;
  69374. /**
  69375. * Disables depth of field
  69376. */
  69377. disableDepthOfField(): void;
  69378. /**
  69379. * Sets the Aperture amount
  69380. * @param amount amount of Aperture
  69381. */
  69382. setAperture(amount: number): void;
  69383. /**
  69384. * Sets the DarkenOutOfFocus amount
  69385. * @param amount amount of DarkenOutOfFocus
  69386. */
  69387. setDarkenOutOfFocus(amount: number): void;
  69388. private _pentagonBokehIsEnabled;
  69389. /**
  69390. * Creates a pentagon bokeh effect
  69391. */
  69392. enablePentagonBokeh(): void;
  69393. /**
  69394. * Disables the pentagon bokeh effect
  69395. */
  69396. disablePentagonBokeh(): void;
  69397. /**
  69398. * Enables noise blur
  69399. */
  69400. enableNoiseBlur(): void;
  69401. /**
  69402. * Disables noise blur
  69403. */
  69404. disableNoiseBlur(): void;
  69405. /**
  69406. * Sets the HighlightsGain amount
  69407. * @param amount amount of HighlightsGain
  69408. */
  69409. setHighlightsGain(amount: number): void;
  69410. /**
  69411. * Sets the HighlightsThreshold amount
  69412. * @param amount amount of HighlightsThreshold
  69413. */
  69414. setHighlightsThreshold(amount: number): void;
  69415. /**
  69416. * Disables highlights
  69417. */
  69418. disableHighlights(): void;
  69419. /**
  69420. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69421. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69422. */
  69423. dispose(disableDepthRender?: boolean): void;
  69424. private _createChromaticAberrationPostProcess;
  69425. private _createHighlightsPostProcess;
  69426. private _createDepthOfFieldPostProcess;
  69427. private _createGrainTexture;
  69428. }
  69429. }
  69430. declare module BABYLON {
  69431. /** @hidden */
  69432. export var ssao2PixelShader: {
  69433. name: string;
  69434. shader: string;
  69435. };
  69436. }
  69437. declare module BABYLON {
  69438. /** @hidden */
  69439. export var ssaoCombinePixelShader: {
  69440. name: string;
  69441. shader: string;
  69442. };
  69443. }
  69444. declare module BABYLON {
  69445. /**
  69446. * Render pipeline to produce ssao effect
  69447. */
  69448. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69449. /**
  69450. * @ignore
  69451. * The PassPostProcess id in the pipeline that contains the original scene color
  69452. */
  69453. SSAOOriginalSceneColorEffect: string;
  69454. /**
  69455. * @ignore
  69456. * The SSAO PostProcess id in the pipeline
  69457. */
  69458. SSAORenderEffect: string;
  69459. /**
  69460. * @ignore
  69461. * The horizontal blur PostProcess id in the pipeline
  69462. */
  69463. SSAOBlurHRenderEffect: string;
  69464. /**
  69465. * @ignore
  69466. * The vertical blur PostProcess id in the pipeline
  69467. */
  69468. SSAOBlurVRenderEffect: string;
  69469. /**
  69470. * @ignore
  69471. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69472. */
  69473. SSAOCombineRenderEffect: string;
  69474. /**
  69475. * The output strength of the SSAO post-process. Default value is 1.0.
  69476. */
  69477. totalStrength: number;
  69478. /**
  69479. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69480. */
  69481. maxZ: number;
  69482. /**
  69483. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69484. */
  69485. minZAspect: number;
  69486. private _samples;
  69487. /**
  69488. * Number of samples used for the SSAO calculations. Default value is 8
  69489. */
  69490. set samples(n: number);
  69491. get samples(): number;
  69492. private _textureSamples;
  69493. /**
  69494. * Number of samples to use for antialiasing
  69495. */
  69496. set textureSamples(n: number);
  69497. get textureSamples(): number;
  69498. /**
  69499. * Ratio object used for SSAO ratio and blur ratio
  69500. */
  69501. private _ratio;
  69502. /**
  69503. * Dynamically generated sphere sampler.
  69504. */
  69505. private _sampleSphere;
  69506. /**
  69507. * Blur filter offsets
  69508. */
  69509. private _samplerOffsets;
  69510. private _expensiveBlur;
  69511. /**
  69512. * If bilateral blur should be used
  69513. */
  69514. set expensiveBlur(b: boolean);
  69515. get expensiveBlur(): boolean;
  69516. /**
  69517. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69518. */
  69519. radius: number;
  69520. /**
  69521. * The base color of the SSAO post-process
  69522. * The final result is "base + ssao" between [0, 1]
  69523. */
  69524. base: number;
  69525. /**
  69526. * Support test.
  69527. */
  69528. static get IsSupported(): boolean;
  69529. private _scene;
  69530. private _depthTexture;
  69531. private _normalTexture;
  69532. private _randomTexture;
  69533. private _originalColorPostProcess;
  69534. private _ssaoPostProcess;
  69535. private _blurHPostProcess;
  69536. private _blurVPostProcess;
  69537. private _ssaoCombinePostProcess;
  69538. /**
  69539. * Gets active scene
  69540. */
  69541. get scene(): Scene;
  69542. /**
  69543. * @constructor
  69544. * @param name The rendering pipeline name
  69545. * @param scene The scene linked to this pipeline
  69546. * @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 }
  69547. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69548. */
  69549. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69550. /**
  69551. * Get the class name
  69552. * @returns "SSAO2RenderingPipeline"
  69553. */
  69554. getClassName(): string;
  69555. /**
  69556. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69557. */
  69558. dispose(disableGeometryBufferRenderer?: boolean): void;
  69559. private _createBlurPostProcess;
  69560. /** @hidden */
  69561. _rebuild(): void;
  69562. private _bits;
  69563. private _radicalInverse_VdC;
  69564. private _hammersley;
  69565. private _hemisphereSample_uniform;
  69566. private _generateHemisphere;
  69567. private _createSSAOPostProcess;
  69568. private _createSSAOCombinePostProcess;
  69569. private _createRandomTexture;
  69570. /**
  69571. * Serialize the rendering pipeline (Used when exporting)
  69572. * @returns the serialized object
  69573. */
  69574. serialize(): any;
  69575. /**
  69576. * Parse the serialized pipeline
  69577. * @param source Source pipeline.
  69578. * @param scene The scene to load the pipeline to.
  69579. * @param rootUrl The URL of the serialized pipeline.
  69580. * @returns An instantiated pipeline from the serialized object.
  69581. */
  69582. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69583. }
  69584. }
  69585. declare module BABYLON {
  69586. /** @hidden */
  69587. export var ssaoPixelShader: {
  69588. name: string;
  69589. shader: string;
  69590. };
  69591. }
  69592. declare module BABYLON {
  69593. /**
  69594. * Render pipeline to produce ssao effect
  69595. */
  69596. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69597. /**
  69598. * @ignore
  69599. * The PassPostProcess id in the pipeline that contains the original scene color
  69600. */
  69601. SSAOOriginalSceneColorEffect: string;
  69602. /**
  69603. * @ignore
  69604. * The SSAO PostProcess id in the pipeline
  69605. */
  69606. SSAORenderEffect: string;
  69607. /**
  69608. * @ignore
  69609. * The horizontal blur PostProcess id in the pipeline
  69610. */
  69611. SSAOBlurHRenderEffect: string;
  69612. /**
  69613. * @ignore
  69614. * The vertical blur PostProcess id in the pipeline
  69615. */
  69616. SSAOBlurVRenderEffect: string;
  69617. /**
  69618. * @ignore
  69619. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69620. */
  69621. SSAOCombineRenderEffect: string;
  69622. /**
  69623. * The output strength of the SSAO post-process. Default value is 1.0.
  69624. */
  69625. totalStrength: number;
  69626. /**
  69627. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69628. */
  69629. radius: number;
  69630. /**
  69631. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69632. * Must not be equal to fallOff and superior to fallOff.
  69633. * Default value is 0.0075
  69634. */
  69635. area: number;
  69636. /**
  69637. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69638. * Must not be equal to area and inferior to area.
  69639. * Default value is 0.000001
  69640. */
  69641. fallOff: number;
  69642. /**
  69643. * The base color of the SSAO post-process
  69644. * The final result is "base + ssao" between [0, 1]
  69645. */
  69646. base: number;
  69647. private _scene;
  69648. private _depthTexture;
  69649. private _randomTexture;
  69650. private _originalColorPostProcess;
  69651. private _ssaoPostProcess;
  69652. private _blurHPostProcess;
  69653. private _blurVPostProcess;
  69654. private _ssaoCombinePostProcess;
  69655. private _firstUpdate;
  69656. /**
  69657. * Gets active scene
  69658. */
  69659. get scene(): Scene;
  69660. /**
  69661. * @constructor
  69662. * @param name - The rendering pipeline name
  69663. * @param scene - The scene linked to this pipeline
  69664. * @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 }
  69665. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69666. */
  69667. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69668. /**
  69669. * Get the class name
  69670. * @returns "SSAORenderingPipeline"
  69671. */
  69672. getClassName(): string;
  69673. /**
  69674. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69675. */
  69676. dispose(disableDepthRender?: boolean): void;
  69677. private _createBlurPostProcess;
  69678. /** @hidden */
  69679. _rebuild(): void;
  69680. private _createSSAOPostProcess;
  69681. private _createSSAOCombinePostProcess;
  69682. private _createRandomTexture;
  69683. }
  69684. }
  69685. declare module BABYLON {
  69686. /** @hidden */
  69687. export var screenSpaceReflectionPixelShader: {
  69688. name: string;
  69689. shader: string;
  69690. };
  69691. }
  69692. declare module BABYLON {
  69693. /**
  69694. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69695. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69696. */
  69697. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69698. /**
  69699. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69700. */
  69701. threshold: number;
  69702. /**
  69703. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69704. */
  69705. strength: number;
  69706. /**
  69707. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69708. */
  69709. reflectionSpecularFalloffExponent: number;
  69710. /**
  69711. * 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]
  69712. */
  69713. step: number;
  69714. /**
  69715. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69716. */
  69717. roughnessFactor: number;
  69718. private _geometryBufferRenderer;
  69719. private _enableSmoothReflections;
  69720. private _reflectionSamples;
  69721. private _smoothSteps;
  69722. /**
  69723. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69724. * @param name The name of the effect.
  69725. * @param scene The scene containing the objects to calculate reflections.
  69726. * @param options The required width/height ratio to downsize to before computing the render pass.
  69727. * @param camera The camera to apply the render pass to.
  69728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69729. * @param engine The engine which the post process will be applied. (default: current engine)
  69730. * @param reusable If the post process can be reused on the same frame. (default: false)
  69731. * @param textureType Type of textures used when performing the post process. (default: 0)
  69732. * @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)
  69733. */
  69734. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69735. /**
  69736. * Gets wether or not smoothing reflections is enabled.
  69737. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69738. */
  69739. get enableSmoothReflections(): boolean;
  69740. /**
  69741. * Sets wether or not smoothing reflections is enabled.
  69742. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69743. */
  69744. set enableSmoothReflections(enabled: boolean);
  69745. /**
  69746. * Gets the number of samples taken while computing reflections. More samples count is high,
  69747. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69748. */
  69749. get reflectionSamples(): number;
  69750. /**
  69751. * Sets the number of samples taken while computing reflections. More samples count is high,
  69752. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69753. */
  69754. set reflectionSamples(samples: number);
  69755. /**
  69756. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69757. * more the post-process will require GPU power and can generate a drop in FPS.
  69758. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69759. */
  69760. get smoothSteps(): number;
  69761. set smoothSteps(steps: number);
  69762. private _updateEffectDefines;
  69763. }
  69764. }
  69765. declare module BABYLON {
  69766. /** @hidden */
  69767. export var standardPixelShader: {
  69768. name: string;
  69769. shader: string;
  69770. };
  69771. }
  69772. declare module BABYLON {
  69773. /**
  69774. * Standard rendering pipeline
  69775. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69776. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69777. */
  69778. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69779. /**
  69780. * Public members
  69781. */
  69782. /**
  69783. * Post-process which contains the original scene color before the pipeline applies all the effects
  69784. */
  69785. originalPostProcess: Nullable<PostProcess>;
  69786. /**
  69787. * Post-process used to down scale an image x4
  69788. */
  69789. downSampleX4PostProcess: Nullable<PostProcess>;
  69790. /**
  69791. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69792. */
  69793. brightPassPostProcess: Nullable<PostProcess>;
  69794. /**
  69795. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69796. */
  69797. blurHPostProcesses: PostProcess[];
  69798. /**
  69799. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69800. */
  69801. blurVPostProcesses: PostProcess[];
  69802. /**
  69803. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69804. */
  69805. textureAdderPostProcess: Nullable<PostProcess>;
  69806. /**
  69807. * Post-process used to create volumetric lighting effect
  69808. */
  69809. volumetricLightPostProcess: Nullable<PostProcess>;
  69810. /**
  69811. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69812. */
  69813. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69814. /**
  69815. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69816. */
  69817. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69818. /**
  69819. * Post-process used to merge the volumetric light effect and the real scene color
  69820. */
  69821. volumetricLightMergePostProces: Nullable<PostProcess>;
  69822. /**
  69823. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69824. */
  69825. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69826. /**
  69827. * Base post-process used to calculate the average luminance of the final image for HDR
  69828. */
  69829. luminancePostProcess: Nullable<PostProcess>;
  69830. /**
  69831. * Post-processes used to create down sample post-processes in order to get
  69832. * the average luminance of the final image for HDR
  69833. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69834. */
  69835. luminanceDownSamplePostProcesses: PostProcess[];
  69836. /**
  69837. * Post-process used to create a HDR effect (light adaptation)
  69838. */
  69839. hdrPostProcess: Nullable<PostProcess>;
  69840. /**
  69841. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69842. */
  69843. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69844. /**
  69845. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69846. */
  69847. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69848. /**
  69849. * Post-process used to merge the final HDR post-process and the real scene color
  69850. */
  69851. hdrFinalPostProcess: Nullable<PostProcess>;
  69852. /**
  69853. * Post-process used to create a lens flare effect
  69854. */
  69855. lensFlarePostProcess: Nullable<PostProcess>;
  69856. /**
  69857. * Post-process that merges the result of the lens flare post-process and the real scene color
  69858. */
  69859. lensFlareComposePostProcess: Nullable<PostProcess>;
  69860. /**
  69861. * Post-process used to create a motion blur effect
  69862. */
  69863. motionBlurPostProcess: Nullable<PostProcess>;
  69864. /**
  69865. * Post-process used to create a depth of field effect
  69866. */
  69867. depthOfFieldPostProcess: Nullable<PostProcess>;
  69868. /**
  69869. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69870. */
  69871. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69872. /**
  69873. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69874. */
  69875. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69876. /**
  69877. * Represents the brightness threshold in order to configure the illuminated surfaces
  69878. */
  69879. brightThreshold: number;
  69880. /**
  69881. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69882. */
  69883. blurWidth: number;
  69884. /**
  69885. * Sets if the blur for highlighted surfaces must be only horizontal
  69886. */
  69887. horizontalBlur: boolean;
  69888. /**
  69889. * Gets the overall exposure used by the pipeline
  69890. */
  69891. get exposure(): number;
  69892. /**
  69893. * Sets the overall exposure used by the pipeline
  69894. */
  69895. set exposure(value: number);
  69896. /**
  69897. * Texture used typically to simulate "dirty" on camera lens
  69898. */
  69899. lensTexture: Nullable<Texture>;
  69900. /**
  69901. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69902. */
  69903. volumetricLightCoefficient: number;
  69904. /**
  69905. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69906. */
  69907. volumetricLightPower: number;
  69908. /**
  69909. * Used the set the blur intensity to smooth the volumetric lights
  69910. */
  69911. volumetricLightBlurScale: number;
  69912. /**
  69913. * Light (spot or directional) used to generate the volumetric lights rays
  69914. * The source light must have a shadow generate so the pipeline can get its
  69915. * depth map
  69916. */
  69917. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69918. /**
  69919. * For eye adaptation, represents the minimum luminance the eye can see
  69920. */
  69921. hdrMinimumLuminance: number;
  69922. /**
  69923. * For eye adaptation, represents the decrease luminance speed
  69924. */
  69925. hdrDecreaseRate: number;
  69926. /**
  69927. * For eye adaptation, represents the increase luminance speed
  69928. */
  69929. hdrIncreaseRate: number;
  69930. /**
  69931. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69932. */
  69933. get hdrAutoExposure(): boolean;
  69934. /**
  69935. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69936. */
  69937. set hdrAutoExposure(value: boolean);
  69938. /**
  69939. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69940. */
  69941. lensColorTexture: Nullable<Texture>;
  69942. /**
  69943. * The overall strengh for the lens flare effect
  69944. */
  69945. lensFlareStrength: number;
  69946. /**
  69947. * Dispersion coefficient for lens flare ghosts
  69948. */
  69949. lensFlareGhostDispersal: number;
  69950. /**
  69951. * Main lens flare halo width
  69952. */
  69953. lensFlareHaloWidth: number;
  69954. /**
  69955. * Based on the lens distortion effect, defines how much the lens flare result
  69956. * is distorted
  69957. */
  69958. lensFlareDistortionStrength: number;
  69959. /**
  69960. * Configures the blur intensity used for for lens flare (halo)
  69961. */
  69962. lensFlareBlurWidth: number;
  69963. /**
  69964. * Lens star texture must be used to simulate rays on the flares and is available
  69965. * in the documentation
  69966. */
  69967. lensStarTexture: Nullable<Texture>;
  69968. /**
  69969. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69970. * flare effect by taking account of the dirt texture
  69971. */
  69972. lensFlareDirtTexture: Nullable<Texture>;
  69973. /**
  69974. * Represents the focal length for the depth of field effect
  69975. */
  69976. depthOfFieldDistance: number;
  69977. /**
  69978. * Represents the blur intensity for the blurred part of the depth of field effect
  69979. */
  69980. depthOfFieldBlurWidth: number;
  69981. /**
  69982. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69983. */
  69984. get motionStrength(): number;
  69985. /**
  69986. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69987. */
  69988. set motionStrength(strength: number);
  69989. /**
  69990. * Gets wether or not the motion blur post-process is object based or screen based.
  69991. */
  69992. get objectBasedMotionBlur(): boolean;
  69993. /**
  69994. * Sets wether or not the motion blur post-process should be object based or screen based
  69995. */
  69996. set objectBasedMotionBlur(value: boolean);
  69997. /**
  69998. * List of animations for the pipeline (IAnimatable implementation)
  69999. */
  70000. animations: Animation[];
  70001. /**
  70002. * Private members
  70003. */
  70004. private _scene;
  70005. private _currentDepthOfFieldSource;
  70006. private _basePostProcess;
  70007. private _fixedExposure;
  70008. private _currentExposure;
  70009. private _hdrAutoExposure;
  70010. private _hdrCurrentLuminance;
  70011. private _motionStrength;
  70012. private _isObjectBasedMotionBlur;
  70013. private _floatTextureType;
  70014. private _camerasToBeAttached;
  70015. private _ratio;
  70016. private _bloomEnabled;
  70017. private _depthOfFieldEnabled;
  70018. private _vlsEnabled;
  70019. private _lensFlareEnabled;
  70020. private _hdrEnabled;
  70021. private _motionBlurEnabled;
  70022. private _fxaaEnabled;
  70023. private _screenSpaceReflectionsEnabled;
  70024. private _motionBlurSamples;
  70025. private _volumetricLightStepsCount;
  70026. private _samples;
  70027. /**
  70028. * @ignore
  70029. * Specifies if the bloom pipeline is enabled
  70030. */
  70031. get BloomEnabled(): boolean;
  70032. set BloomEnabled(enabled: boolean);
  70033. /**
  70034. * @ignore
  70035. * Specifies if the depth of field pipeline is enabed
  70036. */
  70037. get DepthOfFieldEnabled(): boolean;
  70038. set DepthOfFieldEnabled(enabled: boolean);
  70039. /**
  70040. * @ignore
  70041. * Specifies if the lens flare pipeline is enabed
  70042. */
  70043. get LensFlareEnabled(): boolean;
  70044. set LensFlareEnabled(enabled: boolean);
  70045. /**
  70046. * @ignore
  70047. * Specifies if the HDR pipeline is enabled
  70048. */
  70049. get HDREnabled(): boolean;
  70050. set HDREnabled(enabled: boolean);
  70051. /**
  70052. * @ignore
  70053. * Specifies if the volumetric lights scattering effect is enabled
  70054. */
  70055. get VLSEnabled(): boolean;
  70056. set VLSEnabled(enabled: boolean);
  70057. /**
  70058. * @ignore
  70059. * Specifies if the motion blur effect is enabled
  70060. */
  70061. get MotionBlurEnabled(): boolean;
  70062. set MotionBlurEnabled(enabled: boolean);
  70063. /**
  70064. * Specifies if anti-aliasing is enabled
  70065. */
  70066. get fxaaEnabled(): boolean;
  70067. set fxaaEnabled(enabled: boolean);
  70068. /**
  70069. * Specifies if screen space reflections are enabled.
  70070. */
  70071. get screenSpaceReflectionsEnabled(): boolean;
  70072. set screenSpaceReflectionsEnabled(enabled: boolean);
  70073. /**
  70074. * Specifies the number of steps used to calculate the volumetric lights
  70075. * Typically in interval [50, 200]
  70076. */
  70077. get volumetricLightStepsCount(): number;
  70078. set volumetricLightStepsCount(count: number);
  70079. /**
  70080. * Specifies the number of samples used for the motion blur effect
  70081. * Typically in interval [16, 64]
  70082. */
  70083. get motionBlurSamples(): number;
  70084. set motionBlurSamples(samples: number);
  70085. /**
  70086. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70087. */
  70088. get samples(): number;
  70089. set samples(sampleCount: number);
  70090. /**
  70091. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70092. * @constructor
  70093. * @param name The rendering pipeline name
  70094. * @param scene The scene linked to this pipeline
  70095. * @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)
  70096. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70097. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70098. */
  70099. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70100. private _buildPipeline;
  70101. private _createDownSampleX4PostProcess;
  70102. private _createBrightPassPostProcess;
  70103. private _createBlurPostProcesses;
  70104. private _createTextureAdderPostProcess;
  70105. private _createVolumetricLightPostProcess;
  70106. private _createLuminancePostProcesses;
  70107. private _createHdrPostProcess;
  70108. private _createLensFlarePostProcess;
  70109. private _createDepthOfFieldPostProcess;
  70110. private _createMotionBlurPostProcess;
  70111. private _getDepthTexture;
  70112. private _disposePostProcesses;
  70113. /**
  70114. * Dispose of the pipeline and stop all post processes
  70115. */
  70116. dispose(): void;
  70117. /**
  70118. * Serialize the rendering pipeline (Used when exporting)
  70119. * @returns the serialized object
  70120. */
  70121. serialize(): any;
  70122. /**
  70123. * Parse the serialized pipeline
  70124. * @param source Source pipeline.
  70125. * @param scene The scene to load the pipeline to.
  70126. * @param rootUrl The URL of the serialized pipeline.
  70127. * @returns An instantiated pipeline from the serialized object.
  70128. */
  70129. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70130. /**
  70131. * Luminance steps
  70132. */
  70133. static LuminanceSteps: number;
  70134. }
  70135. }
  70136. declare module BABYLON {
  70137. /** @hidden */
  70138. export var stereoscopicInterlacePixelShader: {
  70139. name: string;
  70140. shader: string;
  70141. };
  70142. }
  70143. declare module BABYLON {
  70144. /**
  70145. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70146. */
  70147. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70148. private _stepSize;
  70149. private _passedProcess;
  70150. /**
  70151. * Initializes a StereoscopicInterlacePostProcessI
  70152. * @param name The name of the effect.
  70153. * @param rigCameras The rig cameras to be appled to the post process
  70154. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70155. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  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, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70161. }
  70162. /**
  70163. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70164. */
  70165. export class StereoscopicInterlacePostProcess extends PostProcess {
  70166. private _stepSize;
  70167. private _passedProcess;
  70168. /**
  70169. * Initializes a StereoscopicInterlacePostProcess
  70170. * @param name The name of the effect.
  70171. * @param rigCameras The rig cameras to be appled to the post process
  70172. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70174. * @param engine The engine which the post process will be applied. (default: current engine)
  70175. * @param reusable If the post process can be reused on the same frame. (default: false)
  70176. */
  70177. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70178. }
  70179. }
  70180. declare module BABYLON {
  70181. /** @hidden */
  70182. export var tonemapPixelShader: {
  70183. name: string;
  70184. shader: string;
  70185. };
  70186. }
  70187. declare module BABYLON {
  70188. /** Defines operator used for tonemapping */
  70189. export enum TonemappingOperator {
  70190. /** Hable */
  70191. Hable = 0,
  70192. /** Reinhard */
  70193. Reinhard = 1,
  70194. /** HejiDawson */
  70195. HejiDawson = 2,
  70196. /** Photographic */
  70197. Photographic = 3
  70198. }
  70199. /**
  70200. * Defines a post process to apply tone mapping
  70201. */
  70202. export class TonemapPostProcess extends PostProcess {
  70203. private _operator;
  70204. /** Defines the required exposure adjustement */
  70205. exposureAdjustment: number;
  70206. /**
  70207. * Creates a new TonemapPostProcess
  70208. * @param name defines the name of the postprocess
  70209. * @param _operator defines the operator to use
  70210. * @param exposureAdjustment defines the required exposure adjustement
  70211. * @param camera defines the camera to use (can be null)
  70212. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70213. * @param engine defines the hosting engine (can be ignore if camera is set)
  70214. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70215. */
  70216. constructor(name: string, _operator: TonemappingOperator,
  70217. /** Defines the required exposure adjustement */
  70218. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70219. }
  70220. }
  70221. declare module BABYLON {
  70222. /** @hidden */
  70223. export var volumetricLightScatteringPixelShader: {
  70224. name: string;
  70225. shader: string;
  70226. };
  70227. }
  70228. declare module BABYLON {
  70229. /** @hidden */
  70230. export var volumetricLightScatteringPassVertexShader: {
  70231. name: string;
  70232. shader: string;
  70233. };
  70234. }
  70235. declare module BABYLON {
  70236. /** @hidden */
  70237. export var volumetricLightScatteringPassPixelShader: {
  70238. name: string;
  70239. shader: string;
  70240. };
  70241. }
  70242. declare module BABYLON {
  70243. /**
  70244. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70245. */
  70246. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70247. private _volumetricLightScatteringPass;
  70248. private _volumetricLightScatteringRTT;
  70249. private _viewPort;
  70250. private _screenCoordinates;
  70251. private _cachedDefines;
  70252. /**
  70253. * If not undefined, the mesh position is computed from the attached node position
  70254. */
  70255. attachedNode: {
  70256. position: Vector3;
  70257. };
  70258. /**
  70259. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70260. */
  70261. customMeshPosition: Vector3;
  70262. /**
  70263. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70264. */
  70265. useCustomMeshPosition: boolean;
  70266. /**
  70267. * If the post-process should inverse the light scattering direction
  70268. */
  70269. invert: boolean;
  70270. /**
  70271. * The internal mesh used by the post-process
  70272. */
  70273. mesh: Mesh;
  70274. /**
  70275. * @hidden
  70276. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70277. */
  70278. get useDiffuseColor(): boolean;
  70279. set useDiffuseColor(useDiffuseColor: boolean);
  70280. /**
  70281. * Array containing the excluded meshes not rendered in the internal pass
  70282. */
  70283. excludedMeshes: AbstractMesh[];
  70284. /**
  70285. * Controls the overall intensity of the post-process
  70286. */
  70287. exposure: number;
  70288. /**
  70289. * Dissipates each sample's contribution in range [0, 1]
  70290. */
  70291. decay: number;
  70292. /**
  70293. * Controls the overall intensity of each sample
  70294. */
  70295. weight: number;
  70296. /**
  70297. * Controls the density of each sample
  70298. */
  70299. density: number;
  70300. /**
  70301. * @constructor
  70302. * @param name The post-process name
  70303. * @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)
  70304. * @param camera The camera that the post-process will be attached to
  70305. * @param mesh The mesh used to create the light scattering
  70306. * @param samples The post-process quality, default 100
  70307. * @param samplingModeThe post-process filtering mode
  70308. * @param engine The babylon engine
  70309. * @param reusable If the post-process is reusable
  70310. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70311. */
  70312. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70313. /**
  70314. * Returns the string "VolumetricLightScatteringPostProcess"
  70315. * @returns "VolumetricLightScatteringPostProcess"
  70316. */
  70317. getClassName(): string;
  70318. private _isReady;
  70319. /**
  70320. * Sets the new light position for light scattering effect
  70321. * @param position The new custom light position
  70322. */
  70323. setCustomMeshPosition(position: Vector3): void;
  70324. /**
  70325. * Returns the light position for light scattering effect
  70326. * @return Vector3 The custom light position
  70327. */
  70328. getCustomMeshPosition(): Vector3;
  70329. /**
  70330. * Disposes the internal assets and detaches the post-process from the camera
  70331. */
  70332. dispose(camera: Camera): void;
  70333. /**
  70334. * Returns the render target texture used by the post-process
  70335. * @return the render target texture used by the post-process
  70336. */
  70337. getPass(): RenderTargetTexture;
  70338. private _meshExcluded;
  70339. private _createPass;
  70340. private _updateMeshScreenCoordinates;
  70341. /**
  70342. * Creates a default mesh for the Volumeric Light Scattering post-process
  70343. * @param name The mesh name
  70344. * @param scene The scene where to create the mesh
  70345. * @return the default mesh
  70346. */
  70347. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70348. }
  70349. }
  70350. declare module BABYLON {
  70351. interface Scene {
  70352. /** @hidden (Backing field) */
  70353. _boundingBoxRenderer: BoundingBoxRenderer;
  70354. /** @hidden (Backing field) */
  70355. _forceShowBoundingBoxes: boolean;
  70356. /**
  70357. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70358. */
  70359. forceShowBoundingBoxes: boolean;
  70360. /**
  70361. * Gets the bounding box renderer associated with the scene
  70362. * @returns a BoundingBoxRenderer
  70363. */
  70364. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70365. }
  70366. interface AbstractMesh {
  70367. /** @hidden (Backing field) */
  70368. _showBoundingBox: boolean;
  70369. /**
  70370. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70371. */
  70372. showBoundingBox: boolean;
  70373. }
  70374. /**
  70375. * Component responsible of rendering the bounding box of the meshes in a scene.
  70376. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70377. */
  70378. export class BoundingBoxRenderer implements ISceneComponent {
  70379. /**
  70380. * The component name helpfull to identify the component in the list of scene components.
  70381. */
  70382. readonly name: string;
  70383. /**
  70384. * The scene the component belongs to.
  70385. */
  70386. scene: Scene;
  70387. /**
  70388. * Color of the bounding box lines placed in front of an object
  70389. */
  70390. frontColor: Color3;
  70391. /**
  70392. * Color of the bounding box lines placed behind an object
  70393. */
  70394. backColor: Color3;
  70395. /**
  70396. * Defines if the renderer should show the back lines or not
  70397. */
  70398. showBackLines: boolean;
  70399. /**
  70400. * Observable raised before rendering a bounding box
  70401. */
  70402. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70403. /**
  70404. * Observable raised after rendering a bounding box
  70405. */
  70406. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70407. /**
  70408. * @hidden
  70409. */
  70410. renderList: SmartArray<BoundingBox>;
  70411. private _colorShader;
  70412. private _vertexBuffers;
  70413. private _indexBuffer;
  70414. private _fillIndexBuffer;
  70415. private _fillIndexData;
  70416. /**
  70417. * Instantiates a new bounding box renderer in a scene.
  70418. * @param scene the scene the renderer renders in
  70419. */
  70420. constructor(scene: Scene);
  70421. /**
  70422. * Registers the component in a given scene
  70423. */
  70424. register(): void;
  70425. private _evaluateSubMesh;
  70426. private _activeMesh;
  70427. private _prepareRessources;
  70428. private _createIndexBuffer;
  70429. /**
  70430. * Rebuilds the elements related to this component in case of
  70431. * context lost for instance.
  70432. */
  70433. rebuild(): void;
  70434. /**
  70435. * @hidden
  70436. */
  70437. reset(): void;
  70438. /**
  70439. * Render the bounding boxes of a specific rendering group
  70440. * @param renderingGroupId defines the rendering group to render
  70441. */
  70442. render(renderingGroupId: number): void;
  70443. /**
  70444. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70445. * @param mesh Define the mesh to render the occlusion bounding box for
  70446. */
  70447. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70448. /**
  70449. * Dispose and release the resources attached to this renderer.
  70450. */
  70451. dispose(): void;
  70452. }
  70453. }
  70454. declare module BABYLON {
  70455. interface Scene {
  70456. /** @hidden (Backing field) */
  70457. _depthRenderer: {
  70458. [id: string]: DepthRenderer;
  70459. };
  70460. /**
  70461. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70462. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70463. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70464. * @returns the created depth renderer
  70465. */
  70466. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70467. /**
  70468. * Disables a depth renderer for a given camera
  70469. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70470. */
  70471. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70472. }
  70473. /**
  70474. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70475. * in several rendering techniques.
  70476. */
  70477. export class DepthRendererSceneComponent implements ISceneComponent {
  70478. /**
  70479. * The component name helpfull to identify the component in the list of scene components.
  70480. */
  70481. readonly name: string;
  70482. /**
  70483. * The scene the component belongs to.
  70484. */
  70485. scene: Scene;
  70486. /**
  70487. * Creates a new instance of the component for the given scene
  70488. * @param scene Defines the scene to register the component in
  70489. */
  70490. constructor(scene: Scene);
  70491. /**
  70492. * Registers the component in a given scene
  70493. */
  70494. register(): void;
  70495. /**
  70496. * Rebuilds the elements related to this component in case of
  70497. * context lost for instance.
  70498. */
  70499. rebuild(): void;
  70500. /**
  70501. * Disposes the component and the associated ressources
  70502. */
  70503. dispose(): void;
  70504. private _gatherRenderTargets;
  70505. private _gatherActiveCameraRenderTargets;
  70506. }
  70507. }
  70508. declare module BABYLON {
  70509. /** @hidden */
  70510. export var outlinePixelShader: {
  70511. name: string;
  70512. shader: string;
  70513. };
  70514. }
  70515. declare module BABYLON {
  70516. /** @hidden */
  70517. export var outlineVertexShader: {
  70518. name: string;
  70519. shader: string;
  70520. };
  70521. }
  70522. declare module BABYLON {
  70523. interface Scene {
  70524. /** @hidden */
  70525. _outlineRenderer: OutlineRenderer;
  70526. /**
  70527. * Gets the outline renderer associated with the scene
  70528. * @returns a OutlineRenderer
  70529. */
  70530. getOutlineRenderer(): OutlineRenderer;
  70531. }
  70532. interface AbstractMesh {
  70533. /** @hidden (Backing field) */
  70534. _renderOutline: boolean;
  70535. /**
  70536. * Gets or sets a boolean indicating if the outline must be rendered as well
  70537. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70538. */
  70539. renderOutline: boolean;
  70540. /** @hidden (Backing field) */
  70541. _renderOverlay: boolean;
  70542. /**
  70543. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70544. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70545. */
  70546. renderOverlay: boolean;
  70547. }
  70548. /**
  70549. * This class is responsible to draw bothe outline/overlay of meshes.
  70550. * It should not be used directly but through the available method on mesh.
  70551. */
  70552. export class OutlineRenderer implements ISceneComponent {
  70553. /**
  70554. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70555. */
  70556. private static _StencilReference;
  70557. /**
  70558. * The name of the component. Each component must have a unique name.
  70559. */
  70560. name: string;
  70561. /**
  70562. * The scene the component belongs to.
  70563. */
  70564. scene: Scene;
  70565. /**
  70566. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70567. */
  70568. zOffset: number;
  70569. private _engine;
  70570. private _effect;
  70571. private _cachedDefines;
  70572. private _savedDepthWrite;
  70573. /**
  70574. * Instantiates a new outline renderer. (There could be only one per scene).
  70575. * @param scene Defines the scene it belongs to
  70576. */
  70577. constructor(scene: Scene);
  70578. /**
  70579. * Register the component to one instance of a scene.
  70580. */
  70581. register(): void;
  70582. /**
  70583. * Rebuilds the elements related to this component in case of
  70584. * context lost for instance.
  70585. */
  70586. rebuild(): void;
  70587. /**
  70588. * Disposes the component and the associated ressources.
  70589. */
  70590. dispose(): void;
  70591. /**
  70592. * Renders the outline in the canvas.
  70593. * @param subMesh Defines the sumesh to render
  70594. * @param batch Defines the batch of meshes in case of instances
  70595. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70596. */
  70597. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70598. /**
  70599. * Returns whether or not the outline renderer is ready for a given submesh.
  70600. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70601. * @param subMesh Defines the submesh to check readyness for
  70602. * @param useInstances Defines wheter wee are trying to render instances or not
  70603. * @returns true if ready otherwise false
  70604. */
  70605. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70606. private _beforeRenderingMesh;
  70607. private _afterRenderingMesh;
  70608. }
  70609. }
  70610. declare module BABYLON {
  70611. /**
  70612. * Defines the basic options interface of a Sprite Frame Source Size.
  70613. */
  70614. export interface ISpriteJSONSpriteSourceSize {
  70615. /**
  70616. * number of the original width of the Frame
  70617. */
  70618. w: number;
  70619. /**
  70620. * number of the original height of the Frame
  70621. */
  70622. h: number;
  70623. }
  70624. /**
  70625. * Defines the basic options interface of a Sprite Frame Data.
  70626. */
  70627. export interface ISpriteJSONSpriteFrameData {
  70628. /**
  70629. * number of the x offset of the Frame
  70630. */
  70631. x: number;
  70632. /**
  70633. * number of the y offset of the Frame
  70634. */
  70635. y: number;
  70636. /**
  70637. * number of the width of the Frame
  70638. */
  70639. w: number;
  70640. /**
  70641. * number of the height of the Frame
  70642. */
  70643. h: number;
  70644. }
  70645. /**
  70646. * Defines the basic options interface of a JSON Sprite.
  70647. */
  70648. export interface ISpriteJSONSprite {
  70649. /**
  70650. * string name of the Frame
  70651. */
  70652. filename: string;
  70653. /**
  70654. * ISpriteJSONSpriteFrame basic object of the frame data
  70655. */
  70656. frame: ISpriteJSONSpriteFrameData;
  70657. /**
  70658. * boolean to flag is the frame was rotated.
  70659. */
  70660. rotated: boolean;
  70661. /**
  70662. * boolean to flag is the frame was trimmed.
  70663. */
  70664. trimmed: boolean;
  70665. /**
  70666. * ISpriteJSONSpriteFrame basic object of the source data
  70667. */
  70668. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70669. /**
  70670. * ISpriteJSONSpriteFrame basic object of the source data
  70671. */
  70672. sourceSize: ISpriteJSONSpriteSourceSize;
  70673. }
  70674. /**
  70675. * Defines the basic options interface of a JSON atlas.
  70676. */
  70677. export interface ISpriteJSONAtlas {
  70678. /**
  70679. * Array of objects that contain the frame data.
  70680. */
  70681. frames: Array<ISpriteJSONSprite>;
  70682. /**
  70683. * object basic object containing the sprite meta data.
  70684. */
  70685. meta?: object;
  70686. }
  70687. }
  70688. declare module BABYLON {
  70689. /** @hidden */
  70690. export var spriteMapPixelShader: {
  70691. name: string;
  70692. shader: string;
  70693. };
  70694. }
  70695. declare module BABYLON {
  70696. /** @hidden */
  70697. export var spriteMapVertexShader: {
  70698. name: string;
  70699. shader: string;
  70700. };
  70701. }
  70702. declare module BABYLON {
  70703. /**
  70704. * Defines the basic options interface of a SpriteMap
  70705. */
  70706. export interface ISpriteMapOptions {
  70707. /**
  70708. * Vector2 of the number of cells in the grid.
  70709. */
  70710. stageSize?: Vector2;
  70711. /**
  70712. * Vector2 of the size of the output plane in World Units.
  70713. */
  70714. outputSize?: Vector2;
  70715. /**
  70716. * Vector3 of the position of the output plane in World Units.
  70717. */
  70718. outputPosition?: Vector3;
  70719. /**
  70720. * Vector3 of the rotation of the output plane.
  70721. */
  70722. outputRotation?: Vector3;
  70723. /**
  70724. * number of layers that the system will reserve in resources.
  70725. */
  70726. layerCount?: number;
  70727. /**
  70728. * number of max animation frames a single cell will reserve in resources.
  70729. */
  70730. maxAnimationFrames?: number;
  70731. /**
  70732. * number cell index of the base tile when the system compiles.
  70733. */
  70734. baseTile?: number;
  70735. /**
  70736. * boolean flip the sprite after its been repositioned by the framing data.
  70737. */
  70738. flipU?: boolean;
  70739. /**
  70740. * Vector3 scalar of the global RGB values of the SpriteMap.
  70741. */
  70742. colorMultiply?: Vector3;
  70743. }
  70744. /**
  70745. * Defines the IDisposable interface in order to be cleanable from resources.
  70746. */
  70747. export interface ISpriteMap extends IDisposable {
  70748. /**
  70749. * String name of the SpriteMap.
  70750. */
  70751. name: string;
  70752. /**
  70753. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70754. */
  70755. atlasJSON: ISpriteJSONAtlas;
  70756. /**
  70757. * Texture of the SpriteMap.
  70758. */
  70759. spriteSheet: Texture;
  70760. /**
  70761. * The parameters to initialize the SpriteMap with.
  70762. */
  70763. options: ISpriteMapOptions;
  70764. }
  70765. /**
  70766. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70767. */
  70768. export class SpriteMap implements ISpriteMap {
  70769. /** The Name of the spriteMap */
  70770. name: string;
  70771. /** The JSON file with the frame and meta data */
  70772. atlasJSON: ISpriteJSONAtlas;
  70773. /** The systems Sprite Sheet Texture */
  70774. spriteSheet: Texture;
  70775. /** Arguments passed with the Constructor */
  70776. options: ISpriteMapOptions;
  70777. /** Public Sprite Storage array, parsed from atlasJSON */
  70778. sprites: Array<ISpriteJSONSprite>;
  70779. /** Returns the Number of Sprites in the System */
  70780. get spriteCount(): number;
  70781. /** Returns the Position of Output Plane*/
  70782. get position(): Vector3;
  70783. /** Returns the Position of Output Plane*/
  70784. set position(v: Vector3);
  70785. /** Returns the Rotation of Output Plane*/
  70786. get rotation(): Vector3;
  70787. /** Returns the Rotation of Output Plane*/
  70788. set rotation(v: Vector3);
  70789. /** Sets the AnimationMap*/
  70790. get animationMap(): RawTexture;
  70791. /** Sets the AnimationMap*/
  70792. set animationMap(v: RawTexture);
  70793. /** Scene that the SpriteMap was created in */
  70794. private _scene;
  70795. /** Texture Buffer of Float32 that holds tile frame data*/
  70796. private _frameMap;
  70797. /** Texture Buffers of Float32 that holds tileMap data*/
  70798. private _tileMaps;
  70799. /** Texture Buffer of Float32 that holds Animation Data*/
  70800. private _animationMap;
  70801. /** Custom ShaderMaterial Central to the System*/
  70802. private _material;
  70803. /** Custom ShaderMaterial Central to the System*/
  70804. private _output;
  70805. /** Systems Time Ticker*/
  70806. private _time;
  70807. /**
  70808. * Creates a new SpriteMap
  70809. * @param name defines the SpriteMaps Name
  70810. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70811. * @param spriteSheet is the Texture that the Sprites are on.
  70812. * @param options a basic deployment configuration
  70813. * @param scene The Scene that the map is deployed on
  70814. */
  70815. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70816. /**
  70817. * Returns tileID location
  70818. * @returns Vector2 the cell position ID
  70819. */
  70820. getTileID(): Vector2;
  70821. /**
  70822. * Gets the UV location of the mouse over the SpriteMap.
  70823. * @returns Vector2 the UV position of the mouse interaction
  70824. */
  70825. getMousePosition(): Vector2;
  70826. /**
  70827. * Creates the "frame" texture Buffer
  70828. * -------------------------------------
  70829. * Structure of frames
  70830. * "filename": "Falling-Water-2.png",
  70831. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70832. * "rotated": true,
  70833. * "trimmed": true,
  70834. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70835. * "sourceSize": {"w":32,"h":32}
  70836. * @returns RawTexture of the frameMap
  70837. */
  70838. private _createFrameBuffer;
  70839. /**
  70840. * Creates the tileMap texture Buffer
  70841. * @param buffer normally and array of numbers, or a false to generate from scratch
  70842. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70843. * @returns RawTexture of the tileMap
  70844. */
  70845. private _createTileBuffer;
  70846. /**
  70847. * Modifies the data of the tileMaps
  70848. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70849. * @param pos is the iVector2 Coordinates of the Tile
  70850. * @param tile The SpriteIndex of the new Tile
  70851. */
  70852. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70853. /**
  70854. * Creates the animationMap texture Buffer
  70855. * @param buffer normally and array of numbers, or a false to generate from scratch
  70856. * @returns RawTexture of the animationMap
  70857. */
  70858. private _createTileAnimationBuffer;
  70859. /**
  70860. * Modifies the data of the animationMap
  70861. * @param cellID is the Index of the Sprite
  70862. * @param _frame is the target Animation frame
  70863. * @param toCell is the Target Index of the next frame of the animation
  70864. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70865. * @param speed is a global scalar of the time variable on the map.
  70866. */
  70867. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70868. /**
  70869. * Exports the .tilemaps file
  70870. */
  70871. saveTileMaps(): void;
  70872. /**
  70873. * Imports the .tilemaps file
  70874. * @param url of the .tilemaps file
  70875. */
  70876. loadTileMaps(url: string): void;
  70877. /**
  70878. * Release associated resources
  70879. */
  70880. dispose(): void;
  70881. }
  70882. }
  70883. declare module BABYLON {
  70884. /**
  70885. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70886. * @see http://doc.babylonjs.com/babylon101/sprites
  70887. */
  70888. export class SpritePackedManager extends SpriteManager {
  70889. /** defines the packed manager's name */
  70890. name: string;
  70891. /**
  70892. * Creates a new sprite manager from a packed sprite sheet
  70893. * @param name defines the manager's name
  70894. * @param imgUrl defines the sprite sheet url
  70895. * @param capacity defines the maximum allowed number of sprites
  70896. * @param scene defines the hosting scene
  70897. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70898. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70899. * @param samplingMode defines the smapling mode to use with spritesheet
  70900. * @param fromPacked set to true; do not alter
  70901. */
  70902. constructor(
  70903. /** defines the packed manager's name */
  70904. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70905. }
  70906. }
  70907. declare module BABYLON {
  70908. /**
  70909. * Defines the list of states available for a task inside a AssetsManager
  70910. */
  70911. export enum AssetTaskState {
  70912. /**
  70913. * Initialization
  70914. */
  70915. INIT = 0,
  70916. /**
  70917. * Running
  70918. */
  70919. RUNNING = 1,
  70920. /**
  70921. * Done
  70922. */
  70923. DONE = 2,
  70924. /**
  70925. * Error
  70926. */
  70927. ERROR = 3
  70928. }
  70929. /**
  70930. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70931. */
  70932. export abstract class AbstractAssetTask {
  70933. /**
  70934. * Task name
  70935. */ name: string;
  70936. /**
  70937. * Callback called when the task is successful
  70938. */
  70939. onSuccess: (task: any) => void;
  70940. /**
  70941. * Callback called when the task is not successful
  70942. */
  70943. onError: (task: any, message?: string, exception?: any) => void;
  70944. /**
  70945. * Creates a new AssetsManager
  70946. * @param name defines the name of the task
  70947. */
  70948. constructor(
  70949. /**
  70950. * Task name
  70951. */ name: string);
  70952. private _isCompleted;
  70953. private _taskState;
  70954. private _errorObject;
  70955. /**
  70956. * Get if the task is completed
  70957. */
  70958. get isCompleted(): boolean;
  70959. /**
  70960. * Gets the current state of the task
  70961. */
  70962. get taskState(): AssetTaskState;
  70963. /**
  70964. * Gets the current error object (if task is in error)
  70965. */
  70966. get errorObject(): {
  70967. message?: string;
  70968. exception?: any;
  70969. };
  70970. /**
  70971. * Internal only
  70972. * @hidden
  70973. */
  70974. _setErrorObject(message?: string, exception?: any): void;
  70975. /**
  70976. * Execute the current task
  70977. * @param scene defines the scene where you want your assets to be loaded
  70978. * @param onSuccess is a callback called when the task is successfully executed
  70979. * @param onError is a callback called if an error occurs
  70980. */
  70981. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70982. /**
  70983. * Execute the current task
  70984. * @param scene defines the scene where you want your assets to be loaded
  70985. * @param onSuccess is a callback called when the task is successfully executed
  70986. * @param onError is a callback called if an error occurs
  70987. */
  70988. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70989. /**
  70990. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70991. * This can be used with failed tasks that have the reason for failure fixed.
  70992. */
  70993. reset(): void;
  70994. private onErrorCallback;
  70995. private onDoneCallback;
  70996. }
  70997. /**
  70998. * Define the interface used by progress events raised during assets loading
  70999. */
  71000. export interface 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. /**
  71015. * Class used to share progress information about assets loading
  71016. */
  71017. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71018. /**
  71019. * Defines the number of remaining tasks to process
  71020. */
  71021. remainingCount: number;
  71022. /**
  71023. * Defines the total number of tasks
  71024. */
  71025. totalCount: number;
  71026. /**
  71027. * Defines the task that was just processed
  71028. */
  71029. task: AbstractAssetTask;
  71030. /**
  71031. * Creates a AssetsProgressEvent
  71032. * @param remainingCount defines the number of remaining tasks to process
  71033. * @param totalCount defines the total number of tasks
  71034. * @param task defines the task that was just processed
  71035. */
  71036. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71037. }
  71038. /**
  71039. * Define a task used by AssetsManager to load meshes
  71040. */
  71041. export class MeshAssetTask extends AbstractAssetTask {
  71042. /**
  71043. * Defines the name of the task
  71044. */
  71045. name: string;
  71046. /**
  71047. * Defines the list of mesh's names you want to load
  71048. */
  71049. meshesNames: any;
  71050. /**
  71051. * Defines the root url to use as a base to load your meshes and associated resources
  71052. */
  71053. rootUrl: string;
  71054. /**
  71055. * Defines the filename or File of the scene to load from
  71056. */
  71057. sceneFilename: string | File;
  71058. /**
  71059. * Gets the list of loaded meshes
  71060. */
  71061. loadedMeshes: Array<AbstractMesh>;
  71062. /**
  71063. * Gets the list of loaded particle systems
  71064. */
  71065. loadedParticleSystems: Array<IParticleSystem>;
  71066. /**
  71067. * Gets the list of loaded skeletons
  71068. */
  71069. loadedSkeletons: Array<Skeleton>;
  71070. /**
  71071. * Gets the list of loaded animation groups
  71072. */
  71073. loadedAnimationGroups: Array<AnimationGroup>;
  71074. /**
  71075. * Callback called when the task is successful
  71076. */
  71077. onSuccess: (task: MeshAssetTask) => void;
  71078. /**
  71079. * Callback called when the task is successful
  71080. */
  71081. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71082. /**
  71083. * Creates a new MeshAssetTask
  71084. * @param name defines the name of the task
  71085. * @param meshesNames defines the list of mesh's names you want to load
  71086. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71087. * @param sceneFilename defines the filename or File of the scene to load from
  71088. */
  71089. constructor(
  71090. /**
  71091. * Defines the name of the task
  71092. */
  71093. name: string,
  71094. /**
  71095. * Defines the list of mesh's names you want to load
  71096. */
  71097. meshesNames: any,
  71098. /**
  71099. * Defines the root url to use as a base to load your meshes and associated resources
  71100. */
  71101. rootUrl: string,
  71102. /**
  71103. * Defines the filename or File of the scene to load from
  71104. */
  71105. sceneFilename: string | File);
  71106. /**
  71107. * Execute the current task
  71108. * @param scene defines the scene where you want your assets to be loaded
  71109. * @param onSuccess is a callback called when the task is successfully executed
  71110. * @param onError is a callback called if an error occurs
  71111. */
  71112. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71113. }
  71114. /**
  71115. * Define a task used by AssetsManager to load text content
  71116. */
  71117. export class TextFileAssetTask extends AbstractAssetTask {
  71118. /**
  71119. * Defines the name of the task
  71120. */
  71121. name: string;
  71122. /**
  71123. * Defines the location of the file to load
  71124. */
  71125. url: string;
  71126. /**
  71127. * Gets the loaded text string
  71128. */
  71129. text: string;
  71130. /**
  71131. * Callback called when the task is successful
  71132. */
  71133. onSuccess: (task: TextFileAssetTask) => void;
  71134. /**
  71135. * Callback called when the task is successful
  71136. */
  71137. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71138. /**
  71139. * Creates a new TextFileAssetTask object
  71140. * @param name defines the name of the task
  71141. * @param url defines the location of the file to load
  71142. */
  71143. constructor(
  71144. /**
  71145. * Defines the name of the task
  71146. */
  71147. name: string,
  71148. /**
  71149. * Defines the location of the file to load
  71150. */
  71151. url: string);
  71152. /**
  71153. * Execute the current task
  71154. * @param scene defines the scene where you want your assets to be loaded
  71155. * @param onSuccess is a callback called when the task is successfully executed
  71156. * @param onError is a callback called if an error occurs
  71157. */
  71158. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71159. }
  71160. /**
  71161. * Define a task used by AssetsManager to load binary data
  71162. */
  71163. export class BinaryFileAssetTask extends AbstractAssetTask {
  71164. /**
  71165. * Defines the name of the task
  71166. */
  71167. name: string;
  71168. /**
  71169. * Defines the location of the file to load
  71170. */
  71171. url: string;
  71172. /**
  71173. * Gets the lodaded data (as an array buffer)
  71174. */
  71175. data: ArrayBuffer;
  71176. /**
  71177. * Callback called when the task is successful
  71178. */
  71179. onSuccess: (task: BinaryFileAssetTask) => void;
  71180. /**
  71181. * Callback called when the task is successful
  71182. */
  71183. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71184. /**
  71185. * Creates a new BinaryFileAssetTask object
  71186. * @param name defines the name of the new task
  71187. * @param url defines the location of the file to load
  71188. */
  71189. constructor(
  71190. /**
  71191. * Defines the name of the task
  71192. */
  71193. name: string,
  71194. /**
  71195. * Defines the location of the file to load
  71196. */
  71197. url: string);
  71198. /**
  71199. * Execute the current task
  71200. * @param scene defines the scene where you want your assets to be loaded
  71201. * @param onSuccess is a callback called when the task is successfully executed
  71202. * @param onError is a callback called if an error occurs
  71203. */
  71204. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71205. }
  71206. /**
  71207. * Define a task used by AssetsManager to load images
  71208. */
  71209. export class ImageAssetTask extends AbstractAssetTask {
  71210. /**
  71211. * Defines the name of the task
  71212. */
  71213. name: string;
  71214. /**
  71215. * Defines the location of the image to load
  71216. */
  71217. url: string;
  71218. /**
  71219. * Gets the loaded images
  71220. */
  71221. image: HTMLImageElement;
  71222. /**
  71223. * Callback called when the task is successful
  71224. */
  71225. onSuccess: (task: ImageAssetTask) => void;
  71226. /**
  71227. * Callback called when the task is successful
  71228. */
  71229. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71230. /**
  71231. * Creates a new ImageAssetTask
  71232. * @param name defines the name of the task
  71233. * @param url defines the location of the image to load
  71234. */
  71235. constructor(
  71236. /**
  71237. * Defines the name of the task
  71238. */
  71239. name: string,
  71240. /**
  71241. * Defines the location of the image to load
  71242. */
  71243. url: string);
  71244. /**
  71245. * Execute the current task
  71246. * @param scene defines the scene where you want your assets to be loaded
  71247. * @param onSuccess is a callback called when the task is successfully executed
  71248. * @param onError is a callback called if an error occurs
  71249. */
  71250. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71251. }
  71252. /**
  71253. * Defines the interface used by texture loading tasks
  71254. */
  71255. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71256. /**
  71257. * Gets the loaded texture
  71258. */
  71259. texture: TEX;
  71260. }
  71261. /**
  71262. * Define a task used by AssetsManager to load 2D textures
  71263. */
  71264. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71265. /**
  71266. * Defines the name of the task
  71267. */
  71268. name: string;
  71269. /**
  71270. * Defines the location of the file to load
  71271. */
  71272. url: string;
  71273. /**
  71274. * Defines if mipmap should not be generated (default is false)
  71275. */
  71276. noMipmap?: boolean | undefined;
  71277. /**
  71278. * Defines if texture must be inverted on Y axis (default is true)
  71279. */
  71280. invertY: boolean;
  71281. /**
  71282. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71283. */
  71284. samplingMode: number;
  71285. /**
  71286. * Gets the loaded texture
  71287. */
  71288. texture: Texture;
  71289. /**
  71290. * Callback called when the task is successful
  71291. */
  71292. onSuccess: (task: TextureAssetTask) => void;
  71293. /**
  71294. * Callback called when the task is successful
  71295. */
  71296. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71297. /**
  71298. * Creates a new TextureAssetTask object
  71299. * @param name defines the name of the task
  71300. * @param url defines the location of the file to load
  71301. * @param noMipmap defines if mipmap should not be generated (default is false)
  71302. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71303. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71304. */
  71305. constructor(
  71306. /**
  71307. * Defines the name of the task
  71308. */
  71309. name: string,
  71310. /**
  71311. * Defines the location of the file to load
  71312. */
  71313. url: string,
  71314. /**
  71315. * Defines if mipmap should not be generated (default is false)
  71316. */
  71317. noMipmap?: boolean | undefined,
  71318. /**
  71319. * Defines if texture must be inverted on Y axis (default is true)
  71320. */
  71321. invertY?: boolean,
  71322. /**
  71323. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71324. */
  71325. samplingMode?: number);
  71326. /**
  71327. * Execute the current task
  71328. * @param scene defines the scene where you want your assets to be loaded
  71329. * @param onSuccess is a callback called when the task is successfully executed
  71330. * @param onError is a callback called if an error occurs
  71331. */
  71332. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71333. }
  71334. /**
  71335. * Define a task used by AssetsManager to load cube textures
  71336. */
  71337. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71338. /**
  71339. * Defines the name of the task
  71340. */
  71341. name: string;
  71342. /**
  71343. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71344. */
  71345. url: string;
  71346. /**
  71347. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71348. */
  71349. extensions?: string[] | undefined;
  71350. /**
  71351. * Defines if mipmaps should not be generated (default is false)
  71352. */
  71353. noMipmap?: boolean | undefined;
  71354. /**
  71355. * Defines the explicit list of files (undefined by default)
  71356. */
  71357. files?: string[] | undefined;
  71358. /**
  71359. * Gets the loaded texture
  71360. */
  71361. texture: CubeTexture;
  71362. /**
  71363. * Callback called when the task is successful
  71364. */
  71365. onSuccess: (task: CubeTextureAssetTask) => void;
  71366. /**
  71367. * Callback called when the task is successful
  71368. */
  71369. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71370. /**
  71371. * Creates a new CubeTextureAssetTask
  71372. * @param name defines the name of the task
  71373. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71374. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71375. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71376. * @param files defines the explicit list of files (undefined by default)
  71377. */
  71378. constructor(
  71379. /**
  71380. * Defines the name of the task
  71381. */
  71382. name: string,
  71383. /**
  71384. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71385. */
  71386. url: string,
  71387. /**
  71388. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71389. */
  71390. extensions?: string[] | undefined,
  71391. /**
  71392. * Defines if mipmaps should not be generated (default is false)
  71393. */
  71394. noMipmap?: boolean | undefined,
  71395. /**
  71396. * Defines the explicit list of files (undefined by default)
  71397. */
  71398. files?: string[] | undefined);
  71399. /**
  71400. * Execute the current task
  71401. * @param scene defines the scene where you want your assets to be loaded
  71402. * @param onSuccess is a callback called when the task is successfully executed
  71403. * @param onError is a callback called if an error occurs
  71404. */
  71405. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71406. }
  71407. /**
  71408. * Define a task used by AssetsManager to load HDR cube textures
  71409. */
  71410. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71411. /**
  71412. * Defines the name of the task
  71413. */
  71414. name: string;
  71415. /**
  71416. * Defines the location of the file to load
  71417. */
  71418. url: string;
  71419. /**
  71420. * Defines the desired size (the more it increases the longer the generation will be)
  71421. */
  71422. size: number;
  71423. /**
  71424. * Defines if mipmaps should not be generated (default is false)
  71425. */
  71426. noMipmap: boolean;
  71427. /**
  71428. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71429. */
  71430. generateHarmonics: boolean;
  71431. /**
  71432. * 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)
  71433. */
  71434. gammaSpace: boolean;
  71435. /**
  71436. * Internal Use Only
  71437. */
  71438. reserved: boolean;
  71439. /**
  71440. * Gets the loaded texture
  71441. */
  71442. texture: HDRCubeTexture;
  71443. /**
  71444. * Callback called when the task is successful
  71445. */
  71446. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71447. /**
  71448. * Callback called when the task is successful
  71449. */
  71450. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71451. /**
  71452. * Creates a new HDRCubeTextureAssetTask object
  71453. * @param name defines the name of the task
  71454. * @param url defines the location of the file to load
  71455. * @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.
  71456. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71457. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71458. * @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)
  71459. * @param reserved Internal use only
  71460. */
  71461. constructor(
  71462. /**
  71463. * Defines the name of the task
  71464. */
  71465. name: string,
  71466. /**
  71467. * Defines the location of the file to load
  71468. */
  71469. url: string,
  71470. /**
  71471. * Defines the desired size (the more it increases the longer the generation will be)
  71472. */
  71473. size: number,
  71474. /**
  71475. * Defines if mipmaps should not be generated (default is false)
  71476. */
  71477. noMipmap?: boolean,
  71478. /**
  71479. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71480. */
  71481. generateHarmonics?: boolean,
  71482. /**
  71483. * 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)
  71484. */
  71485. gammaSpace?: boolean,
  71486. /**
  71487. * Internal Use Only
  71488. */
  71489. reserved?: boolean);
  71490. /**
  71491. * Execute the current task
  71492. * @param scene defines the scene where you want your assets to be loaded
  71493. * @param onSuccess is a callback called when the task is successfully executed
  71494. * @param onError is a callback called if an error occurs
  71495. */
  71496. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71497. }
  71498. /**
  71499. * Define a task used by AssetsManager to load Equirectangular cube textures
  71500. */
  71501. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71502. /**
  71503. * Defines the name of the task
  71504. */
  71505. name: string;
  71506. /**
  71507. * Defines the location of the file to load
  71508. */
  71509. url: string;
  71510. /**
  71511. * Defines the desired size (the more it increases the longer the generation will be)
  71512. */
  71513. size: number;
  71514. /**
  71515. * Defines if mipmaps should not be generated (default is false)
  71516. */
  71517. noMipmap: boolean;
  71518. /**
  71519. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71520. * but the standard material would require them in Gamma space) (default is true)
  71521. */
  71522. gammaSpace: boolean;
  71523. /**
  71524. * Gets the loaded texture
  71525. */
  71526. texture: EquiRectangularCubeTexture;
  71527. /**
  71528. * Callback called when the task is successful
  71529. */
  71530. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71531. /**
  71532. * Callback called when the task is successful
  71533. */
  71534. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71535. /**
  71536. * Creates a new EquiRectangularCubeTextureAssetTask object
  71537. * @param name defines the name of the task
  71538. * @param url defines the location of the file to load
  71539. * @param size defines the desired size (the more it increases the longer the generation will be)
  71540. * If the size is omitted this implies you are using a preprocessed cubemap.
  71541. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71542. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71543. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71544. * (default is true)
  71545. */
  71546. constructor(
  71547. /**
  71548. * Defines the name of the task
  71549. */
  71550. name: string,
  71551. /**
  71552. * Defines the location of the file to load
  71553. */
  71554. url: string,
  71555. /**
  71556. * Defines the desired size (the more it increases the longer the generation will be)
  71557. */
  71558. size: number,
  71559. /**
  71560. * Defines if mipmaps should not be generated (default is false)
  71561. */
  71562. noMipmap?: boolean,
  71563. /**
  71564. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71565. * but the standard material would require them in Gamma space) (default is true)
  71566. */
  71567. gammaSpace?: boolean);
  71568. /**
  71569. * Execute the current task
  71570. * @param scene defines the scene where you want your assets to be loaded
  71571. * @param onSuccess is a callback called when the task is successfully executed
  71572. * @param onError is a callback called if an error occurs
  71573. */
  71574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71575. }
  71576. /**
  71577. * This class can be used to easily import assets into a scene
  71578. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71579. */
  71580. export class AssetsManager {
  71581. private _scene;
  71582. private _isLoading;
  71583. protected _tasks: AbstractAssetTask[];
  71584. protected _waitingTasksCount: number;
  71585. protected _totalTasksCount: number;
  71586. /**
  71587. * Callback called when all tasks are processed
  71588. */
  71589. onFinish: (tasks: AbstractAssetTask[]) => void;
  71590. /**
  71591. * Callback called when a task is successful
  71592. */
  71593. onTaskSuccess: (task: AbstractAssetTask) => void;
  71594. /**
  71595. * Callback called when a task had an error
  71596. */
  71597. onTaskError: (task: AbstractAssetTask) => void;
  71598. /**
  71599. * Callback called when a task is done (whatever the result is)
  71600. */
  71601. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71602. /**
  71603. * Observable called when all tasks are processed
  71604. */
  71605. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71606. /**
  71607. * Observable called when a task had an error
  71608. */
  71609. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71610. /**
  71611. * Observable called when all tasks were executed
  71612. */
  71613. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71614. /**
  71615. * Observable called when a task is done (whatever the result is)
  71616. */
  71617. onProgressObservable: Observable<IAssetsProgressEvent>;
  71618. /**
  71619. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71620. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71621. */
  71622. useDefaultLoadingScreen: boolean;
  71623. /**
  71624. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71625. * when all assets have been downloaded.
  71626. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71627. */
  71628. autoHideLoadingUI: boolean;
  71629. /**
  71630. * Creates a new AssetsManager
  71631. * @param scene defines the scene to work on
  71632. */
  71633. constructor(scene: Scene);
  71634. /**
  71635. * Add a MeshAssetTask to the list of active tasks
  71636. * @param taskName defines the name of the new task
  71637. * @param meshesNames defines the name of meshes to load
  71638. * @param rootUrl defines the root url to use to locate files
  71639. * @param sceneFilename defines the filename of the scene file
  71640. * @returns a new MeshAssetTask object
  71641. */
  71642. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71643. /**
  71644. * Add a TextFileAssetTask to the list of active tasks
  71645. * @param taskName defines the name of the new task
  71646. * @param url defines the url of the file to load
  71647. * @returns a new TextFileAssetTask object
  71648. */
  71649. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71650. /**
  71651. * Add a BinaryFileAssetTask to the list of active tasks
  71652. * @param taskName defines the name of the new task
  71653. * @param url defines the url of the file to load
  71654. * @returns a new BinaryFileAssetTask object
  71655. */
  71656. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71657. /**
  71658. * Add a ImageAssetTask 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. * @returns a new ImageAssetTask object
  71662. */
  71663. addImageTask(taskName: string, url: string): ImageAssetTask;
  71664. /**
  71665. * Add a TextureAssetTask to the list of active tasks
  71666. * @param taskName defines the name of the new task
  71667. * @param url defines the url of the file to load
  71668. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71669. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71670. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71671. * @returns a new TextureAssetTask object
  71672. */
  71673. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71674. /**
  71675. * Add a CubeTextureAssetTask to the list of active tasks
  71676. * @param taskName defines the name of the new task
  71677. * @param url defines the url of the file to load
  71678. * @param extensions defines the extension to use to load the cube map (can be null)
  71679. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71680. * @param files defines the list of files to load (can be null)
  71681. * @returns a new CubeTextureAssetTask object
  71682. */
  71683. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71684. /**
  71685. *
  71686. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71687. * @param taskName defines the name of the new task
  71688. * @param url defines the url of the file to load
  71689. * @param size defines the size you want for the cubemap (can be null)
  71690. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71691. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71692. * @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)
  71693. * @param reserved Internal use only
  71694. * @returns a new HDRCubeTextureAssetTask object
  71695. */
  71696. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71697. /**
  71698. *
  71699. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71700. * @param taskName defines the name of the new task
  71701. * @param url defines the url of the file to load
  71702. * @param size defines the size you want for the cubemap (can be null)
  71703. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71704. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71705. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71706. * @returns a new EquiRectangularCubeTextureAssetTask object
  71707. */
  71708. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71709. /**
  71710. * Remove a task from the assets manager.
  71711. * @param task the task to remove
  71712. */
  71713. removeTask(task: AbstractAssetTask): void;
  71714. private _decreaseWaitingTasksCount;
  71715. private _runTask;
  71716. /**
  71717. * Reset the AssetsManager and remove all tasks
  71718. * @return the current instance of the AssetsManager
  71719. */
  71720. reset(): AssetsManager;
  71721. /**
  71722. * Start the loading process
  71723. * @return the current instance of the AssetsManager
  71724. */
  71725. load(): AssetsManager;
  71726. /**
  71727. * Start the loading process as an async operation
  71728. * @return a promise returning the list of failed tasks
  71729. */
  71730. loadAsync(): Promise<void>;
  71731. }
  71732. }
  71733. declare module BABYLON {
  71734. /**
  71735. * Wrapper class for promise with external resolve and reject.
  71736. */
  71737. export class Deferred<T> {
  71738. /**
  71739. * The promise associated with this deferred object.
  71740. */
  71741. readonly promise: Promise<T>;
  71742. private _resolve;
  71743. private _reject;
  71744. /**
  71745. * The resolve method of the promise associated with this deferred object.
  71746. */
  71747. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71748. /**
  71749. * The reject method of the promise associated with this deferred object.
  71750. */
  71751. get reject(): (reason?: any) => void;
  71752. /**
  71753. * Constructor for this deferred object.
  71754. */
  71755. constructor();
  71756. }
  71757. }
  71758. declare module BABYLON {
  71759. /**
  71760. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71761. */
  71762. export class MeshExploder {
  71763. private _centerMesh;
  71764. private _meshes;
  71765. private _meshesOrigins;
  71766. private _toCenterVectors;
  71767. private _scaledDirection;
  71768. private _newPosition;
  71769. private _centerPosition;
  71770. /**
  71771. * Explodes meshes from a center mesh.
  71772. * @param meshes The meshes to explode.
  71773. * @param centerMesh The mesh to be center of explosion.
  71774. */
  71775. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71776. private _setCenterMesh;
  71777. /**
  71778. * Get class name
  71779. * @returns "MeshExploder"
  71780. */
  71781. getClassName(): string;
  71782. /**
  71783. * "Exploded meshes"
  71784. * @returns Array of meshes with the centerMesh at index 0.
  71785. */
  71786. getMeshes(): Array<Mesh>;
  71787. /**
  71788. * Explodes meshes giving a specific direction
  71789. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71790. */
  71791. explode(direction?: number): void;
  71792. }
  71793. }
  71794. declare module BABYLON {
  71795. /**
  71796. * Class used to help managing file picking and drag'n'drop
  71797. */
  71798. export class FilesInput {
  71799. /**
  71800. * List of files ready to be loaded
  71801. */
  71802. static get FilesToLoad(): {
  71803. [key: string]: File;
  71804. };
  71805. /**
  71806. * Callback called when a file is processed
  71807. */
  71808. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71809. private _engine;
  71810. private _currentScene;
  71811. private _sceneLoadedCallback;
  71812. private _progressCallback;
  71813. private _additionalRenderLoopLogicCallback;
  71814. private _textureLoadingCallback;
  71815. private _startingProcessingFilesCallback;
  71816. private _onReloadCallback;
  71817. private _errorCallback;
  71818. private _elementToMonitor;
  71819. private _sceneFileToLoad;
  71820. private _filesToLoad;
  71821. /**
  71822. * Creates a new FilesInput
  71823. * @param engine defines the rendering engine
  71824. * @param scene defines the hosting scene
  71825. * @param sceneLoadedCallback callback called when scene is loaded
  71826. * @param progressCallback callback called to track progress
  71827. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71828. * @param textureLoadingCallback callback called when a texture is loading
  71829. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71830. * @param onReloadCallback callback called when a reload is requested
  71831. * @param errorCallback callback call if an error occurs
  71832. */
  71833. 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);
  71834. private _dragEnterHandler;
  71835. private _dragOverHandler;
  71836. private _dropHandler;
  71837. /**
  71838. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71839. * @param elementToMonitor defines the DOM element to track
  71840. */
  71841. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71842. /**
  71843. * Release all associated resources
  71844. */
  71845. dispose(): void;
  71846. private renderFunction;
  71847. private drag;
  71848. private drop;
  71849. private _traverseFolder;
  71850. private _processFiles;
  71851. /**
  71852. * Load files from a drop event
  71853. * @param event defines the drop event to use as source
  71854. */
  71855. loadFiles(event: any): void;
  71856. private _processReload;
  71857. /**
  71858. * Reload the current scene from the loaded files
  71859. */
  71860. reload(): void;
  71861. }
  71862. }
  71863. declare module BABYLON {
  71864. /**
  71865. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71866. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71867. */
  71868. export class SceneOptimization {
  71869. /**
  71870. * Defines the priority of this optimization (0 by default which means first in the list)
  71871. */
  71872. priority: number;
  71873. /**
  71874. * Gets a string describing the action executed by the current optimization
  71875. * @returns description string
  71876. */
  71877. getDescription(): string;
  71878. /**
  71879. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71880. * @param scene defines the current scene where to apply this optimization
  71881. * @param optimizer defines the current optimizer
  71882. * @returns true if everything that can be done was applied
  71883. */
  71884. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71885. /**
  71886. * Creates the SceneOptimization object
  71887. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71888. * @param desc defines the description associated with the optimization
  71889. */
  71890. constructor(
  71891. /**
  71892. * Defines the priority of this optimization (0 by default which means first in the list)
  71893. */
  71894. priority?: number);
  71895. }
  71896. /**
  71897. * Defines an optimization used to reduce the size of render target textures
  71898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71899. */
  71900. export class TextureOptimization extends SceneOptimization {
  71901. /**
  71902. * Defines the priority of this optimization (0 by default which means first in the list)
  71903. */
  71904. priority: number;
  71905. /**
  71906. * 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
  71907. */
  71908. maximumSize: number;
  71909. /**
  71910. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71911. */
  71912. step: number;
  71913. /**
  71914. * Gets a string describing the action executed by the current optimization
  71915. * @returns description string
  71916. */
  71917. getDescription(): string;
  71918. /**
  71919. * Creates the TextureOptimization object
  71920. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71921. * @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
  71922. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71923. */
  71924. constructor(
  71925. /**
  71926. * Defines the priority of this optimization (0 by default which means first in the list)
  71927. */
  71928. priority?: number,
  71929. /**
  71930. * 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
  71931. */
  71932. maximumSize?: number,
  71933. /**
  71934. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71935. */
  71936. step?: number);
  71937. /**
  71938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71939. * @param scene defines the current scene where to apply this optimization
  71940. * @param optimizer defines the current optimizer
  71941. * @returns true if everything that can be done was applied
  71942. */
  71943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71944. }
  71945. /**
  71946. * Defines an optimization used to increase or decrease the rendering resolution
  71947. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71948. */
  71949. export class HardwareScalingOptimization extends SceneOptimization {
  71950. /**
  71951. * Defines the priority of this optimization (0 by default which means first in the list)
  71952. */
  71953. priority: number;
  71954. /**
  71955. * Defines the maximum scale to use (2 by default)
  71956. */
  71957. maximumScale: number;
  71958. /**
  71959. * Defines the step to use between two passes (0.5 by default)
  71960. */
  71961. step: number;
  71962. private _currentScale;
  71963. private _directionOffset;
  71964. /**
  71965. * Gets a string describing the action executed by the current optimization
  71966. * @return description string
  71967. */
  71968. getDescription(): string;
  71969. /**
  71970. * Creates the HardwareScalingOptimization object
  71971. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71972. * @param maximumScale defines the maximum scale to use (2 by default)
  71973. * @param step defines the step to use between two passes (0.5 by default)
  71974. */
  71975. constructor(
  71976. /**
  71977. * Defines the priority of this optimization (0 by default which means first in the list)
  71978. */
  71979. priority?: number,
  71980. /**
  71981. * Defines the maximum scale to use (2 by default)
  71982. */
  71983. maximumScale?: number,
  71984. /**
  71985. * Defines the step to use between two passes (0.5 by default)
  71986. */
  71987. step?: number);
  71988. /**
  71989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71990. * @param scene defines the current scene where to apply this optimization
  71991. * @param optimizer defines the current optimizer
  71992. * @returns true if everything that can be done was applied
  71993. */
  71994. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71995. }
  71996. /**
  71997. * Defines an optimization used to remove shadows
  71998. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71999. */
  72000. export class ShadowsOptimization extends SceneOptimization {
  72001. /**
  72002. * Gets a string describing the action executed by the current optimization
  72003. * @return description string
  72004. */
  72005. getDescription(): string;
  72006. /**
  72007. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72008. * @param scene defines the current scene where to apply this optimization
  72009. * @param optimizer defines the current optimizer
  72010. * @returns true if everything that can be done was applied
  72011. */
  72012. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72013. }
  72014. /**
  72015. * Defines an optimization used to turn post-processes off
  72016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72017. */
  72018. export class PostProcessesOptimization extends SceneOptimization {
  72019. /**
  72020. * Gets a string describing the action executed by the current optimization
  72021. * @return description string
  72022. */
  72023. getDescription(): string;
  72024. /**
  72025. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72026. * @param scene defines the current scene where to apply this optimization
  72027. * @param optimizer defines the current optimizer
  72028. * @returns true if everything that can be done was applied
  72029. */
  72030. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72031. }
  72032. /**
  72033. * Defines an optimization used to turn lens flares off
  72034. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72035. */
  72036. export class LensFlaresOptimization extends SceneOptimization {
  72037. /**
  72038. * Gets a string describing the action executed by the current optimization
  72039. * @return description string
  72040. */
  72041. getDescription(): string;
  72042. /**
  72043. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72044. * @param scene defines the current scene where to apply this optimization
  72045. * @param optimizer defines the current optimizer
  72046. * @returns true if everything that can be done was applied
  72047. */
  72048. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72049. }
  72050. /**
  72051. * Defines an optimization based on user defined callback.
  72052. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72053. */
  72054. export class CustomOptimization extends SceneOptimization {
  72055. /**
  72056. * Callback called to apply the custom optimization.
  72057. */
  72058. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72059. /**
  72060. * Callback called to get custom description
  72061. */
  72062. onGetDescription: () => string;
  72063. /**
  72064. * Gets a string describing the action executed by the current optimization
  72065. * @returns description string
  72066. */
  72067. getDescription(): string;
  72068. /**
  72069. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72070. * @param scene defines the current scene where to apply this optimization
  72071. * @param optimizer defines the current optimizer
  72072. * @returns true if everything that can be done was applied
  72073. */
  72074. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72075. }
  72076. /**
  72077. * Defines an optimization used to turn particles off
  72078. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72079. */
  72080. export class ParticlesOptimization extends SceneOptimization {
  72081. /**
  72082. * Gets a string describing the action executed by the current optimization
  72083. * @return description string
  72084. */
  72085. getDescription(): string;
  72086. /**
  72087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72088. * @param scene defines the current scene where to apply this optimization
  72089. * @param optimizer defines the current optimizer
  72090. * @returns true if everything that can be done was applied
  72091. */
  72092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72093. }
  72094. /**
  72095. * Defines an optimization used to turn render targets off
  72096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72097. */
  72098. export class RenderTargetsOptimization extends SceneOptimization {
  72099. /**
  72100. * Gets a string describing the action executed by the current optimization
  72101. * @return description string
  72102. */
  72103. getDescription(): string;
  72104. /**
  72105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72106. * @param scene defines the current scene where to apply this optimization
  72107. * @param optimizer defines the current optimizer
  72108. * @returns true if everything that can be done was applied
  72109. */
  72110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72111. }
  72112. /**
  72113. * Defines an optimization used to merge meshes with compatible materials
  72114. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72115. */
  72116. export class MergeMeshesOptimization extends SceneOptimization {
  72117. private static _UpdateSelectionTree;
  72118. /**
  72119. * Gets or sets a boolean which defines if optimization octree has to be updated
  72120. */
  72121. static get UpdateSelectionTree(): boolean;
  72122. /**
  72123. * Gets or sets a boolean which defines if optimization octree has to be updated
  72124. */
  72125. static set UpdateSelectionTree(value: boolean);
  72126. /**
  72127. * Gets a string describing the action executed by the current optimization
  72128. * @return description string
  72129. */
  72130. getDescription(): string;
  72131. private _canBeMerged;
  72132. /**
  72133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72134. * @param scene defines the current scene where to apply this optimization
  72135. * @param optimizer defines the current optimizer
  72136. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72137. * @returns true if everything that can be done was applied
  72138. */
  72139. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72140. }
  72141. /**
  72142. * Defines a list of options used by SceneOptimizer
  72143. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72144. */
  72145. export class SceneOptimizerOptions {
  72146. /**
  72147. * Defines the target frame rate to reach (60 by default)
  72148. */
  72149. targetFrameRate: number;
  72150. /**
  72151. * Defines the interval between two checkes (2000ms by default)
  72152. */
  72153. trackerDuration: number;
  72154. /**
  72155. * Gets the list of optimizations to apply
  72156. */
  72157. optimizations: SceneOptimization[];
  72158. /**
  72159. * Creates a new list of options used by SceneOptimizer
  72160. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72161. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72162. */
  72163. constructor(
  72164. /**
  72165. * Defines the target frame rate to reach (60 by default)
  72166. */
  72167. targetFrameRate?: number,
  72168. /**
  72169. * Defines the interval between two checkes (2000ms by default)
  72170. */
  72171. trackerDuration?: number);
  72172. /**
  72173. * Add a new optimization
  72174. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72175. * @returns the current SceneOptimizerOptions
  72176. */
  72177. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72178. /**
  72179. * Add a new custom optimization
  72180. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72181. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72182. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72183. * @returns the current SceneOptimizerOptions
  72184. */
  72185. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72186. /**
  72187. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72188. * @param targetFrameRate defines the target frame rate (60 by default)
  72189. * @returns a SceneOptimizerOptions object
  72190. */
  72191. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72192. /**
  72193. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72194. * @param targetFrameRate defines the target frame rate (60 by default)
  72195. * @returns a SceneOptimizerOptions object
  72196. */
  72197. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72198. /**
  72199. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72200. * @param targetFrameRate defines the target frame rate (60 by default)
  72201. * @returns a SceneOptimizerOptions object
  72202. */
  72203. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72204. }
  72205. /**
  72206. * Class used to run optimizations in order to reach a target frame rate
  72207. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72208. */
  72209. export class SceneOptimizer implements IDisposable {
  72210. private _isRunning;
  72211. private _options;
  72212. private _scene;
  72213. private _currentPriorityLevel;
  72214. private _targetFrameRate;
  72215. private _trackerDuration;
  72216. private _currentFrameRate;
  72217. private _sceneDisposeObserver;
  72218. private _improvementMode;
  72219. /**
  72220. * Defines an observable called when the optimizer reaches the target frame rate
  72221. */
  72222. onSuccessObservable: Observable<SceneOptimizer>;
  72223. /**
  72224. * Defines an observable called when the optimizer enables an optimization
  72225. */
  72226. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72227. /**
  72228. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72229. */
  72230. onFailureObservable: Observable<SceneOptimizer>;
  72231. /**
  72232. * Gets a boolean indicating if the optimizer is in improvement mode
  72233. */
  72234. get isInImprovementMode(): boolean;
  72235. /**
  72236. * Gets the current priority level (0 at start)
  72237. */
  72238. get currentPriorityLevel(): number;
  72239. /**
  72240. * Gets the current frame rate checked by the SceneOptimizer
  72241. */
  72242. get currentFrameRate(): number;
  72243. /**
  72244. * Gets or sets the current target frame rate (60 by default)
  72245. */
  72246. get targetFrameRate(): number;
  72247. /**
  72248. * Gets or sets the current target frame rate (60 by default)
  72249. */
  72250. set targetFrameRate(value: number);
  72251. /**
  72252. * Gets or sets the current interval between two checks (every 2000ms by default)
  72253. */
  72254. get trackerDuration(): number;
  72255. /**
  72256. * Gets or sets the current interval between two checks (every 2000ms by default)
  72257. */
  72258. set trackerDuration(value: number);
  72259. /**
  72260. * Gets the list of active optimizations
  72261. */
  72262. get optimizations(): SceneOptimization[];
  72263. /**
  72264. * Creates a new SceneOptimizer
  72265. * @param scene defines the scene to work on
  72266. * @param options defines the options to use with the SceneOptimizer
  72267. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72268. * @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)
  72269. */
  72270. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72271. /**
  72272. * Stops the current optimizer
  72273. */
  72274. stop(): void;
  72275. /**
  72276. * Reset the optimizer to initial step (current priority level = 0)
  72277. */
  72278. reset(): void;
  72279. /**
  72280. * Start the optimizer. By default it will try to reach a specific framerate
  72281. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72282. */
  72283. start(): void;
  72284. private _checkCurrentState;
  72285. /**
  72286. * Release all resources
  72287. */
  72288. dispose(): void;
  72289. /**
  72290. * Helper function to create a SceneOptimizer with one single line of code
  72291. * @param scene defines the scene to work on
  72292. * @param options defines the options to use with the SceneOptimizer
  72293. * @param onSuccess defines a callback to call on success
  72294. * @param onFailure defines a callback to call on failure
  72295. * @returns the new SceneOptimizer object
  72296. */
  72297. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72298. }
  72299. }
  72300. declare module BABYLON {
  72301. /**
  72302. * Class used to serialize a scene into a string
  72303. */
  72304. export class SceneSerializer {
  72305. /**
  72306. * Clear cache used by a previous serialization
  72307. */
  72308. static ClearCache(): void;
  72309. /**
  72310. * Serialize a scene into a JSON compatible object
  72311. * @param scene defines the scene to serialize
  72312. * @returns a JSON compatible object
  72313. */
  72314. static Serialize(scene: Scene): any;
  72315. /**
  72316. * Serialize a mesh into a JSON compatible object
  72317. * @param toSerialize defines the mesh to serialize
  72318. * @param withParents defines if parents must be serialized as well
  72319. * @param withChildren defines if children must be serialized as well
  72320. * @returns a JSON compatible object
  72321. */
  72322. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72323. }
  72324. }
  72325. declare module BABYLON {
  72326. /**
  72327. * Class used to host texture specific utilities
  72328. */
  72329. export class TextureTools {
  72330. /**
  72331. * Uses the GPU to create a copy texture rescaled at a given size
  72332. * @param texture Texture to copy from
  72333. * @param width defines the desired width
  72334. * @param height defines the desired height
  72335. * @param useBilinearMode defines if bilinear mode has to be used
  72336. * @return the generated texture
  72337. */
  72338. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72339. }
  72340. }
  72341. declare module BABYLON {
  72342. /**
  72343. * This represents the different options available for the video capture.
  72344. */
  72345. export interface VideoRecorderOptions {
  72346. /** Defines the mime type of the video. */
  72347. mimeType: string;
  72348. /** Defines the FPS the video should be recorded at. */
  72349. fps: number;
  72350. /** Defines the chunk size for the recording data. */
  72351. recordChunckSize: number;
  72352. /** The audio tracks to attach to the recording. */
  72353. audioTracks?: MediaStreamTrack[];
  72354. }
  72355. /**
  72356. * This can help with recording videos from BabylonJS.
  72357. * This is based on the available WebRTC functionalities of the browser.
  72358. *
  72359. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72360. */
  72361. export class VideoRecorder {
  72362. private static readonly _defaultOptions;
  72363. /**
  72364. * Returns whether or not the VideoRecorder is available in your browser.
  72365. * @param engine Defines the Babylon Engine.
  72366. * @returns true if supported otherwise false.
  72367. */
  72368. static IsSupported(engine: Engine): boolean;
  72369. private readonly _options;
  72370. private _canvas;
  72371. private _mediaRecorder;
  72372. private _recordedChunks;
  72373. private _fileName;
  72374. private _resolve;
  72375. private _reject;
  72376. /**
  72377. * True when a recording is already in progress.
  72378. */
  72379. get isRecording(): boolean;
  72380. /**
  72381. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72382. * @param engine Defines the BabylonJS Engine you wish to record.
  72383. * @param options Defines options that can be used to customize the capture.
  72384. */
  72385. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72386. /**
  72387. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72388. */
  72389. stopRecording(): void;
  72390. /**
  72391. * Starts recording the canvas for a max duration specified in parameters.
  72392. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72393. * If null no automatic download will start and you can rely on the promise to get the data back.
  72394. * @param maxDuration Defines the maximum recording time in seconds.
  72395. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72396. * @return A promise callback at the end of the recording with the video data in Blob.
  72397. */
  72398. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72399. /**
  72400. * Releases internal resources used during the recording.
  72401. */
  72402. dispose(): void;
  72403. private _handleDataAvailable;
  72404. private _handleError;
  72405. private _handleStop;
  72406. }
  72407. }
  72408. declare module BABYLON {
  72409. /**
  72410. * Class containing a set of static utilities functions for screenshots
  72411. */
  72412. export class ScreenshotTools {
  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 successCallback defines the callback receives a single parameter which contains the
  72424. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72425. * src parameter of an <img> to display it
  72426. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72427. * Check your browser for supported MIME types
  72428. */
  72429. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72430. /**
  72431. * Captures a screenshot of the current rendering
  72432. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72433. * @param engine defines the rendering engine
  72434. * @param camera defines the source camera
  72435. * @param size This parameter can be set to a single number or to an object with the
  72436. * following (optional) properties: precision, width, height. If a single number is passed,
  72437. * it will be used for both width and height. If an object is passed, the screenshot size
  72438. * will be derived from the parameters. The precision property is a multiplier allowing
  72439. * rendering at a higher or lower resolution
  72440. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72441. * Check your browser for supported MIME types
  72442. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72443. * to the src parameter of an <img> to display it
  72444. */
  72445. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72446. /**
  72447. * Generates an image screenshot from the specified camera.
  72448. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72449. * @param engine The engine to use for rendering
  72450. * @param camera The camera to use for rendering
  72451. * @param size This parameter can be set to a single number or to an object with the
  72452. * following (optional) properties: precision, width, height. If a single number is passed,
  72453. * it will be used for both width and height. If an object is passed, the screenshot size
  72454. * will be derived from the parameters. The precision property is a multiplier allowing
  72455. * rendering at a higher or lower resolution
  72456. * @param successCallback The callback receives a single parameter which contains the
  72457. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72458. * src parameter of an <img> to display it
  72459. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72460. * Check your browser for supported MIME types
  72461. * @param samples Texture samples (default: 1)
  72462. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72463. * @param fileName A name for for the downloaded file.
  72464. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72465. */
  72466. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72467. /**
  72468. * Generates an image screenshot from the specified camera.
  72469. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72470. * @param engine The engine to use for rendering
  72471. * @param camera The camera to use for rendering
  72472. * @param size This parameter can be set to a single number or to an object with the
  72473. * following (optional) properties: precision, width, height. If a single number is passed,
  72474. * it will be used for both width and height. If an object is passed, the screenshot size
  72475. * will be derived from the parameters. The precision property is a multiplier allowing
  72476. * rendering at a higher or lower resolution
  72477. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72478. * Check your browser for supported MIME types
  72479. * @param samples Texture samples (default: 1)
  72480. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72481. * @param fileName A name for for the downloaded file.
  72482. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72483. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72484. * to the src parameter of an <img> to display it
  72485. */
  72486. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72487. /**
  72488. * Gets height and width for screenshot size
  72489. * @private
  72490. */
  72491. private static _getScreenshotSize;
  72492. }
  72493. }
  72494. declare module BABYLON {
  72495. /**
  72496. * Interface for a data buffer
  72497. */
  72498. export interface IDataBuffer {
  72499. /**
  72500. * Reads bytes from the data buffer.
  72501. * @param byteOffset The byte offset to read
  72502. * @param byteLength The byte length to read
  72503. * @returns A promise that resolves when the bytes are read
  72504. */
  72505. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72506. /**
  72507. * The byte length of the buffer.
  72508. */
  72509. readonly byteLength: number;
  72510. }
  72511. /**
  72512. * Utility class for reading from a data buffer
  72513. */
  72514. export class DataReader {
  72515. /**
  72516. * The data buffer associated with this data reader.
  72517. */
  72518. readonly buffer: IDataBuffer;
  72519. /**
  72520. * The current byte offset from the beginning of the data buffer.
  72521. */
  72522. byteOffset: number;
  72523. private _dataView;
  72524. private _dataByteOffset;
  72525. /**
  72526. * Constructor
  72527. * @param buffer The buffer to read
  72528. */
  72529. constructor(buffer: IDataBuffer);
  72530. /**
  72531. * Loads the given byte length.
  72532. * @param byteLength The byte length to load
  72533. * @returns A promise that resolves when the load is complete
  72534. */
  72535. loadAsync(byteLength: number): Promise<void>;
  72536. /**
  72537. * Read a unsigned 32-bit integer from the currently loaded data range.
  72538. * @returns The 32-bit integer read
  72539. */
  72540. readUint32(): number;
  72541. /**
  72542. * Read a byte array from the currently loaded data range.
  72543. * @param byteLength The byte length to read
  72544. * @returns The byte array read
  72545. */
  72546. readUint8Array(byteLength: number): Uint8Array;
  72547. /**
  72548. * Read a string from the currently loaded data range.
  72549. * @param byteLength The byte length to read
  72550. * @returns The string read
  72551. */
  72552. readString(byteLength: number): string;
  72553. /**
  72554. * Skips the given byte length the currently loaded data range.
  72555. * @param byteLength The byte length to skip
  72556. */
  72557. skipBytes(byteLength: number): void;
  72558. }
  72559. }
  72560. declare module BABYLON {
  72561. /**
  72562. * Class for storing data to local storage if available or in-memory storage otherwise
  72563. */
  72564. export class DataStorage {
  72565. private static _Storage;
  72566. private static _GetStorage;
  72567. /**
  72568. * Reads a string from the data storage
  72569. * @param key The key to read
  72570. * @param defaultValue The value if the key doesn't exist
  72571. * @returns The string value
  72572. */
  72573. static ReadString(key: string, defaultValue: string): string;
  72574. /**
  72575. * Writes a string to the data storage
  72576. * @param key The key to write
  72577. * @param value The value to write
  72578. */
  72579. static WriteString(key: string, value: string): void;
  72580. /**
  72581. * Reads a boolean from the data storage
  72582. * @param key The key to read
  72583. * @param defaultValue The value if the key doesn't exist
  72584. * @returns The boolean value
  72585. */
  72586. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72587. /**
  72588. * Writes a boolean to the data storage
  72589. * @param key The key to write
  72590. * @param value The value to write
  72591. */
  72592. static WriteBoolean(key: string, value: boolean): void;
  72593. /**
  72594. * Reads a number from the data storage
  72595. * @param key The key to read
  72596. * @param defaultValue The value if the key doesn't exist
  72597. * @returns The number value
  72598. */
  72599. static ReadNumber(key: string, defaultValue: number): number;
  72600. /**
  72601. * Writes a number to the data storage
  72602. * @param key The key to write
  72603. * @param value The value to write
  72604. */
  72605. static WriteNumber(key: string, value: number): void;
  72606. }
  72607. }
  72608. declare module BABYLON {
  72609. /**
  72610. * An interface for all Hit test features
  72611. */
  72612. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72613. /**
  72614. * Triggered when new babylon (transformed) hit test results are available
  72615. */
  72616. onHitTestResultObservable: Observable<T[]>;
  72617. }
  72618. /**
  72619. * Options used for hit testing
  72620. */
  72621. export interface IWebXRLegacyHitTestOptions {
  72622. /**
  72623. * Only test when user interacted with the scene. Default - hit test every frame
  72624. */
  72625. testOnPointerDownOnly?: boolean;
  72626. /**
  72627. * The node to use to transform the local results to world coordinates
  72628. */
  72629. worldParentNode?: TransformNode;
  72630. }
  72631. /**
  72632. * Interface defining the babylon result of raycasting/hit-test
  72633. */
  72634. export interface IWebXRLegacyHitResult {
  72635. /**
  72636. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72637. */
  72638. transformationMatrix: Matrix;
  72639. /**
  72640. * The native hit test result
  72641. */
  72642. xrHitResult: XRHitResult | XRHitTestResult;
  72643. }
  72644. /**
  72645. * The currently-working hit-test module.
  72646. * Hit test (or Ray-casting) is used to interact with the real world.
  72647. * For further information read here - https://github.com/immersive-web/hit-test
  72648. */
  72649. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72650. /**
  72651. * options to use when constructing this feature
  72652. */
  72653. readonly options: IWebXRLegacyHitTestOptions;
  72654. private _direction;
  72655. private _mat;
  72656. private _onSelectEnabled;
  72657. private _origin;
  72658. /**
  72659. * The module's name
  72660. */
  72661. static readonly Name: string;
  72662. /**
  72663. * The (Babylon) version of this module.
  72664. * This is an integer representing the implementation version.
  72665. * This number does not correspond to the WebXR specs version
  72666. */
  72667. static readonly Version: number;
  72668. /**
  72669. * Populated with the last native XR Hit Results
  72670. */
  72671. lastNativeXRHitResults: XRHitResult[];
  72672. /**
  72673. * Triggered when new babylon (transformed) hit test results are available
  72674. */
  72675. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72676. /**
  72677. * Creates a new instance of the (legacy version) hit test feature
  72678. * @param _xrSessionManager an instance of WebXRSessionManager
  72679. * @param options options to use when constructing this feature
  72680. */
  72681. constructor(_xrSessionManager: WebXRSessionManager,
  72682. /**
  72683. * options to use when constructing this feature
  72684. */
  72685. options?: IWebXRLegacyHitTestOptions);
  72686. /**
  72687. * execute a hit test with an XR Ray
  72688. *
  72689. * @param xrSession a native xrSession that will execute this hit test
  72690. * @param xrRay the ray (position and direction) to use for ray-casting
  72691. * @param referenceSpace native XR reference space to use for the hit-test
  72692. * @param filter filter function that will filter the results
  72693. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72694. */
  72695. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72696. /**
  72697. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72698. * @param event the (select) event to use to select with
  72699. * @param referenceSpace the reference space to use for this hit test
  72700. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72701. */
  72702. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72703. /**
  72704. * attach this feature
  72705. * Will usually be called by the features manager
  72706. *
  72707. * @returns true if successful.
  72708. */
  72709. attach(): boolean;
  72710. /**
  72711. * detach this feature.
  72712. * Will usually be called by the features manager
  72713. *
  72714. * @returns true if successful.
  72715. */
  72716. detach(): boolean;
  72717. /**
  72718. * Dispose this feature and all of the resources attached
  72719. */
  72720. dispose(): void;
  72721. protected _onXRFrame(frame: XRFrame): void;
  72722. private _onHitTestResults;
  72723. private _onSelect;
  72724. }
  72725. }
  72726. declare module BABYLON {
  72727. /**
  72728. * Options used for hit testing (version 2)
  72729. */
  72730. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72731. /**
  72732. * Do not create a permanent hit test. Will usually be used when only
  72733. * transient inputs are needed.
  72734. */
  72735. disablePermanentHitTest?: boolean;
  72736. /**
  72737. * Enable transient (for example touch-based) hit test inspections
  72738. */
  72739. enableTransientHitTest?: boolean;
  72740. /**
  72741. * Offset ray for the permanent hit test
  72742. */
  72743. offsetRay?: Vector3;
  72744. /**
  72745. * Offset ray for the transient hit test
  72746. */
  72747. transientOffsetRay?: Vector3;
  72748. /**
  72749. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72750. */
  72751. useReferenceSpace?: boolean;
  72752. }
  72753. /**
  72754. * Interface defining the babylon result of hit-test
  72755. */
  72756. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72757. /**
  72758. * The input source that generated this hit test (if transient)
  72759. */
  72760. inputSource?: XRInputSource;
  72761. /**
  72762. * Is this a transient hit test
  72763. */
  72764. isTransient?: boolean;
  72765. /**
  72766. * Position of the hit test result
  72767. */
  72768. position: Vector3;
  72769. /**
  72770. * Rotation of the hit test result
  72771. */
  72772. rotationQuaternion: Quaternion;
  72773. /**
  72774. * The native hit test result
  72775. */
  72776. xrHitResult: XRHitTestResult;
  72777. }
  72778. /**
  72779. * The currently-working hit-test module.
  72780. * Hit test (or Ray-casting) is used to interact with the real world.
  72781. * For further information read here - https://github.com/immersive-web/hit-test
  72782. *
  72783. * Tested on chrome (mobile) 80.
  72784. */
  72785. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72786. /**
  72787. * options to use when constructing this feature
  72788. */
  72789. readonly options: IWebXRHitTestOptions;
  72790. private _tmpMat;
  72791. private _tmpPos;
  72792. private _tmpQuat;
  72793. private _transientXrHitTestSource;
  72794. private _xrHitTestSource;
  72795. private initHitTestSource;
  72796. /**
  72797. * The module's name
  72798. */
  72799. static readonly Name: string;
  72800. /**
  72801. * The (Babylon) version of this module.
  72802. * This is an integer representing the implementation version.
  72803. * This number does not correspond to the WebXR specs version
  72804. */
  72805. static readonly Version: number;
  72806. /**
  72807. * When set to true, each hit test will have its own position/rotation objects
  72808. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72809. * the developers will clone them or copy them as they see fit.
  72810. */
  72811. autoCloneTransformation: boolean;
  72812. /**
  72813. * Triggered when new babylon (transformed) hit test results are available
  72814. */
  72815. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72816. /**
  72817. * Use this to temporarily pause hit test checks.
  72818. */
  72819. paused: boolean;
  72820. /**
  72821. * Creates a new instance of the hit test feature
  72822. * @param _xrSessionManager an instance of WebXRSessionManager
  72823. * @param options options to use when constructing this feature
  72824. */
  72825. constructor(_xrSessionManager: WebXRSessionManager,
  72826. /**
  72827. * options to use when constructing this feature
  72828. */
  72829. options?: IWebXRHitTestOptions);
  72830. /**
  72831. * attach this feature
  72832. * Will usually be called by the features manager
  72833. *
  72834. * @returns true if successful.
  72835. */
  72836. attach(): boolean;
  72837. /**
  72838. * detach this feature.
  72839. * Will usually be called by the features manager
  72840. *
  72841. * @returns true if successful.
  72842. */
  72843. detach(): boolean;
  72844. /**
  72845. * Dispose this feature and all of the resources attached
  72846. */
  72847. dispose(): void;
  72848. protected _onXRFrame(frame: XRFrame): void;
  72849. private _processWebXRHitTestResult;
  72850. }
  72851. }
  72852. declare module BABYLON {
  72853. /**
  72854. * Configuration options of the anchor system
  72855. */
  72856. export interface IWebXRAnchorSystemOptions {
  72857. /**
  72858. * a node that will be used to convert local to world coordinates
  72859. */
  72860. worldParentNode?: TransformNode;
  72861. /**
  72862. * If set to true a reference of the created anchors will be kept until the next session starts
  72863. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72864. */
  72865. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72866. }
  72867. /**
  72868. * A babylon container for an XR Anchor
  72869. */
  72870. export interface IWebXRAnchor {
  72871. /**
  72872. * A babylon-assigned ID for this anchor
  72873. */
  72874. id: number;
  72875. /**
  72876. * Transformation matrix to apply to an object attached to this anchor
  72877. */
  72878. transformationMatrix: Matrix;
  72879. /**
  72880. * The native anchor object
  72881. */
  72882. xrAnchor: XRAnchor;
  72883. /**
  72884. * if defined, this object will be constantly updated by the anchor's position and rotation
  72885. */
  72886. attachedNode?: TransformNode;
  72887. }
  72888. /**
  72889. * An implementation of the anchor system for WebXR.
  72890. * For further information see https://github.com/immersive-web/anchors/
  72891. */
  72892. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72893. private _options;
  72894. private _lastFrameDetected;
  72895. private _trackedAnchors;
  72896. private _referenceSpaceForFrameAnchors;
  72897. private _futureAnchors;
  72898. /**
  72899. * The module's name
  72900. */
  72901. static readonly Name: string;
  72902. /**
  72903. * The (Babylon) version of this module.
  72904. * This is an integer representing the implementation version.
  72905. * This number does not correspond to the WebXR specs version
  72906. */
  72907. static readonly Version: number;
  72908. /**
  72909. * Observers registered here will be executed when a new anchor was added to the session
  72910. */
  72911. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72912. /**
  72913. * Observers registered here will be executed when an anchor was removed from the session
  72914. */
  72915. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72916. /**
  72917. * Observers registered here will be executed when an existing anchor updates
  72918. * This can execute N times every frame
  72919. */
  72920. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72921. /**
  72922. * Set the reference space to use for anchor creation, when not using a hit test.
  72923. * Will default to the session's reference space if not defined
  72924. */
  72925. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72926. /**
  72927. * constructs a new anchor system
  72928. * @param _xrSessionManager an instance of WebXRSessionManager
  72929. * @param _options configuration object for this feature
  72930. */
  72931. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72932. private _tmpVector;
  72933. private _tmpQuaternion;
  72934. private _populateTmpTransformation;
  72935. /**
  72936. * Create a new anchor point using a hit test result at a specific point in the scene
  72937. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72938. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72939. *
  72940. * @param hitTestResult The hit test result to use for this anchor creation
  72941. * @param position an optional position offset for this anchor
  72942. * @param rotationQuaternion an optional rotation offset for this anchor
  72943. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72944. */
  72945. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72946. /**
  72947. * Add a new anchor at a specific position and rotation
  72948. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72949. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72950. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72951. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72952. *
  72953. * @param position the position in which to add an anchor
  72954. * @param rotationQuaternion an optional rotation for the anchor transformation
  72955. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72956. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72957. */
  72958. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72959. /**
  72960. * detach this feature.
  72961. * Will usually be called by the features manager
  72962. *
  72963. * @returns true if successful.
  72964. */
  72965. detach(): boolean;
  72966. /**
  72967. * Dispose this feature and all of the resources attached
  72968. */
  72969. dispose(): void;
  72970. protected _onXRFrame(frame: XRFrame): void;
  72971. /**
  72972. * avoiding using Array.find for global support.
  72973. * @param xrAnchor the plane to find in the array
  72974. */
  72975. private _findIndexInAnchorArray;
  72976. private _updateAnchorWithXRFrame;
  72977. private _createAnchorAtTransformation;
  72978. }
  72979. }
  72980. declare module BABYLON {
  72981. /**
  72982. * Options used in the plane detector module
  72983. */
  72984. export interface IWebXRPlaneDetectorOptions {
  72985. /**
  72986. * The node to use to transform the local results to world coordinates
  72987. */
  72988. worldParentNode?: TransformNode;
  72989. /**
  72990. * If set to true a reference of the created planes will be kept until the next session starts
  72991. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72992. */
  72993. doNotRemovePlanesOnSessionEnded?: boolean;
  72994. }
  72995. /**
  72996. * A babylon interface for a WebXR plane.
  72997. * A Plane is actually a polygon, built from N points in space
  72998. *
  72999. * Supported in chrome 79, not supported in canary 81 ATM
  73000. */
  73001. export interface IWebXRPlane {
  73002. /**
  73003. * a babylon-assigned ID for this polygon
  73004. */
  73005. id: number;
  73006. /**
  73007. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73008. */
  73009. polygonDefinition: Array<Vector3>;
  73010. /**
  73011. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73012. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73013. */
  73014. transformationMatrix: Matrix;
  73015. /**
  73016. * the native xr-plane object
  73017. */
  73018. xrPlane: XRPlane;
  73019. }
  73020. /**
  73021. * The plane detector is used to detect planes in the real world when in AR
  73022. * For more information see https://github.com/immersive-web/real-world-geometry/
  73023. */
  73024. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73025. private _options;
  73026. private _detectedPlanes;
  73027. private _enabled;
  73028. private _lastFrameDetected;
  73029. /**
  73030. * The module's name
  73031. */
  73032. static readonly Name: string;
  73033. /**
  73034. * The (Babylon) version of this module.
  73035. * This is an integer representing the implementation version.
  73036. * This number does not correspond to the WebXR specs version
  73037. */
  73038. static readonly Version: number;
  73039. /**
  73040. * Observers registered here will be executed when a new plane was added to the session
  73041. */
  73042. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73043. /**
  73044. * Observers registered here will be executed when a plane is no longer detected in the session
  73045. */
  73046. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73047. /**
  73048. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73049. * This can execute N times every frame
  73050. */
  73051. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73052. /**
  73053. * construct a new Plane Detector
  73054. * @param _xrSessionManager an instance of xr Session manager
  73055. * @param _options configuration to use when constructing this feature
  73056. */
  73057. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73058. /**
  73059. * detach this feature.
  73060. * Will usually be called by the features manager
  73061. *
  73062. * @returns true if successful.
  73063. */
  73064. detach(): boolean;
  73065. /**
  73066. * Dispose this feature and all of the resources attached
  73067. */
  73068. dispose(): void;
  73069. protected _onXRFrame(frame: XRFrame): void;
  73070. private _init;
  73071. private _updatePlaneWithXRPlane;
  73072. /**
  73073. * avoiding using Array.find for global support.
  73074. * @param xrPlane the plane to find in the array
  73075. */
  73076. private findIndexInPlaneArray;
  73077. }
  73078. }
  73079. declare module BABYLON {
  73080. /**
  73081. * Options interface for the background remover plugin
  73082. */
  73083. export interface IWebXRBackgroundRemoverOptions {
  73084. /**
  73085. * Further background meshes to disable when entering AR
  73086. */
  73087. backgroundMeshes?: AbstractMesh[];
  73088. /**
  73089. * flags to configure the removal of the environment helper.
  73090. * If not set, the entire background will be removed. If set, flags should be set as well.
  73091. */
  73092. environmentHelperRemovalFlags?: {
  73093. /**
  73094. * Should the skybox be removed (default false)
  73095. */
  73096. skyBox?: boolean;
  73097. /**
  73098. * Should the ground be removed (default false)
  73099. */
  73100. ground?: boolean;
  73101. };
  73102. /**
  73103. * don't disable the environment helper
  73104. */
  73105. ignoreEnvironmentHelper?: boolean;
  73106. }
  73107. /**
  73108. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73109. */
  73110. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73111. /**
  73112. * read-only options to be used in this module
  73113. */
  73114. readonly options: IWebXRBackgroundRemoverOptions;
  73115. /**
  73116. * The module's name
  73117. */
  73118. static readonly Name: string;
  73119. /**
  73120. * The (Babylon) version of this module.
  73121. * This is an integer representing the implementation version.
  73122. * This number does not correspond to the WebXR specs version
  73123. */
  73124. static readonly Version: number;
  73125. /**
  73126. * registered observers will be triggered when the background state changes
  73127. */
  73128. onBackgroundStateChangedObservable: Observable<boolean>;
  73129. /**
  73130. * constructs a new background remover module
  73131. * @param _xrSessionManager the session manager for this module
  73132. * @param options read-only options to be used in this module
  73133. */
  73134. constructor(_xrSessionManager: WebXRSessionManager,
  73135. /**
  73136. * read-only options to be used in this module
  73137. */
  73138. options?: IWebXRBackgroundRemoverOptions);
  73139. /**
  73140. * attach this feature
  73141. * Will usually be called by the features manager
  73142. *
  73143. * @returns true if successful.
  73144. */
  73145. attach(): boolean;
  73146. /**
  73147. * detach this feature.
  73148. * Will usually be called by the features manager
  73149. *
  73150. * @returns true if successful.
  73151. */
  73152. detach(): boolean;
  73153. /**
  73154. * Dispose this feature and all of the resources attached
  73155. */
  73156. dispose(): void;
  73157. protected _onXRFrame(_xrFrame: XRFrame): void;
  73158. private _setBackgroundState;
  73159. }
  73160. }
  73161. declare module BABYLON {
  73162. /**
  73163. * Options for the controller physics feature
  73164. */
  73165. export class IWebXRControllerPhysicsOptions {
  73166. /**
  73167. * Should the headset get its own impostor
  73168. */
  73169. enableHeadsetImpostor?: boolean;
  73170. /**
  73171. * Optional parameters for the headset impostor
  73172. */
  73173. headsetImpostorParams?: {
  73174. /**
  73175. * The type of impostor to create. Default is sphere
  73176. */
  73177. impostorType: number;
  73178. /**
  73179. * the size of the impostor. Defaults to 10cm
  73180. */
  73181. impostorSize?: number | {
  73182. width: number;
  73183. height: number;
  73184. depth: number;
  73185. };
  73186. /**
  73187. * Friction definitions
  73188. */
  73189. friction?: number;
  73190. /**
  73191. * Restitution
  73192. */
  73193. restitution?: number;
  73194. };
  73195. /**
  73196. * The physics properties of the future impostors
  73197. */
  73198. physicsProperties?: {
  73199. /**
  73200. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73201. * Note that this requires a physics engine that supports mesh impostors!
  73202. */
  73203. useControllerMesh?: boolean;
  73204. /**
  73205. * The type of impostor to create. Default is sphere
  73206. */
  73207. impostorType?: number;
  73208. /**
  73209. * the size of the impostor. Defaults to 10cm
  73210. */
  73211. impostorSize?: number | {
  73212. width: number;
  73213. height: number;
  73214. depth: number;
  73215. };
  73216. /**
  73217. * Friction definitions
  73218. */
  73219. friction?: number;
  73220. /**
  73221. * Restitution
  73222. */
  73223. restitution?: number;
  73224. };
  73225. /**
  73226. * the xr input to use with this pointer selection
  73227. */
  73228. xrInput: WebXRInput;
  73229. }
  73230. /**
  73231. * Add physics impostor to your webxr controllers,
  73232. * including naive calculation of their linear and angular velocity
  73233. */
  73234. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73235. private readonly _options;
  73236. private _attachController;
  73237. private _controllers;
  73238. private _debugMode;
  73239. private _delta;
  73240. private _headsetImpostor?;
  73241. private _headsetMesh?;
  73242. private _lastTimestamp;
  73243. private _tmpQuaternion;
  73244. private _tmpVector;
  73245. /**
  73246. * The module's name
  73247. */
  73248. static readonly Name: string;
  73249. /**
  73250. * The (Babylon) version of this module.
  73251. * This is an integer representing the implementation version.
  73252. * This number does not correspond to the webxr specs version
  73253. */
  73254. static readonly Version: number;
  73255. /**
  73256. * Construct a new Controller Physics Feature
  73257. * @param _xrSessionManager the corresponding xr session manager
  73258. * @param _options options to create this feature with
  73259. */
  73260. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73261. /**
  73262. * @hidden
  73263. * enable debugging - will show console outputs and the impostor mesh
  73264. */
  73265. _enablePhysicsDebug(): void;
  73266. /**
  73267. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73268. * @param xrController the controller to add
  73269. */
  73270. addController(xrController: WebXRInputSource): void;
  73271. /**
  73272. * attach this feature
  73273. * Will usually be called by the features manager
  73274. *
  73275. * @returns true if successful.
  73276. */
  73277. attach(): boolean;
  73278. /**
  73279. * detach this feature.
  73280. * Will usually be called by the features manager
  73281. *
  73282. * @returns true if successful.
  73283. */
  73284. detach(): boolean;
  73285. /**
  73286. * Get the headset impostor, if enabled
  73287. * @returns the impostor
  73288. */
  73289. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73290. /**
  73291. * Get the physics impostor of a specific controller.
  73292. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73293. * @param controller the controller or the controller id of which to get the impostor
  73294. * @returns the impostor or null
  73295. */
  73296. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73297. /**
  73298. * Update the physics properties provided in the constructor
  73299. * @param newProperties the new properties object
  73300. */
  73301. setPhysicsProperties(newProperties: {
  73302. impostorType?: number;
  73303. impostorSize?: number | {
  73304. width: number;
  73305. height: number;
  73306. depth: number;
  73307. };
  73308. friction?: number;
  73309. restitution?: number;
  73310. }): void;
  73311. protected _onXRFrame(_xrFrame: any): void;
  73312. private _detachController;
  73313. }
  73314. }
  73315. declare module BABYLON {
  73316. /**
  73317. * The motion controller class for all microsoft mixed reality controllers
  73318. */
  73319. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73320. protected readonly _mapping: {
  73321. defaultButton: {
  73322. valueNodeName: string;
  73323. unpressedNodeName: string;
  73324. pressedNodeName: string;
  73325. };
  73326. defaultAxis: {
  73327. valueNodeName: string;
  73328. minNodeName: string;
  73329. maxNodeName: string;
  73330. };
  73331. buttons: {
  73332. "xr-standard-trigger": {
  73333. rootNodeName: string;
  73334. componentProperty: string;
  73335. states: string[];
  73336. };
  73337. "xr-standard-squeeze": {
  73338. rootNodeName: string;
  73339. componentProperty: string;
  73340. states: string[];
  73341. };
  73342. "xr-standard-touchpad": {
  73343. rootNodeName: string;
  73344. labelAnchorNodeName: string;
  73345. touchPointNodeName: string;
  73346. };
  73347. "xr-standard-thumbstick": {
  73348. rootNodeName: string;
  73349. componentProperty: string;
  73350. states: string[];
  73351. };
  73352. };
  73353. axes: {
  73354. "xr-standard-touchpad": {
  73355. "x-axis": {
  73356. rootNodeName: string;
  73357. };
  73358. "y-axis": {
  73359. rootNodeName: string;
  73360. };
  73361. };
  73362. "xr-standard-thumbstick": {
  73363. "x-axis": {
  73364. rootNodeName: string;
  73365. };
  73366. "y-axis": {
  73367. rootNodeName: string;
  73368. };
  73369. };
  73370. };
  73371. };
  73372. /**
  73373. * The base url used to load the left and right controller models
  73374. */
  73375. static MODEL_BASE_URL: string;
  73376. /**
  73377. * The name of the left controller model file
  73378. */
  73379. static MODEL_LEFT_FILENAME: string;
  73380. /**
  73381. * The name of the right controller model file
  73382. */
  73383. static MODEL_RIGHT_FILENAME: string;
  73384. profileId: string;
  73385. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73386. protected _getFilenameAndPath(): {
  73387. filename: string;
  73388. path: string;
  73389. };
  73390. protected _getModelLoadingConstraints(): boolean;
  73391. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73392. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73393. protected _updateModel(): void;
  73394. }
  73395. }
  73396. declare module BABYLON {
  73397. /**
  73398. * The motion controller class for oculus touch (quest, rift).
  73399. * This class supports legacy mapping as well the standard xr mapping
  73400. */
  73401. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73402. private _forceLegacyControllers;
  73403. private _modelRootNode;
  73404. /**
  73405. * The base url used to load the left and right controller models
  73406. */
  73407. static MODEL_BASE_URL: string;
  73408. /**
  73409. * The name of the left controller model file
  73410. */
  73411. static MODEL_LEFT_FILENAME: string;
  73412. /**
  73413. * The name of the right controller model file
  73414. */
  73415. static MODEL_RIGHT_FILENAME: string;
  73416. /**
  73417. * Base Url for the Quest controller model.
  73418. */
  73419. static QUEST_MODEL_BASE_URL: string;
  73420. profileId: string;
  73421. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73422. protected _getFilenameAndPath(): {
  73423. filename: string;
  73424. path: string;
  73425. };
  73426. protected _getModelLoadingConstraints(): boolean;
  73427. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73428. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73429. protected _updateModel(): void;
  73430. /**
  73431. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73432. * between the touch and touch 2.
  73433. */
  73434. private _isQuest;
  73435. }
  73436. }
  73437. declare module BABYLON {
  73438. /**
  73439. * The motion controller class for the standard HTC-Vive controllers
  73440. */
  73441. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73442. private _modelRootNode;
  73443. /**
  73444. * The base url used to load the left and right controller models
  73445. */
  73446. static MODEL_BASE_URL: string;
  73447. /**
  73448. * File name for the controller model.
  73449. */
  73450. static MODEL_FILENAME: string;
  73451. profileId: string;
  73452. /**
  73453. * Create a new Vive motion controller object
  73454. * @param scene the scene to use to create this controller
  73455. * @param gamepadObject the corresponding gamepad object
  73456. * @param handedness the handedness of the controller
  73457. */
  73458. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73459. protected _getFilenameAndPath(): {
  73460. filename: string;
  73461. path: string;
  73462. };
  73463. protected _getModelLoadingConstraints(): boolean;
  73464. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73465. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73466. protected _updateModel(): void;
  73467. }
  73468. }
  73469. declare module BABYLON {
  73470. /**
  73471. * A cursor which tracks a point on a path
  73472. */
  73473. export class PathCursor {
  73474. private path;
  73475. /**
  73476. * Stores path cursor callbacks for when an onchange event is triggered
  73477. */
  73478. private _onchange;
  73479. /**
  73480. * The value of the path cursor
  73481. */
  73482. value: number;
  73483. /**
  73484. * The animation array of the path cursor
  73485. */
  73486. animations: Animation[];
  73487. /**
  73488. * Initializes the path cursor
  73489. * @param path The path to track
  73490. */
  73491. constructor(path: Path2);
  73492. /**
  73493. * Gets the cursor point on the path
  73494. * @returns A point on the path cursor at the cursor location
  73495. */
  73496. getPoint(): Vector3;
  73497. /**
  73498. * Moves the cursor ahead by the step amount
  73499. * @param step The amount to move the cursor forward
  73500. * @returns This path cursor
  73501. */
  73502. moveAhead(step?: number): PathCursor;
  73503. /**
  73504. * Moves the cursor behind by the step amount
  73505. * @param step The amount to move the cursor back
  73506. * @returns This path cursor
  73507. */
  73508. moveBack(step?: number): PathCursor;
  73509. /**
  73510. * Moves the cursor by the step amount
  73511. * If the step amount is greater than one, an exception is thrown
  73512. * @param step The amount to move the cursor
  73513. * @returns This path cursor
  73514. */
  73515. move(step: number): PathCursor;
  73516. /**
  73517. * Ensures that the value is limited between zero and one
  73518. * @returns This path cursor
  73519. */
  73520. private ensureLimits;
  73521. /**
  73522. * Runs onchange callbacks on change (used by the animation engine)
  73523. * @returns This path cursor
  73524. */
  73525. private raiseOnChange;
  73526. /**
  73527. * Executes a function on change
  73528. * @param f A path cursor onchange callback
  73529. * @returns This path cursor
  73530. */
  73531. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73532. }
  73533. }
  73534. declare module BABYLON {
  73535. /** @hidden */
  73536. export var blurPixelShader: {
  73537. name: string;
  73538. shader: string;
  73539. };
  73540. }
  73541. declare module BABYLON {
  73542. /** @hidden */
  73543. export var pointCloudVertexDeclaration: {
  73544. name: string;
  73545. shader: string;
  73546. };
  73547. }
  73548. // Mixins
  73549. interface Window {
  73550. mozIndexedDB: IDBFactory;
  73551. webkitIndexedDB: IDBFactory;
  73552. msIndexedDB: IDBFactory;
  73553. webkitURL: typeof URL;
  73554. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73555. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73556. WebGLRenderingContext: WebGLRenderingContext;
  73557. MSGesture: MSGesture;
  73558. CANNON: any;
  73559. AudioContext: AudioContext;
  73560. webkitAudioContext: AudioContext;
  73561. PointerEvent: any;
  73562. Math: Math;
  73563. Uint8Array: Uint8ArrayConstructor;
  73564. Float32Array: Float32ArrayConstructor;
  73565. mozURL: typeof URL;
  73566. msURL: typeof URL;
  73567. VRFrameData: any; // WebVR, from specs 1.1
  73568. DracoDecoderModule: any;
  73569. setImmediate(handler: (...args: any[]) => void): number;
  73570. }
  73571. interface HTMLCanvasElement {
  73572. requestPointerLock(): void;
  73573. msRequestPointerLock?(): void;
  73574. mozRequestPointerLock?(): void;
  73575. webkitRequestPointerLock?(): void;
  73576. /** Track wether a record is in progress */
  73577. isRecording: boolean;
  73578. /** Capture Stream method defined by some browsers */
  73579. captureStream(fps?: number): MediaStream;
  73580. }
  73581. interface CanvasRenderingContext2D {
  73582. msImageSmoothingEnabled: boolean;
  73583. }
  73584. interface MouseEvent {
  73585. mozMovementX: number;
  73586. mozMovementY: number;
  73587. webkitMovementX: number;
  73588. webkitMovementY: number;
  73589. msMovementX: number;
  73590. msMovementY: number;
  73591. }
  73592. interface Navigator {
  73593. mozGetVRDevices: (any: any) => any;
  73594. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73595. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73596. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73597. webkitGetGamepads(): Gamepad[];
  73598. msGetGamepads(): Gamepad[];
  73599. webkitGamepads(): Gamepad[];
  73600. }
  73601. interface HTMLVideoElement {
  73602. mozSrcObject: any;
  73603. }
  73604. interface Math {
  73605. fround(x: number): number;
  73606. imul(a: number, b: number): number;
  73607. }
  73608. interface WebGLRenderingContext {
  73609. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73610. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73611. vertexAttribDivisor(index: number, divisor: number): void;
  73612. createVertexArray(): any;
  73613. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73614. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73615. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73616. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73617. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73618. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73619. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73620. // Queries
  73621. createQuery(): WebGLQuery;
  73622. deleteQuery(query: WebGLQuery): void;
  73623. beginQuery(target: number, query: WebGLQuery): void;
  73624. endQuery(target: number): void;
  73625. getQueryParameter(query: WebGLQuery, pname: number): any;
  73626. getQuery(target: number, pname: number): any;
  73627. MAX_SAMPLES: number;
  73628. RGBA8: number;
  73629. READ_FRAMEBUFFER: number;
  73630. DRAW_FRAMEBUFFER: number;
  73631. UNIFORM_BUFFER: number;
  73632. HALF_FLOAT_OES: number;
  73633. RGBA16F: number;
  73634. RGBA32F: number;
  73635. R32F: number;
  73636. RG32F: number;
  73637. RGB32F: number;
  73638. R16F: number;
  73639. RG16F: number;
  73640. RGB16F: number;
  73641. RED: number;
  73642. RG: number;
  73643. R8: number;
  73644. RG8: number;
  73645. UNSIGNED_INT_24_8: number;
  73646. DEPTH24_STENCIL8: number;
  73647. MIN: number;
  73648. MAX: number;
  73649. /* Multiple Render Targets */
  73650. drawBuffers(buffers: number[]): void;
  73651. readBuffer(src: number): void;
  73652. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73653. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73654. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73655. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73656. // Occlusion Query
  73657. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73658. ANY_SAMPLES_PASSED: number;
  73659. QUERY_RESULT_AVAILABLE: number;
  73660. QUERY_RESULT: number;
  73661. }
  73662. interface WebGLProgram {
  73663. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73664. }
  73665. interface EXT_disjoint_timer_query {
  73666. QUERY_COUNTER_BITS_EXT: number;
  73667. TIME_ELAPSED_EXT: number;
  73668. TIMESTAMP_EXT: number;
  73669. GPU_DISJOINT_EXT: number;
  73670. QUERY_RESULT_EXT: number;
  73671. QUERY_RESULT_AVAILABLE_EXT: number;
  73672. queryCounterEXT(query: WebGLQuery, target: number): void;
  73673. createQueryEXT(): WebGLQuery;
  73674. beginQueryEXT(target: number, query: WebGLQuery): void;
  73675. endQueryEXT(target: number): void;
  73676. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73677. deleteQueryEXT(query: WebGLQuery): void;
  73678. }
  73679. interface WebGLUniformLocation {
  73680. _currentState: any;
  73681. }
  73682. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73683. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73684. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73685. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73686. interface WebGLRenderingContext {
  73687. readonly RASTERIZER_DISCARD: number;
  73688. readonly DEPTH_COMPONENT24: number;
  73689. readonly TEXTURE_3D: number;
  73690. readonly TEXTURE_2D_ARRAY: number;
  73691. readonly TEXTURE_COMPARE_FUNC: number;
  73692. readonly TEXTURE_COMPARE_MODE: number;
  73693. readonly COMPARE_REF_TO_TEXTURE: number;
  73694. readonly TEXTURE_WRAP_R: number;
  73695. readonly HALF_FLOAT: number;
  73696. readonly RGB8: number;
  73697. readonly RED_INTEGER: number;
  73698. readonly RG_INTEGER: number;
  73699. readonly RGB_INTEGER: number;
  73700. readonly RGBA_INTEGER: number;
  73701. readonly R8_SNORM: number;
  73702. readonly RG8_SNORM: number;
  73703. readonly RGB8_SNORM: number;
  73704. readonly RGBA8_SNORM: number;
  73705. readonly R8I: number;
  73706. readonly RG8I: number;
  73707. readonly RGB8I: number;
  73708. readonly RGBA8I: number;
  73709. readonly R8UI: number;
  73710. readonly RG8UI: number;
  73711. readonly RGB8UI: number;
  73712. readonly RGBA8UI: number;
  73713. readonly R16I: number;
  73714. readonly RG16I: number;
  73715. readonly RGB16I: number;
  73716. readonly RGBA16I: number;
  73717. readonly R16UI: number;
  73718. readonly RG16UI: number;
  73719. readonly RGB16UI: number;
  73720. readonly RGBA16UI: number;
  73721. readonly R32I: number;
  73722. readonly RG32I: number;
  73723. readonly RGB32I: number;
  73724. readonly RGBA32I: number;
  73725. readonly R32UI: number;
  73726. readonly RG32UI: number;
  73727. readonly RGB32UI: number;
  73728. readonly RGBA32UI: number;
  73729. readonly RGB10_A2UI: number;
  73730. readonly R11F_G11F_B10F: number;
  73731. readonly RGB9_E5: number;
  73732. readonly RGB10_A2: number;
  73733. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73734. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73735. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73736. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73737. readonly DEPTH_COMPONENT32F: number;
  73738. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73739. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73740. 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;
  73741. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73742. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73743. readonly TRANSFORM_FEEDBACK: number;
  73744. readonly INTERLEAVED_ATTRIBS: number;
  73745. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73746. createTransformFeedback(): WebGLTransformFeedback;
  73747. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73748. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73749. beginTransformFeedback(primitiveMode: number): void;
  73750. endTransformFeedback(): void;
  73751. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73752. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73753. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73754. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73755. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73756. }
  73757. interface ImageBitmap {
  73758. readonly width: number;
  73759. readonly height: number;
  73760. close(): void;
  73761. }
  73762. interface WebGLQuery extends WebGLObject {
  73763. }
  73764. declare var WebGLQuery: {
  73765. prototype: WebGLQuery;
  73766. new(): WebGLQuery;
  73767. };
  73768. interface WebGLSampler extends WebGLObject {
  73769. }
  73770. declare var WebGLSampler: {
  73771. prototype: WebGLSampler;
  73772. new(): WebGLSampler;
  73773. };
  73774. interface WebGLSync extends WebGLObject {
  73775. }
  73776. declare var WebGLSync: {
  73777. prototype: WebGLSync;
  73778. new(): WebGLSync;
  73779. };
  73780. interface WebGLTransformFeedback extends WebGLObject {
  73781. }
  73782. declare var WebGLTransformFeedback: {
  73783. prototype: WebGLTransformFeedback;
  73784. new(): WebGLTransformFeedback;
  73785. };
  73786. interface WebGLVertexArrayObject extends WebGLObject {
  73787. }
  73788. declare var WebGLVertexArrayObject: {
  73789. prototype: WebGLVertexArrayObject;
  73790. new(): WebGLVertexArrayObject;
  73791. };
  73792. // Type definitions for WebVR API
  73793. // Project: https://w3c.github.io/webvr/
  73794. // Definitions by: six a <https://github.com/lostfictions>
  73795. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73796. interface VRDisplay extends EventTarget {
  73797. /**
  73798. * Dictionary of capabilities describing the VRDisplay.
  73799. */
  73800. readonly capabilities: VRDisplayCapabilities;
  73801. /**
  73802. * z-depth defining the far plane of the eye view frustum
  73803. * enables mapping of values in the render target depth
  73804. * attachment to scene coordinates. Initially set to 10000.0.
  73805. */
  73806. depthFar: number;
  73807. /**
  73808. * z-depth defining the near plane of the eye view frustum
  73809. * enables mapping of values in the render target depth
  73810. * attachment to scene coordinates. Initially set to 0.01.
  73811. */
  73812. depthNear: number;
  73813. /**
  73814. * An identifier for this distinct VRDisplay. Used as an
  73815. * association point in the Gamepad API.
  73816. */
  73817. readonly displayId: number;
  73818. /**
  73819. * A display name, a user-readable name identifying it.
  73820. */
  73821. readonly displayName: string;
  73822. readonly isConnected: boolean;
  73823. readonly isPresenting: boolean;
  73824. /**
  73825. * If this VRDisplay supports room-scale experiences, the optional
  73826. * stage attribute contains details on the room-scale parameters.
  73827. */
  73828. readonly stageParameters: VRStageParameters | null;
  73829. /**
  73830. * Passing the value returned by `requestAnimationFrame` to
  73831. * `cancelAnimationFrame` will unregister the callback.
  73832. * @param handle Define the hanle of the request to cancel
  73833. */
  73834. cancelAnimationFrame(handle: number): void;
  73835. /**
  73836. * Stops presenting to the VRDisplay.
  73837. * @returns a promise to know when it stopped
  73838. */
  73839. exitPresent(): Promise<void>;
  73840. /**
  73841. * Return the current VREyeParameters for the given eye.
  73842. * @param whichEye Define the eye we want the parameter for
  73843. * @returns the eye parameters
  73844. */
  73845. getEyeParameters(whichEye: string): VREyeParameters;
  73846. /**
  73847. * Populates the passed VRFrameData with the information required to render
  73848. * the current frame.
  73849. * @param frameData Define the data structure to populate
  73850. * @returns true if ok otherwise false
  73851. */
  73852. getFrameData(frameData: VRFrameData): boolean;
  73853. /**
  73854. * Get the layers currently being presented.
  73855. * @returns the list of VR layers
  73856. */
  73857. getLayers(): VRLayer[];
  73858. /**
  73859. * Return a VRPose containing the future predicted pose of the VRDisplay
  73860. * when the current frame will be presented. The value returned will not
  73861. * change until JavaScript has returned control to the browser.
  73862. *
  73863. * The VRPose will contain the position, orientation, velocity,
  73864. * and acceleration of each of these properties.
  73865. * @returns the pose object
  73866. */
  73867. getPose(): VRPose;
  73868. /**
  73869. * Return the current instantaneous pose of the VRDisplay, with no
  73870. * prediction applied.
  73871. * @returns the current instantaneous pose
  73872. */
  73873. getImmediatePose(): VRPose;
  73874. /**
  73875. * The callback passed to `requestAnimationFrame` will be called
  73876. * any time a new frame should be rendered. When the VRDisplay is
  73877. * presenting the callback will be called at the native refresh
  73878. * rate of the HMD. When not presenting this function acts
  73879. * identically to how window.requestAnimationFrame acts. Content should
  73880. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73881. * asynchronously from other displays and at differing refresh rates.
  73882. * @param callback Define the eaction to run next frame
  73883. * @returns the request handle it
  73884. */
  73885. requestAnimationFrame(callback: FrameRequestCallback): number;
  73886. /**
  73887. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73888. * Repeat calls while already presenting will update the VRLayers being displayed.
  73889. * @param layers Define the list of layer to present
  73890. * @returns a promise to know when the request has been fulfilled
  73891. */
  73892. requestPresent(layers: VRLayer[]): Promise<void>;
  73893. /**
  73894. * Reset the pose for this display, treating its current position and
  73895. * orientation as the "origin/zero" values. VRPose.position,
  73896. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73897. * updated when calling resetPose(). This should be called in only
  73898. * sitting-space experiences.
  73899. */
  73900. resetPose(): void;
  73901. /**
  73902. * The VRLayer provided to the VRDisplay will be captured and presented
  73903. * in the HMD. Calling this function has the same effect on the source
  73904. * canvas as any other operation that uses its source image, and canvases
  73905. * created without preserveDrawingBuffer set to true will be cleared.
  73906. * @param pose Define the pose to submit
  73907. */
  73908. submitFrame(pose?: VRPose): void;
  73909. }
  73910. declare var VRDisplay: {
  73911. prototype: VRDisplay;
  73912. new(): VRDisplay;
  73913. };
  73914. interface VRLayer {
  73915. leftBounds?: number[] | Float32Array | null;
  73916. rightBounds?: number[] | Float32Array | null;
  73917. source?: HTMLCanvasElement | null;
  73918. }
  73919. interface VRDisplayCapabilities {
  73920. readonly canPresent: boolean;
  73921. readonly hasExternalDisplay: boolean;
  73922. readonly hasOrientation: boolean;
  73923. readonly hasPosition: boolean;
  73924. readonly maxLayers: number;
  73925. }
  73926. interface VREyeParameters {
  73927. /** @deprecated */
  73928. readonly fieldOfView: VRFieldOfView;
  73929. readonly offset: Float32Array;
  73930. readonly renderHeight: number;
  73931. readonly renderWidth: number;
  73932. }
  73933. interface VRFieldOfView {
  73934. readonly downDegrees: number;
  73935. readonly leftDegrees: number;
  73936. readonly rightDegrees: number;
  73937. readonly upDegrees: number;
  73938. }
  73939. interface VRFrameData {
  73940. readonly leftProjectionMatrix: Float32Array;
  73941. readonly leftViewMatrix: Float32Array;
  73942. readonly pose: VRPose;
  73943. readonly rightProjectionMatrix: Float32Array;
  73944. readonly rightViewMatrix: Float32Array;
  73945. readonly timestamp: number;
  73946. }
  73947. interface VRPose {
  73948. readonly angularAcceleration: Float32Array | null;
  73949. readonly angularVelocity: Float32Array | null;
  73950. readonly linearAcceleration: Float32Array | null;
  73951. readonly linearVelocity: Float32Array | null;
  73952. readonly orientation: Float32Array | null;
  73953. readonly position: Float32Array | null;
  73954. readonly timestamp: number;
  73955. }
  73956. interface VRStageParameters {
  73957. sittingToStandingTransform?: Float32Array;
  73958. sizeX?: number;
  73959. sizeY?: number;
  73960. }
  73961. interface Navigator {
  73962. getVRDisplays(): Promise<VRDisplay[]>;
  73963. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73964. }
  73965. interface Window {
  73966. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73967. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73968. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73969. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73970. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73971. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73972. }
  73973. interface Gamepad {
  73974. readonly displayId: number;
  73975. }
  73976. type XRSessionMode =
  73977. | "inline"
  73978. | "immersive-vr"
  73979. | "immersive-ar";
  73980. type XRReferenceSpaceType =
  73981. | "viewer"
  73982. | "local"
  73983. | "local-floor"
  73984. | "bounded-floor"
  73985. | "unbounded";
  73986. type XREnvironmentBlendMode =
  73987. | "opaque"
  73988. | "additive"
  73989. | "alpha-blend";
  73990. type XRVisibilityState =
  73991. | "visible"
  73992. | "visible-blurred"
  73993. | "hidden";
  73994. type XRHandedness =
  73995. | "none"
  73996. | "left"
  73997. | "right";
  73998. type XRTargetRayMode =
  73999. | "gaze"
  74000. | "tracked-pointer"
  74001. | "screen";
  74002. type XREye =
  74003. | "none"
  74004. | "left"
  74005. | "right";
  74006. type XREventType =
  74007. | "devicechange"
  74008. | "visibilitychange"
  74009. | "end"
  74010. | "inputsourceschange"
  74011. | "select"
  74012. | "selectstart"
  74013. | "selectend"
  74014. | "squeeze"
  74015. | "squeezestart"
  74016. | "squeezeend"
  74017. | "reset";
  74018. interface XRSpace extends EventTarget {
  74019. }
  74020. interface XRRenderState {
  74021. depthNear?: number;
  74022. depthFar?: number;
  74023. inlineVerticalFieldOfView?: number;
  74024. baseLayer?: XRWebGLLayer;
  74025. }
  74026. interface XRInputSource {
  74027. handedness: XRHandedness;
  74028. targetRayMode: XRTargetRayMode;
  74029. targetRaySpace: XRSpace;
  74030. gripSpace: XRSpace | undefined;
  74031. gamepad: Gamepad | undefined;
  74032. profiles: Array<string>;
  74033. }
  74034. interface XRSessionInit {
  74035. optionalFeatures?: string[];
  74036. requiredFeatures?: string[];
  74037. }
  74038. interface XRSession {
  74039. addEventListener: Function;
  74040. removeEventListener: Function;
  74041. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74042. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74043. requestAnimationFrame: Function;
  74044. end(): Promise<void>;
  74045. renderState: XRRenderState;
  74046. inputSources: Array<XRInputSource>;
  74047. // hit test
  74048. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74049. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74050. // legacy AR hit test
  74051. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74052. // legacy plane detection
  74053. updateWorldTrackingState(options: {
  74054. planeDetectionState?: { enabled: boolean; }
  74055. }): void;
  74056. }
  74057. interface XRReferenceSpace extends XRSpace {
  74058. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74059. onreset: any;
  74060. }
  74061. type XRPlaneSet = Set<XRPlane>;
  74062. type XRAnchorSet = Set<XRAnchor>;
  74063. interface XRFrame {
  74064. session: XRSession;
  74065. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74066. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74067. // AR
  74068. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74069. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74070. // Anchors
  74071. trackedAnchors?: XRAnchorSet;
  74072. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74073. // Planes
  74074. worldInformation: {
  74075. detectedPlanes?: XRPlaneSet;
  74076. };
  74077. }
  74078. interface XRViewerPose extends XRPose {
  74079. views: Array<XRView>;
  74080. }
  74081. interface XRPose {
  74082. transform: XRRigidTransform;
  74083. emulatedPosition: boolean;
  74084. }
  74085. interface XRWebGLLayerOptions {
  74086. antialias?: boolean;
  74087. depth?: boolean;
  74088. stencil?: boolean;
  74089. alpha?: boolean;
  74090. multiview?: boolean;
  74091. framebufferScaleFactor?: number;
  74092. }
  74093. declare var XRWebGLLayer: {
  74094. prototype: XRWebGLLayer;
  74095. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74096. };
  74097. interface XRWebGLLayer {
  74098. framebuffer: WebGLFramebuffer;
  74099. framebufferWidth: number;
  74100. framebufferHeight: number;
  74101. getViewport: Function;
  74102. }
  74103. declare class XRRigidTransform {
  74104. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74105. position: DOMPointReadOnly;
  74106. orientation: DOMPointReadOnly;
  74107. matrix: Float32Array;
  74108. inverse: XRRigidTransform;
  74109. }
  74110. interface XRView {
  74111. eye: XREye;
  74112. projectionMatrix: Float32Array;
  74113. transform: XRRigidTransform;
  74114. }
  74115. interface XRInputSourceChangeEvent {
  74116. session: XRSession;
  74117. removed: Array<XRInputSource>;
  74118. added: Array<XRInputSource>;
  74119. }
  74120. interface XRInputSourceEvent extends Event {
  74121. readonly frame: XRFrame;
  74122. readonly inputSource: XRInputSource;
  74123. }
  74124. // Experimental(er) features
  74125. declare class XRRay {
  74126. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74127. origin: DOMPointReadOnly;
  74128. direction: DOMPointReadOnly;
  74129. matrix: Float32Array;
  74130. }
  74131. declare enum XRHitTestTrackableType {
  74132. "point",
  74133. "plane"
  74134. }
  74135. interface XRHitResult {
  74136. hitMatrix: Float32Array;
  74137. }
  74138. interface XRTransientInputHitTestResult {
  74139. readonly inputSource: XRInputSource;
  74140. readonly results: Array<XRHitTestResult>;
  74141. }
  74142. interface XRHitTestResult {
  74143. getPose(baseSpace: XRSpace): XRPose | undefined;
  74144. // When anchor system is enabled
  74145. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74146. }
  74147. interface XRHitTestSource {
  74148. cancel(): void;
  74149. }
  74150. interface XRTransientInputHitTestSource {
  74151. cancel(): void;
  74152. }
  74153. interface XRHitTestOptionsInit {
  74154. space: XRSpace;
  74155. entityTypes?: Array<XRHitTestTrackableType>;
  74156. offsetRay?: XRRay;
  74157. }
  74158. interface XRTransientInputHitTestOptionsInit {
  74159. profile: string;
  74160. entityTypes?: Array<XRHitTestTrackableType>;
  74161. offsetRay?: XRRay;
  74162. }
  74163. interface XRAnchor {
  74164. anchorSpace: XRSpace;
  74165. delete(): void;
  74166. }
  74167. interface XRPlane {
  74168. orientation: "Horizontal" | "Vertical";
  74169. planeSpace: XRSpace;
  74170. polygon: Array<DOMPointReadOnly>;
  74171. lastChangedTime: number;
  74172. }
  74173. /**
  74174. * @ignore
  74175. */
  74176. declare module BABYLON.GLTF2.Exporter {
  74177. }
  74178. /**
  74179. * @ignore
  74180. */
  74181. declare module BABYLON.GLTF1 {
  74182. }
  74183. declare module BABYLON.GUI {
  74184. /**
  74185. * Class used to specific a value and its associated unit
  74186. */
  74187. export class ValueAndUnit {
  74188. /** defines the unit to store */
  74189. unit: number;
  74190. /** defines a boolean indicating if the value can be negative */
  74191. negativeValueAllowed: boolean;
  74192. private _value;
  74193. private _originalUnit;
  74194. /**
  74195. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74196. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74197. */
  74198. ignoreAdaptiveScaling: boolean;
  74199. /**
  74200. * Creates a new ValueAndUnit
  74201. * @param value defines the value to store
  74202. * @param unit defines the unit to store
  74203. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74204. */
  74205. constructor(value: number,
  74206. /** defines the unit to store */
  74207. unit?: number,
  74208. /** defines a boolean indicating if the value can be negative */
  74209. negativeValueAllowed?: boolean);
  74210. /** Gets a boolean indicating if the value is a percentage */
  74211. get isPercentage(): boolean;
  74212. /** Gets a boolean indicating if the value is store as pixel */
  74213. get isPixel(): boolean;
  74214. /** Gets direct internal value */
  74215. get internalValue(): number;
  74216. /**
  74217. * Gets value as pixel
  74218. * @param host defines the root host
  74219. * @param refValue defines the reference value for percentages
  74220. * @returns the value as pixel
  74221. */
  74222. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74223. /**
  74224. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74225. * @param value defines the value to store
  74226. * @param unit defines the unit to store
  74227. * @returns the current ValueAndUnit
  74228. */
  74229. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74230. /**
  74231. * Gets the value accordingly to its unit
  74232. * @param host defines the root host
  74233. * @returns the value
  74234. */
  74235. getValue(host: AdvancedDynamicTexture): number;
  74236. /**
  74237. * Gets a string representation of the value
  74238. * @param host defines the root host
  74239. * @param decimals defines an optional number of decimals to display
  74240. * @returns a string
  74241. */
  74242. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74243. /**
  74244. * Store a value parsed from a string
  74245. * @param source defines the source string
  74246. * @returns true if the value was successfully parsed
  74247. */
  74248. fromString(source: string | number): boolean;
  74249. private static _Regex;
  74250. private static _UNITMODE_PERCENTAGE;
  74251. private static _UNITMODE_PIXEL;
  74252. /** UNITMODE_PERCENTAGE */
  74253. static get UNITMODE_PERCENTAGE(): number;
  74254. /** UNITMODE_PIXEL */
  74255. static get UNITMODE_PIXEL(): number;
  74256. }
  74257. }
  74258. declare module BABYLON.GUI {
  74259. /**
  74260. * Define a style used by control to automatically setup properties based on a template.
  74261. * Only support font related properties so far
  74262. */
  74263. export class Style implements BABYLON.IDisposable {
  74264. private _fontFamily;
  74265. private _fontStyle;
  74266. private _fontWeight;
  74267. /** @hidden */
  74268. _host: AdvancedDynamicTexture;
  74269. /** @hidden */
  74270. _fontSize: ValueAndUnit;
  74271. /**
  74272. * BABYLON.Observable raised when the style values are changed
  74273. */
  74274. onChangedObservable: BABYLON.Observable<Style>;
  74275. /**
  74276. * Creates a new style object
  74277. * @param host defines the AdvancedDynamicTexture which hosts this style
  74278. */
  74279. constructor(host: AdvancedDynamicTexture);
  74280. /**
  74281. * Gets or sets the font size
  74282. */
  74283. get fontSize(): string | number;
  74284. set fontSize(value: string | number);
  74285. /**
  74286. * Gets or sets the font family
  74287. */
  74288. get fontFamily(): string;
  74289. set fontFamily(value: string);
  74290. /**
  74291. * Gets or sets the font style
  74292. */
  74293. get fontStyle(): string;
  74294. set fontStyle(value: string);
  74295. /** Gets or sets font weight */
  74296. get fontWeight(): string;
  74297. set fontWeight(value: string);
  74298. /** Dispose all associated resources */
  74299. dispose(): void;
  74300. }
  74301. }
  74302. declare module BABYLON.GUI {
  74303. /**
  74304. * Class used to transport BABYLON.Vector2 information for pointer events
  74305. */
  74306. export class Vector2WithInfo extends BABYLON.Vector2 {
  74307. /** defines the current mouse button index */
  74308. buttonIndex: number;
  74309. /**
  74310. * Creates a new Vector2WithInfo
  74311. * @param source defines the vector2 data to transport
  74312. * @param buttonIndex defines the current mouse button index
  74313. */
  74314. constructor(source: BABYLON.Vector2,
  74315. /** defines the current mouse button index */
  74316. buttonIndex?: number);
  74317. }
  74318. /** Class used to provide 2D matrix features */
  74319. export class Matrix2D {
  74320. /** Gets the internal array of 6 floats used to store matrix data */
  74321. m: Float32Array;
  74322. /**
  74323. * Creates a new matrix
  74324. * @param m00 defines value for (0, 0)
  74325. * @param m01 defines value for (0, 1)
  74326. * @param m10 defines value for (1, 0)
  74327. * @param m11 defines value for (1, 1)
  74328. * @param m20 defines value for (2, 0)
  74329. * @param m21 defines value for (2, 1)
  74330. */
  74331. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74332. /**
  74333. * Fills the matrix from direct values
  74334. * @param m00 defines value for (0, 0)
  74335. * @param m01 defines value for (0, 1)
  74336. * @param m10 defines value for (1, 0)
  74337. * @param m11 defines value for (1, 1)
  74338. * @param m20 defines value for (2, 0)
  74339. * @param m21 defines value for (2, 1)
  74340. * @returns the current modified matrix
  74341. */
  74342. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74343. /**
  74344. * Gets matrix determinant
  74345. * @returns the determinant
  74346. */
  74347. determinant(): number;
  74348. /**
  74349. * Inverses the matrix and stores it in a target matrix
  74350. * @param result defines the target matrix
  74351. * @returns the current matrix
  74352. */
  74353. invertToRef(result: Matrix2D): Matrix2D;
  74354. /**
  74355. * Multiplies the current matrix with another one
  74356. * @param other defines the second operand
  74357. * @param result defines the target matrix
  74358. * @returns the current matrix
  74359. */
  74360. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74361. /**
  74362. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74363. * @param x defines the x coordinate to transform
  74364. * @param y defines the x coordinate to transform
  74365. * @param result defines the target vector2
  74366. * @returns the current matrix
  74367. */
  74368. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74369. /**
  74370. * Creates an identity matrix
  74371. * @returns a new matrix
  74372. */
  74373. static Identity(): Matrix2D;
  74374. /**
  74375. * Creates a translation matrix and stores it in a target matrix
  74376. * @param x defines the x coordinate of the translation
  74377. * @param y defines the y coordinate of the translation
  74378. * @param result defines the target matrix
  74379. */
  74380. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74381. /**
  74382. * Creates a scaling matrix and stores it in a target matrix
  74383. * @param x defines the x coordinate of the scaling
  74384. * @param y defines the y coordinate of the scaling
  74385. * @param result defines the target matrix
  74386. */
  74387. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74388. /**
  74389. * Creates a rotation matrix and stores it in a target matrix
  74390. * @param angle defines the rotation angle
  74391. * @param result defines the target matrix
  74392. */
  74393. static RotationToRef(angle: number, result: Matrix2D): void;
  74394. private static _TempPreTranslationMatrix;
  74395. private static _TempPostTranslationMatrix;
  74396. private static _TempRotationMatrix;
  74397. private static _TempScalingMatrix;
  74398. private static _TempCompose0;
  74399. private static _TempCompose1;
  74400. private static _TempCompose2;
  74401. /**
  74402. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74403. * @param tx defines the x coordinate of the translation
  74404. * @param ty defines the y coordinate of the translation
  74405. * @param angle defines the rotation angle
  74406. * @param scaleX defines the x coordinate of the scaling
  74407. * @param scaleY defines the y coordinate of the scaling
  74408. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74409. * @param result defines the target matrix
  74410. */
  74411. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74412. }
  74413. }
  74414. declare module BABYLON.GUI {
  74415. /**
  74416. * Class used to store 2D control sizes
  74417. */
  74418. export class Measure {
  74419. /** defines left coordinate */
  74420. left: number;
  74421. /** defines top coordinate */
  74422. top: number;
  74423. /** defines width dimension */
  74424. width: number;
  74425. /** defines height dimension */
  74426. height: number;
  74427. /**
  74428. * Creates a new measure
  74429. * @param left defines left coordinate
  74430. * @param top defines top coordinate
  74431. * @param width defines width dimension
  74432. * @param height defines height dimension
  74433. */
  74434. constructor(
  74435. /** defines left coordinate */
  74436. left: number,
  74437. /** defines top coordinate */
  74438. top: number,
  74439. /** defines width dimension */
  74440. width: number,
  74441. /** defines height dimension */
  74442. height: number);
  74443. /**
  74444. * Copy from another measure
  74445. * @param other defines the other measure to copy from
  74446. */
  74447. copyFrom(other: Measure): void;
  74448. /**
  74449. * Copy from a group of 4 floats
  74450. * @param left defines left coordinate
  74451. * @param top defines top coordinate
  74452. * @param width defines width dimension
  74453. * @param height defines height dimension
  74454. */
  74455. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74456. /**
  74457. * Computes the axis aligned bounding box measure for two given measures
  74458. * @param a Input measure
  74459. * @param b Input measure
  74460. * @param result the resulting bounding measure
  74461. */
  74462. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74463. /**
  74464. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74465. * @param transform the matrix to transform the measure before computing the AABB
  74466. * @param result the resulting AABB
  74467. */
  74468. transformToRef(transform: Matrix2D, result: Measure): void;
  74469. /**
  74470. * Check equality between this measure and another one
  74471. * @param other defines the other measures
  74472. * @returns true if both measures are equals
  74473. */
  74474. isEqualsTo(other: Measure): boolean;
  74475. /**
  74476. * Creates an empty measure
  74477. * @returns a new measure
  74478. */
  74479. static Empty(): Measure;
  74480. }
  74481. }
  74482. declare module BABYLON.GUI {
  74483. /**
  74484. * Interface used to define a control that can receive focus
  74485. */
  74486. export interface IFocusableControl {
  74487. /**
  74488. * Function called when the control receives the focus
  74489. */
  74490. onFocus(): void;
  74491. /**
  74492. * Function called when the control loses the focus
  74493. */
  74494. onBlur(): void;
  74495. /**
  74496. * Function called to let the control handle keyboard events
  74497. * @param evt defines the current keyboard event
  74498. */
  74499. processKeyboard(evt: KeyboardEvent): void;
  74500. /**
  74501. * Function called to get the list of controls that should not steal the focus from this control
  74502. * @returns an array of controls
  74503. */
  74504. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74505. }
  74506. /**
  74507. * Class used to create texture to support 2D GUI elements
  74508. * @see http://doc.babylonjs.com/how_to/gui
  74509. */
  74510. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74511. private _isDirty;
  74512. private _renderObserver;
  74513. private _resizeObserver;
  74514. private _preKeyboardObserver;
  74515. private _pointerMoveObserver;
  74516. private _pointerObserver;
  74517. private _canvasPointerOutObserver;
  74518. private _background;
  74519. /** @hidden */
  74520. _rootContainer: Container;
  74521. /** @hidden */
  74522. _lastPickedControl: Control;
  74523. /** @hidden */
  74524. _lastControlOver: {
  74525. [pointerId: number]: Control;
  74526. };
  74527. /** @hidden */
  74528. _lastControlDown: {
  74529. [pointerId: number]: Control;
  74530. };
  74531. /** @hidden */
  74532. _capturingControl: {
  74533. [pointerId: number]: Control;
  74534. };
  74535. /** @hidden */
  74536. _shouldBlockPointer: boolean;
  74537. /** @hidden */
  74538. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74539. /** @hidden */
  74540. _linkedControls: Control[];
  74541. private _isFullscreen;
  74542. private _fullscreenViewport;
  74543. private _idealWidth;
  74544. private _idealHeight;
  74545. private _useSmallestIdeal;
  74546. private _renderAtIdealSize;
  74547. private _focusedControl;
  74548. private _blockNextFocusCheck;
  74549. private _renderScale;
  74550. private _rootElement;
  74551. private _cursorChanged;
  74552. private _defaultMousePointerId;
  74553. /** @hidden */
  74554. _numLayoutCalls: number;
  74555. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74556. get numLayoutCalls(): number;
  74557. /** @hidden */
  74558. _numRenderCalls: number;
  74559. /** Gets the number of render calls made the last time the ADT has been rendered */
  74560. get numRenderCalls(): number;
  74561. /**
  74562. * Define type to string to ensure compatibility across browsers
  74563. * Safari doesn't support DataTransfer constructor
  74564. */
  74565. private _clipboardData;
  74566. /**
  74567. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74568. */
  74569. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74570. /**
  74571. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74572. */
  74573. onControlPickedObservable: BABYLON.Observable<Control>;
  74574. /**
  74575. * BABYLON.Observable event triggered before layout is evaluated
  74576. */
  74577. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74578. /**
  74579. * BABYLON.Observable event triggered after the layout was evaluated
  74580. */
  74581. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74582. /**
  74583. * BABYLON.Observable event triggered before the texture is rendered
  74584. */
  74585. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74586. /**
  74587. * BABYLON.Observable event triggered after the texture was rendered
  74588. */
  74589. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74590. /**
  74591. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74592. */
  74593. premulAlpha: boolean;
  74594. /**
  74595. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74596. * Useful when you want more antialiasing
  74597. */
  74598. get renderScale(): number;
  74599. set renderScale(value: number);
  74600. /** Gets or sets the background color */
  74601. get background(): string;
  74602. set background(value: string);
  74603. /**
  74604. * Gets or sets the ideal width used to design controls.
  74605. * The GUI will then rescale everything accordingly
  74606. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74607. */
  74608. get idealWidth(): number;
  74609. set idealWidth(value: number);
  74610. /**
  74611. * Gets or sets the ideal height used to design controls.
  74612. * The GUI will then rescale everything accordingly
  74613. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74614. */
  74615. get idealHeight(): number;
  74616. set idealHeight(value: number);
  74617. /**
  74618. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74619. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74620. */
  74621. get useSmallestIdeal(): boolean;
  74622. set useSmallestIdeal(value: boolean);
  74623. /**
  74624. * Gets or sets a boolean indicating if adaptive scaling must be used
  74625. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74626. */
  74627. get renderAtIdealSize(): boolean;
  74628. set renderAtIdealSize(value: boolean);
  74629. /**
  74630. * Gets the ratio used when in "ideal mode"
  74631. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74632. * */
  74633. get idealRatio(): number;
  74634. /**
  74635. * Gets the underlying layer used to render the texture when in fullscreen mode
  74636. */
  74637. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74638. /**
  74639. * Gets the root container control
  74640. */
  74641. get rootContainer(): Container;
  74642. /**
  74643. * Returns an array containing the root container.
  74644. * This is mostly used to let the Inspector introspects the ADT
  74645. * @returns an array containing the rootContainer
  74646. */
  74647. getChildren(): Array<Container>;
  74648. /**
  74649. * Will return all controls that are inside this texture
  74650. * @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
  74651. * @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
  74652. * @return all child controls
  74653. */
  74654. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74655. /**
  74656. * Gets or sets the current focused control
  74657. */
  74658. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74659. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74660. /**
  74661. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74662. */
  74663. get isForeground(): boolean;
  74664. set isForeground(value: boolean);
  74665. /**
  74666. * Gets or set information about clipboardData
  74667. */
  74668. get clipboardData(): string;
  74669. set clipboardData(value: string);
  74670. /**
  74671. * Creates a new AdvancedDynamicTexture
  74672. * @param name defines the name of the texture
  74673. * @param width defines the width of the texture
  74674. * @param height defines the height of the texture
  74675. * @param scene defines the hosting scene
  74676. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74677. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74678. */
  74679. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74680. /**
  74681. * Get the current class name of the texture useful for serialization or dynamic coding.
  74682. * @returns "AdvancedDynamicTexture"
  74683. */
  74684. getClassName(): string;
  74685. /**
  74686. * Function used to execute a function on all controls
  74687. * @param func defines the function to execute
  74688. * @param container defines the container where controls belong. If null the root container will be used
  74689. */
  74690. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74691. private _useInvalidateRectOptimization;
  74692. /**
  74693. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74694. */
  74695. get useInvalidateRectOptimization(): boolean;
  74696. set useInvalidateRectOptimization(value: boolean);
  74697. private _invalidatedRectangle;
  74698. /**
  74699. * Invalidates a rectangle area on the gui texture
  74700. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74701. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74702. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74703. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74704. */
  74705. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74706. /**
  74707. * Marks the texture as dirty forcing a complete update
  74708. */
  74709. markAsDirty(): void;
  74710. /**
  74711. * Helper function used to create a new style
  74712. * @returns a new style
  74713. * @see http://doc.babylonjs.com/how_to/gui#styles
  74714. */
  74715. createStyle(): Style;
  74716. /**
  74717. * Adds a new control to the root container
  74718. * @param control defines the control to add
  74719. * @returns the current texture
  74720. */
  74721. addControl(control: Control): AdvancedDynamicTexture;
  74722. /**
  74723. * Removes a control from the root container
  74724. * @param control defines the control to remove
  74725. * @returns the current texture
  74726. */
  74727. removeControl(control: Control): AdvancedDynamicTexture;
  74728. /**
  74729. * Release all resources
  74730. */
  74731. dispose(): void;
  74732. private _onResize;
  74733. /** @hidden */
  74734. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74735. /**
  74736. * Get screen coordinates for a vector3
  74737. * @param position defines the position to project
  74738. * @param worldMatrix defines the world matrix to use
  74739. * @returns the projected position
  74740. */
  74741. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74742. private _checkUpdate;
  74743. private _clearMeasure;
  74744. private _render;
  74745. /** @hidden */
  74746. _changeCursor(cursor: string): void;
  74747. /** @hidden */
  74748. _registerLastControlDown(control: Control, pointerId: number): void;
  74749. private _doPicking;
  74750. /** @hidden */
  74751. _cleanControlAfterRemovalFromList(list: {
  74752. [pointerId: number]: Control;
  74753. }, control: Control): void;
  74754. /** @hidden */
  74755. _cleanControlAfterRemoval(control: Control): void;
  74756. /** Attach to all scene events required to support pointer events */
  74757. attach(): void;
  74758. /** @hidden */
  74759. private onClipboardCopy;
  74760. /** @hidden */
  74761. private onClipboardCut;
  74762. /** @hidden */
  74763. private onClipboardPaste;
  74764. /**
  74765. * Register the clipboard Events onto the canvas
  74766. */
  74767. registerClipboardEvents(): void;
  74768. /**
  74769. * Unregister the clipboard Events from the canvas
  74770. */
  74771. unRegisterClipboardEvents(): void;
  74772. /**
  74773. * Connect the texture to a hosting mesh to enable interactions
  74774. * @param mesh defines the mesh to attach to
  74775. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74776. */
  74777. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74778. /**
  74779. * Move the focus to a specific control
  74780. * @param control defines the control which will receive the focus
  74781. */
  74782. moveFocusToControl(control: IFocusableControl): void;
  74783. private _manageFocus;
  74784. private _attachToOnPointerOut;
  74785. /**
  74786. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74787. * @param mesh defines the mesh which will receive the texture
  74788. * @param width defines the texture width (1024 by default)
  74789. * @param height defines the texture height (1024 by default)
  74790. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74791. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74792. * @returns a new AdvancedDynamicTexture
  74793. */
  74794. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74795. /**
  74796. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74797. * In this mode the texture will rely on a layer for its rendering.
  74798. * This allows it to be treated like any other layer.
  74799. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74800. * LayerMask is set through advancedTexture.layer.layerMask
  74801. * @param name defines name for the texture
  74802. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74803. * @param scene defines the hsoting scene
  74804. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74805. * @returns a new AdvancedDynamicTexture
  74806. */
  74807. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74808. }
  74809. }
  74810. declare module BABYLON.GUI {
  74811. /**
  74812. * Root class used for all 2D controls
  74813. * @see http://doc.babylonjs.com/how_to/gui#controls
  74814. */
  74815. export class Control {
  74816. /** defines the name of the control */
  74817. name?: string | undefined;
  74818. /**
  74819. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74820. */
  74821. static AllowAlphaInheritance: boolean;
  74822. private _alpha;
  74823. private _alphaSet;
  74824. private _zIndex;
  74825. /** @hidden */
  74826. _host: AdvancedDynamicTexture;
  74827. /** Gets or sets the control parent */
  74828. parent: BABYLON.Nullable<Container>;
  74829. /** @hidden */
  74830. _currentMeasure: Measure;
  74831. private _fontFamily;
  74832. private _fontStyle;
  74833. private _fontWeight;
  74834. private _fontSize;
  74835. private _font;
  74836. /** @hidden */
  74837. _width: ValueAndUnit;
  74838. /** @hidden */
  74839. _height: ValueAndUnit;
  74840. /** @hidden */
  74841. protected _fontOffset: {
  74842. ascent: number;
  74843. height: number;
  74844. descent: number;
  74845. };
  74846. private _color;
  74847. private _style;
  74848. private _styleObserver;
  74849. /** @hidden */
  74850. protected _horizontalAlignment: number;
  74851. /** @hidden */
  74852. protected _verticalAlignment: number;
  74853. /** @hidden */
  74854. protected _isDirty: boolean;
  74855. /** @hidden */
  74856. protected _wasDirty: boolean;
  74857. /** @hidden */
  74858. _tempParentMeasure: Measure;
  74859. /** @hidden */
  74860. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74861. /** @hidden */
  74862. protected _cachedParentMeasure: Measure;
  74863. private _paddingLeft;
  74864. private _paddingRight;
  74865. private _paddingTop;
  74866. private _paddingBottom;
  74867. /** @hidden */
  74868. _left: ValueAndUnit;
  74869. /** @hidden */
  74870. _top: ValueAndUnit;
  74871. private _scaleX;
  74872. private _scaleY;
  74873. private _rotation;
  74874. private _transformCenterX;
  74875. private _transformCenterY;
  74876. /** @hidden */
  74877. _transformMatrix: Matrix2D;
  74878. /** @hidden */
  74879. protected _invertTransformMatrix: Matrix2D;
  74880. /** @hidden */
  74881. protected _transformedPosition: BABYLON.Vector2;
  74882. private _isMatrixDirty;
  74883. private _cachedOffsetX;
  74884. private _cachedOffsetY;
  74885. private _isVisible;
  74886. private _isHighlighted;
  74887. /** @hidden */
  74888. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74889. private _fontSet;
  74890. private _dummyVector2;
  74891. private _downCount;
  74892. private _enterCount;
  74893. private _doNotRender;
  74894. private _downPointerIds;
  74895. protected _isEnabled: boolean;
  74896. protected _disabledColor: string;
  74897. protected _disabledColorItem: string;
  74898. /** @hidden */
  74899. protected _rebuildLayout: boolean;
  74900. /** @hidden */
  74901. _customData: any;
  74902. /** @hidden */
  74903. _isClipped: boolean;
  74904. /** @hidden */
  74905. _automaticSize: boolean;
  74906. /** @hidden */
  74907. _tag: any;
  74908. /**
  74909. * 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
  74910. */
  74911. uniqueId: number;
  74912. /**
  74913. * Gets or sets an object used to store user defined information for the node
  74914. */
  74915. metadata: any;
  74916. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74917. isHitTestVisible: boolean;
  74918. /** Gets or sets a boolean indicating if the control can block pointer events */
  74919. isPointerBlocker: boolean;
  74920. /** Gets or sets a boolean indicating if the control can be focusable */
  74921. isFocusInvisible: boolean;
  74922. /**
  74923. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74924. * 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
  74925. */
  74926. clipChildren: boolean;
  74927. /**
  74928. * Gets or sets a boolean indicating that control content must be clipped
  74929. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  74930. */
  74931. clipContent: boolean;
  74932. /**
  74933. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74934. */
  74935. useBitmapCache: boolean;
  74936. private _cacheData;
  74937. private _shadowOffsetX;
  74938. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74939. get shadowOffsetX(): number;
  74940. set shadowOffsetX(value: number);
  74941. private _shadowOffsetY;
  74942. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74943. get shadowOffsetY(): number;
  74944. set shadowOffsetY(value: number);
  74945. private _shadowBlur;
  74946. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74947. get shadowBlur(): number;
  74948. set shadowBlur(value: number);
  74949. private _shadowColor;
  74950. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74951. get shadowColor(): string;
  74952. set shadowColor(value: string);
  74953. /** Gets or sets the cursor to use when the control is hovered */
  74954. hoverCursor: string;
  74955. /** @hidden */
  74956. protected _linkOffsetX: ValueAndUnit;
  74957. /** @hidden */
  74958. protected _linkOffsetY: ValueAndUnit;
  74959. /** Gets the control type name */
  74960. get typeName(): string;
  74961. /**
  74962. * Get the current class name of the control.
  74963. * @returns current class name
  74964. */
  74965. getClassName(): string;
  74966. /**
  74967. * An event triggered when pointer wheel is scrolled
  74968. */
  74969. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74970. /**
  74971. * An event triggered when the pointer move over the control.
  74972. */
  74973. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74974. /**
  74975. * An event triggered when the pointer move out of the control.
  74976. */
  74977. onPointerOutObservable: BABYLON.Observable<Control>;
  74978. /**
  74979. * An event triggered when the pointer taps the control
  74980. */
  74981. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74982. /**
  74983. * An event triggered when pointer up
  74984. */
  74985. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74986. /**
  74987. * An event triggered when a control is clicked on
  74988. */
  74989. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74990. /**
  74991. * An event triggered when pointer enters the control
  74992. */
  74993. onPointerEnterObservable: BABYLON.Observable<Control>;
  74994. /**
  74995. * An event triggered when the control is marked as dirty
  74996. */
  74997. onDirtyObservable: BABYLON.Observable<Control>;
  74998. /**
  74999. * An event triggered before drawing the control
  75000. */
  75001. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75002. /**
  75003. * An event triggered after the control was drawn
  75004. */
  75005. onAfterDrawObservable: BABYLON.Observable<Control>;
  75006. /**
  75007. * An event triggered when the control has been disposed
  75008. */
  75009. onDisposeObservable: BABYLON.Observable<Control>;
  75010. /**
  75011. * Get the hosting AdvancedDynamicTexture
  75012. */
  75013. get host(): AdvancedDynamicTexture;
  75014. /** Gets or set information about font offsets (used to render and align text) */
  75015. get fontOffset(): {
  75016. ascent: number;
  75017. height: number;
  75018. descent: number;
  75019. };
  75020. set fontOffset(offset: {
  75021. ascent: number;
  75022. height: number;
  75023. descent: number;
  75024. });
  75025. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75026. get alpha(): number;
  75027. set alpha(value: number);
  75028. /**
  75029. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75030. */
  75031. get isHighlighted(): boolean;
  75032. set isHighlighted(value: boolean);
  75033. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75034. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75035. */
  75036. get scaleX(): number;
  75037. set scaleX(value: number);
  75038. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75039. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75040. */
  75041. get scaleY(): number;
  75042. set scaleY(value: number);
  75043. /** Gets or sets the rotation angle (0 by default)
  75044. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75045. */
  75046. get rotation(): number;
  75047. set rotation(value: number);
  75048. /** Gets or sets the transformation center on Y axis (0 by default)
  75049. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75050. */
  75051. get transformCenterY(): number;
  75052. set transformCenterY(value: number);
  75053. /** Gets or sets the transformation center on X axis (0 by default)
  75054. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75055. */
  75056. get transformCenterX(): number;
  75057. set transformCenterX(value: number);
  75058. /**
  75059. * Gets or sets the horizontal alignment
  75060. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75061. */
  75062. get horizontalAlignment(): number;
  75063. set horizontalAlignment(value: number);
  75064. /**
  75065. * Gets or sets the vertical alignment
  75066. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75067. */
  75068. get verticalAlignment(): number;
  75069. set verticalAlignment(value: number);
  75070. /**
  75071. * Gets or sets control width
  75072. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75073. */
  75074. get width(): string | number;
  75075. set width(value: string | number);
  75076. /**
  75077. * Gets or sets the control width in pixel
  75078. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75079. */
  75080. get widthInPixels(): number;
  75081. set widthInPixels(value: number);
  75082. /**
  75083. * Gets or sets control height
  75084. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75085. */
  75086. get height(): string | number;
  75087. set height(value: string | number);
  75088. /**
  75089. * Gets or sets control height in pixel
  75090. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75091. */
  75092. get heightInPixels(): number;
  75093. set heightInPixels(value: number);
  75094. /** Gets or set font family */
  75095. get fontFamily(): string;
  75096. set fontFamily(value: string);
  75097. /** Gets or sets font style */
  75098. get fontStyle(): string;
  75099. set fontStyle(value: string);
  75100. /** Gets or sets font weight */
  75101. get fontWeight(): string;
  75102. set fontWeight(value: string);
  75103. /**
  75104. * Gets or sets style
  75105. * @see http://doc.babylonjs.com/how_to/gui#styles
  75106. */
  75107. get style(): BABYLON.Nullable<Style>;
  75108. set style(value: BABYLON.Nullable<Style>);
  75109. /** @hidden */
  75110. get _isFontSizeInPercentage(): boolean;
  75111. /** Gets or sets font size in pixels */
  75112. get fontSizeInPixels(): number;
  75113. set fontSizeInPixels(value: number);
  75114. /** Gets or sets font size */
  75115. get fontSize(): string | number;
  75116. set fontSize(value: string | number);
  75117. /** Gets or sets foreground color */
  75118. get color(): string;
  75119. set color(value: string);
  75120. /** Gets or sets z index which is used to reorder controls on the z axis */
  75121. get zIndex(): number;
  75122. set zIndex(value: number);
  75123. /** Gets or sets a boolean indicating if the control can be rendered */
  75124. get notRenderable(): boolean;
  75125. set notRenderable(value: boolean);
  75126. /** Gets or sets a boolean indicating if the control is visible */
  75127. get isVisible(): boolean;
  75128. set isVisible(value: boolean);
  75129. /** Gets a boolean indicating that the control needs to update its rendering */
  75130. get isDirty(): boolean;
  75131. /**
  75132. * Gets the current linked mesh (or null if none)
  75133. */
  75134. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75135. /**
  75136. * Gets or sets a value indicating the padding to use on the left of the control
  75137. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75138. */
  75139. get paddingLeft(): string | number;
  75140. set paddingLeft(value: string | number);
  75141. /**
  75142. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75143. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75144. */
  75145. get paddingLeftInPixels(): number;
  75146. set paddingLeftInPixels(value: number);
  75147. /**
  75148. * Gets or sets a value indicating the padding to use on the right of the control
  75149. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75150. */
  75151. get paddingRight(): string | number;
  75152. set paddingRight(value: string | number);
  75153. /**
  75154. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75155. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75156. */
  75157. get paddingRightInPixels(): number;
  75158. set paddingRightInPixels(value: number);
  75159. /**
  75160. * Gets or sets a value indicating the padding to use on the top of the control
  75161. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75162. */
  75163. get paddingTop(): string | number;
  75164. set paddingTop(value: string | number);
  75165. /**
  75166. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75167. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75168. */
  75169. get paddingTopInPixels(): number;
  75170. set paddingTopInPixels(value: number);
  75171. /**
  75172. * Gets or sets a value indicating the padding to use on the bottom of the control
  75173. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75174. */
  75175. get paddingBottom(): string | number;
  75176. set paddingBottom(value: string | number);
  75177. /**
  75178. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75179. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75180. */
  75181. get paddingBottomInPixels(): number;
  75182. set paddingBottomInPixels(value: number);
  75183. /**
  75184. * Gets or sets a value indicating the left coordinate of the control
  75185. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75186. */
  75187. get left(): string | number;
  75188. set left(value: string | number);
  75189. /**
  75190. * Gets or sets a value indicating the left coordinate in pixels of the control
  75191. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75192. */
  75193. get leftInPixels(): number;
  75194. set leftInPixels(value: number);
  75195. /**
  75196. * Gets or sets a value indicating the top coordinate of the control
  75197. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75198. */
  75199. get top(): string | number;
  75200. set top(value: string | number);
  75201. /**
  75202. * Gets or sets a value indicating the top coordinate in pixels of the control
  75203. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75204. */
  75205. get topInPixels(): number;
  75206. set topInPixels(value: number);
  75207. /**
  75208. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75209. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75210. */
  75211. get linkOffsetX(): string | number;
  75212. set linkOffsetX(value: string | number);
  75213. /**
  75214. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75215. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75216. */
  75217. get linkOffsetXInPixels(): number;
  75218. set linkOffsetXInPixels(value: number);
  75219. /**
  75220. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75221. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75222. */
  75223. get linkOffsetY(): string | number;
  75224. set linkOffsetY(value: string | number);
  75225. /**
  75226. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75227. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75228. */
  75229. get linkOffsetYInPixels(): number;
  75230. set linkOffsetYInPixels(value: number);
  75231. /** Gets the center coordinate on X axis */
  75232. get centerX(): number;
  75233. /** Gets the center coordinate on Y axis */
  75234. get centerY(): number;
  75235. /** Gets or sets if control is Enabled*/
  75236. get isEnabled(): boolean;
  75237. set isEnabled(value: boolean);
  75238. /** Gets or sets background color of control if it's disabled*/
  75239. get disabledColor(): string;
  75240. set disabledColor(value: string);
  75241. /** Gets or sets front color of control if it's disabled*/
  75242. get disabledColorItem(): string;
  75243. set disabledColorItem(value: string);
  75244. /**
  75245. * Creates a new control
  75246. * @param name defines the name of the control
  75247. */
  75248. constructor(
  75249. /** defines the name of the control */
  75250. name?: string | undefined);
  75251. /** @hidden */
  75252. protected _getTypeName(): string;
  75253. /**
  75254. * Gets the first ascendant in the hierarchy of the given type
  75255. * @param className defines the required type
  75256. * @returns the ascendant or null if not found
  75257. */
  75258. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75259. /** @hidden */
  75260. _resetFontCache(): void;
  75261. /**
  75262. * Determines if a container is an ascendant of the current control
  75263. * @param container defines the container to look for
  75264. * @returns true if the container is one of the ascendant of the control
  75265. */
  75266. isAscendant(container: Control): boolean;
  75267. /**
  75268. * Gets coordinates in local control space
  75269. * @param globalCoordinates defines the coordinates to transform
  75270. * @returns the new coordinates in local space
  75271. */
  75272. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75273. /**
  75274. * Gets coordinates in local control space
  75275. * @param globalCoordinates defines the coordinates to transform
  75276. * @param result defines the target vector2 where to store the result
  75277. * @returns the current control
  75278. */
  75279. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75280. /**
  75281. * Gets coordinates in parent local control space
  75282. * @param globalCoordinates defines the coordinates to transform
  75283. * @returns the new coordinates in parent local space
  75284. */
  75285. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75286. /**
  75287. * Move the current control to a vector3 position projected onto the screen.
  75288. * @param position defines the target position
  75289. * @param scene defines the hosting scene
  75290. */
  75291. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75292. /**
  75293. * Will store all controls that have this control as ascendant in a given array
  75294. * @param results defines the array where to store the descendants
  75295. * @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
  75296. * @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
  75297. */
  75298. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75299. /**
  75300. * Will return all controls that have this control as ascendant
  75301. * @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
  75302. * @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
  75303. * @return all child controls
  75304. */
  75305. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75306. /**
  75307. * Link current control with a target mesh
  75308. * @param mesh defines the mesh to link with
  75309. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75310. */
  75311. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75312. /** @hidden */
  75313. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75314. /** @hidden */
  75315. _offsetLeft(offset: number): void;
  75316. /** @hidden */
  75317. _offsetTop(offset: number): void;
  75318. /** @hidden */
  75319. _markMatrixAsDirty(): void;
  75320. /** @hidden */
  75321. _flagDescendantsAsMatrixDirty(): void;
  75322. /** @hidden */
  75323. _intersectsRect(rect: Measure): boolean;
  75324. /** @hidden */
  75325. protected invalidateRect(): void;
  75326. /** @hidden */
  75327. _markAsDirty(force?: boolean): void;
  75328. /** @hidden */
  75329. _markAllAsDirty(): void;
  75330. /** @hidden */
  75331. _link(host: AdvancedDynamicTexture): void;
  75332. /** @hidden */
  75333. protected _transform(context?: CanvasRenderingContext2D): void;
  75334. /** @hidden */
  75335. _renderHighlight(context: CanvasRenderingContext2D): void;
  75336. /** @hidden */
  75337. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75338. /** @hidden */
  75339. protected _applyStates(context: CanvasRenderingContext2D): void;
  75340. /** @hidden */
  75341. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75342. /** @hidden */
  75343. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75344. protected _evaluateClippingState(parentMeasure: Measure): void;
  75345. /** @hidden */
  75346. _measure(): void;
  75347. /** @hidden */
  75348. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75349. /** @hidden */
  75350. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75351. /** @hidden */
  75352. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75353. /** @hidden */
  75354. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75355. private static _ClipMeasure;
  75356. private _tmpMeasureA;
  75357. private _clip;
  75358. /** @hidden */
  75359. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75360. /** @hidden */
  75361. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75362. /**
  75363. * Tests if a given coordinates belong to the current control
  75364. * @param x defines x coordinate to test
  75365. * @param y defines y coordinate to test
  75366. * @returns true if the coordinates are inside the control
  75367. */
  75368. contains(x: number, y: number): boolean;
  75369. /** @hidden */
  75370. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75371. /** @hidden */
  75372. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75373. /** @hidden */
  75374. _onPointerEnter(target: Control): boolean;
  75375. /** @hidden */
  75376. _onPointerOut(target: Control, force?: boolean): void;
  75377. /** @hidden */
  75378. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75379. /** @hidden */
  75380. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75381. /** @hidden */
  75382. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75383. /** @hidden */
  75384. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75385. /** @hidden */
  75386. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75387. private _prepareFont;
  75388. /** Releases associated resources */
  75389. dispose(): void;
  75390. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75391. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75392. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75393. private static _VERTICAL_ALIGNMENT_TOP;
  75394. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75395. private static _VERTICAL_ALIGNMENT_CENTER;
  75396. /** HORIZONTAL_ALIGNMENT_LEFT */
  75397. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75398. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75399. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75400. /** HORIZONTAL_ALIGNMENT_CENTER */
  75401. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75402. /** VERTICAL_ALIGNMENT_TOP */
  75403. static get VERTICAL_ALIGNMENT_TOP(): number;
  75404. /** VERTICAL_ALIGNMENT_BOTTOM */
  75405. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75406. /** VERTICAL_ALIGNMENT_CENTER */
  75407. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75408. private static _FontHeightSizes;
  75409. /** @hidden */
  75410. static _GetFontOffset(font: string): {
  75411. ascent: number;
  75412. height: number;
  75413. descent: number;
  75414. };
  75415. /**
  75416. * Creates a stack panel that can be used to render headers
  75417. * @param control defines the control to associate with the header
  75418. * @param text defines the text of the header
  75419. * @param size defines the size of the header
  75420. * @param options defines options used to configure the header
  75421. * @returns a new StackPanel
  75422. * @ignore
  75423. * @hidden
  75424. */
  75425. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75426. isHorizontal: boolean;
  75427. controlFirst: boolean;
  75428. }) => any;
  75429. /** @hidden */
  75430. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75431. }
  75432. }
  75433. declare module BABYLON.GUI {
  75434. /**
  75435. * Root class for 2D containers
  75436. * @see http://doc.babylonjs.com/how_to/gui#containers
  75437. */
  75438. export class Container extends Control {
  75439. name?: string | undefined;
  75440. /** @hidden */
  75441. _children: Control[];
  75442. /** @hidden */
  75443. protected _measureForChildren: Measure;
  75444. /** @hidden */
  75445. protected _background: string;
  75446. /** @hidden */
  75447. protected _adaptWidthToChildren: boolean;
  75448. /** @hidden */
  75449. protected _adaptHeightToChildren: boolean;
  75450. /**
  75451. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75452. */
  75453. logLayoutCycleErrors: boolean;
  75454. /**
  75455. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75456. */
  75457. maxLayoutCycle: number;
  75458. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75459. get adaptHeightToChildren(): boolean;
  75460. set adaptHeightToChildren(value: boolean);
  75461. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75462. get adaptWidthToChildren(): boolean;
  75463. set adaptWidthToChildren(value: boolean);
  75464. /** Gets or sets background color */
  75465. get background(): string;
  75466. set background(value: string);
  75467. /** Gets the list of children */
  75468. get children(): Control[];
  75469. /**
  75470. * Creates a new Container
  75471. * @param name defines the name of the container
  75472. */
  75473. constructor(name?: string | undefined);
  75474. protected _getTypeName(): string;
  75475. _flagDescendantsAsMatrixDirty(): void;
  75476. /**
  75477. * Gets a child using its name
  75478. * @param name defines the child name to look for
  75479. * @returns the child control if found
  75480. */
  75481. getChildByName(name: string): BABYLON.Nullable<Control>;
  75482. /**
  75483. * Gets a child using its type and its name
  75484. * @param name defines the child name to look for
  75485. * @param type defines the child type to look for
  75486. * @returns the child control if found
  75487. */
  75488. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75489. /**
  75490. * Search for a specific control in children
  75491. * @param control defines the control to look for
  75492. * @returns true if the control is in child list
  75493. */
  75494. containsControl(control: Control): boolean;
  75495. /**
  75496. * Adds a new control to the current container
  75497. * @param control defines the control to add
  75498. * @returns the current container
  75499. */
  75500. addControl(control: BABYLON.Nullable<Control>): Container;
  75501. /**
  75502. * Removes all controls from the current container
  75503. * @returns the current container
  75504. */
  75505. clearControls(): Container;
  75506. /**
  75507. * Removes a control from the current container
  75508. * @param control defines the control to remove
  75509. * @returns the current container
  75510. */
  75511. removeControl(control: Control): Container;
  75512. /** @hidden */
  75513. _reOrderControl(control: Control): void;
  75514. /** @hidden */
  75515. _offsetLeft(offset: number): void;
  75516. /** @hidden */
  75517. _offsetTop(offset: number): void;
  75518. /** @hidden */
  75519. _markAllAsDirty(): void;
  75520. /** @hidden */
  75521. protected _localDraw(context: CanvasRenderingContext2D): void;
  75522. /** @hidden */
  75523. _link(host: AdvancedDynamicTexture): void;
  75524. /** @hidden */
  75525. protected _beforeLayout(): void;
  75526. /** @hidden */
  75527. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75528. /** @hidden */
  75529. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75530. protected _postMeasure(): void;
  75531. /** @hidden */
  75532. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75533. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75534. /** @hidden */
  75535. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75536. /** @hidden */
  75537. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75538. /** Releases associated resources */
  75539. dispose(): void;
  75540. }
  75541. }
  75542. declare module BABYLON.GUI {
  75543. /** Class used to create rectangle container */
  75544. export class Rectangle extends Container {
  75545. name?: string | undefined;
  75546. private _thickness;
  75547. private _cornerRadius;
  75548. /** Gets or sets border thickness */
  75549. get thickness(): number;
  75550. set thickness(value: number);
  75551. /** Gets or sets the corner radius angle */
  75552. get cornerRadius(): number;
  75553. set cornerRadius(value: number);
  75554. /**
  75555. * Creates a new Rectangle
  75556. * @param name defines the control name
  75557. */
  75558. constructor(name?: string | undefined);
  75559. protected _getTypeName(): string;
  75560. protected _localDraw(context: CanvasRenderingContext2D): void;
  75561. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75562. private _drawRoundedRect;
  75563. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75564. }
  75565. }
  75566. declare module BABYLON.GUI {
  75567. /**
  75568. * Enum that determines the text-wrapping mode to use.
  75569. */
  75570. export enum TextWrapping {
  75571. /**
  75572. * Clip the text when it's larger than Control.width; this is the default mode.
  75573. */
  75574. Clip = 0,
  75575. /**
  75576. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75577. */
  75578. WordWrap = 1,
  75579. /**
  75580. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75581. */
  75582. Ellipsis = 2
  75583. }
  75584. /**
  75585. * Class used to create text block control
  75586. */
  75587. export class TextBlock extends Control {
  75588. /**
  75589. * Defines the name of the control
  75590. */
  75591. name?: string | undefined;
  75592. private _text;
  75593. private _textWrapping;
  75594. private _textHorizontalAlignment;
  75595. private _textVerticalAlignment;
  75596. private _lines;
  75597. private _resizeToFit;
  75598. private _lineSpacing;
  75599. private _outlineWidth;
  75600. private _outlineColor;
  75601. /**
  75602. * An event triggered after the text is changed
  75603. */
  75604. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75605. /**
  75606. * An event triggered after the text was broken up into lines
  75607. */
  75608. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75609. /**
  75610. * Function used to split a string into words. By default, a string is split at each space character found
  75611. */
  75612. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75613. /**
  75614. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75615. */
  75616. get lines(): any[];
  75617. /**
  75618. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75619. */
  75620. get resizeToFit(): boolean;
  75621. /**
  75622. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75623. */
  75624. set resizeToFit(value: boolean);
  75625. /**
  75626. * Gets or sets a boolean indicating if text must be wrapped
  75627. */
  75628. get textWrapping(): TextWrapping | boolean;
  75629. /**
  75630. * Gets or sets a boolean indicating if text must be wrapped
  75631. */
  75632. set textWrapping(value: TextWrapping | boolean);
  75633. /**
  75634. * Gets or sets text to display
  75635. */
  75636. get text(): string;
  75637. /**
  75638. * Gets or sets text to display
  75639. */
  75640. set text(value: string);
  75641. /**
  75642. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75643. */
  75644. get textHorizontalAlignment(): number;
  75645. /**
  75646. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75647. */
  75648. set textHorizontalAlignment(value: number);
  75649. /**
  75650. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75651. */
  75652. get textVerticalAlignment(): number;
  75653. /**
  75654. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75655. */
  75656. set textVerticalAlignment(value: number);
  75657. /**
  75658. * Gets or sets line spacing value
  75659. */
  75660. set lineSpacing(value: string | number);
  75661. /**
  75662. * Gets or sets line spacing value
  75663. */
  75664. get lineSpacing(): string | number;
  75665. /**
  75666. * Gets or sets outlineWidth of the text to display
  75667. */
  75668. get outlineWidth(): number;
  75669. /**
  75670. * Gets or sets outlineWidth of the text to display
  75671. */
  75672. set outlineWidth(value: number);
  75673. /**
  75674. * Gets or sets outlineColor of the text to display
  75675. */
  75676. get outlineColor(): string;
  75677. /**
  75678. * Gets or sets outlineColor of the text to display
  75679. */
  75680. set outlineColor(value: string);
  75681. /**
  75682. * Creates a new TextBlock object
  75683. * @param name defines the name of the control
  75684. * @param text defines the text to display (emptry string by default)
  75685. */
  75686. constructor(
  75687. /**
  75688. * Defines the name of the control
  75689. */
  75690. name?: string | undefined, text?: string);
  75691. protected _getTypeName(): string;
  75692. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75693. private _drawText;
  75694. /** @hidden */
  75695. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75696. protected _applyStates(context: CanvasRenderingContext2D): void;
  75697. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75698. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75699. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75700. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75701. protected _renderLines(context: CanvasRenderingContext2D): void;
  75702. /**
  75703. * Given a width constraint applied on the text block, find the expected height
  75704. * @returns expected height
  75705. */
  75706. computeExpectedHeight(): number;
  75707. dispose(): void;
  75708. }
  75709. }
  75710. declare module BABYLON.GUI {
  75711. /**
  75712. * Class used to create 2D images
  75713. */
  75714. export class Image extends Control {
  75715. name?: string | undefined;
  75716. private _workingCanvas;
  75717. private _domImage;
  75718. private _imageWidth;
  75719. private _imageHeight;
  75720. private _loaded;
  75721. private _stretch;
  75722. private _source;
  75723. private _autoScale;
  75724. private _sourceLeft;
  75725. private _sourceTop;
  75726. private _sourceWidth;
  75727. private _sourceHeight;
  75728. private _svgAttributesComputationCompleted;
  75729. private _isSVG;
  75730. private _cellWidth;
  75731. private _cellHeight;
  75732. private _cellId;
  75733. private _populateNinePatchSlicesFromImage;
  75734. private _sliceLeft;
  75735. private _sliceRight;
  75736. private _sliceTop;
  75737. private _sliceBottom;
  75738. private _detectPointerOnOpaqueOnly;
  75739. /**
  75740. * BABYLON.Observable notified when the content is loaded
  75741. */
  75742. onImageLoadedObservable: BABYLON.Observable<Image>;
  75743. /**
  75744. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75745. */
  75746. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75747. /**
  75748. * Gets a boolean indicating that the content is loaded
  75749. */
  75750. get isLoaded(): boolean;
  75751. /**
  75752. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75753. */
  75754. get populateNinePatchSlicesFromImage(): boolean;
  75755. set populateNinePatchSlicesFromImage(value: boolean);
  75756. /**
  75757. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75758. * Beware using this as this will comsume more memory as the image has to be stored twice
  75759. */
  75760. get detectPointerOnOpaqueOnly(): boolean;
  75761. set detectPointerOnOpaqueOnly(value: boolean);
  75762. /**
  75763. * Gets or sets the left value for slicing (9-patch)
  75764. */
  75765. get sliceLeft(): number;
  75766. set sliceLeft(value: number);
  75767. /**
  75768. * Gets or sets the right value for slicing (9-patch)
  75769. */
  75770. get sliceRight(): number;
  75771. set sliceRight(value: number);
  75772. /**
  75773. * Gets or sets the top value for slicing (9-patch)
  75774. */
  75775. get sliceTop(): number;
  75776. set sliceTop(value: number);
  75777. /**
  75778. * Gets or sets the bottom value for slicing (9-patch)
  75779. */
  75780. get sliceBottom(): number;
  75781. set sliceBottom(value: number);
  75782. /**
  75783. * Gets or sets the left coordinate in the source image
  75784. */
  75785. get sourceLeft(): number;
  75786. set sourceLeft(value: number);
  75787. /**
  75788. * Gets or sets the top coordinate in the source image
  75789. */
  75790. get sourceTop(): number;
  75791. set sourceTop(value: number);
  75792. /**
  75793. * Gets or sets the width to capture in the source image
  75794. */
  75795. get sourceWidth(): number;
  75796. set sourceWidth(value: number);
  75797. /**
  75798. * Gets or sets the height to capture in the source image
  75799. */
  75800. get sourceHeight(): number;
  75801. set sourceHeight(value: number);
  75802. /** Indicates if the format of the image is SVG */
  75803. get isSVG(): boolean;
  75804. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75805. get svgAttributesComputationCompleted(): boolean;
  75806. /**
  75807. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75808. * @see http://doc.babylonjs.com/how_to/gui#image
  75809. */
  75810. get autoScale(): boolean;
  75811. set autoScale(value: boolean);
  75812. /** Gets or sets the streching mode used by the image */
  75813. get stretch(): number;
  75814. set stretch(value: number);
  75815. /** @hidden */
  75816. _rotate90(n: number, preserveProperties?: boolean): Image;
  75817. private _handleRotationForSVGImage;
  75818. private _rotate90SourceProperties;
  75819. /**
  75820. * Gets or sets the internal DOM image used to render the control
  75821. */
  75822. set domImage(value: HTMLImageElement);
  75823. get domImage(): HTMLImageElement;
  75824. private _onImageLoaded;
  75825. private _extractNinePatchSliceDataFromImage;
  75826. /**
  75827. * Gets or sets image source url
  75828. */
  75829. set source(value: BABYLON.Nullable<string>);
  75830. /**
  75831. * Checks for svg document with icon id present
  75832. */
  75833. private _svgCheck;
  75834. /**
  75835. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75836. * given external svg file and icon id
  75837. */
  75838. private _getSVGAttribs;
  75839. /**
  75840. * Gets or sets the cell width to use when animation sheet is enabled
  75841. * @see http://doc.babylonjs.com/how_to/gui#image
  75842. */
  75843. get cellWidth(): number;
  75844. set cellWidth(value: number);
  75845. /**
  75846. * Gets or sets the cell height to use when animation sheet is enabled
  75847. * @see http://doc.babylonjs.com/how_to/gui#image
  75848. */
  75849. get cellHeight(): number;
  75850. set cellHeight(value: number);
  75851. /**
  75852. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75853. * @see http://doc.babylonjs.com/how_to/gui#image
  75854. */
  75855. get cellId(): number;
  75856. set cellId(value: number);
  75857. /**
  75858. * Creates a new Image
  75859. * @param name defines the control name
  75860. * @param url defines the image url
  75861. */
  75862. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75863. /**
  75864. * Tests if a given coordinates belong to the current control
  75865. * @param x defines x coordinate to test
  75866. * @param y defines y coordinate to test
  75867. * @returns true if the coordinates are inside the control
  75868. */
  75869. contains(x: number, y: number): boolean;
  75870. protected _getTypeName(): string;
  75871. /** Force the control to synchronize with its content */
  75872. synchronizeSizeWithContent(): void;
  75873. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75874. private _prepareWorkingCanvasForOpaqueDetection;
  75875. private _drawImage;
  75876. _draw(context: CanvasRenderingContext2D): void;
  75877. private _renderCornerPatch;
  75878. private _renderNinePatch;
  75879. dispose(): void;
  75880. /** STRETCH_NONE */
  75881. static readonly STRETCH_NONE: number;
  75882. /** STRETCH_FILL */
  75883. static readonly STRETCH_FILL: number;
  75884. /** STRETCH_UNIFORM */
  75885. static readonly STRETCH_UNIFORM: number;
  75886. /** STRETCH_EXTEND */
  75887. static readonly STRETCH_EXTEND: number;
  75888. /** NINE_PATCH */
  75889. static readonly STRETCH_NINE_PATCH: number;
  75890. }
  75891. }
  75892. declare module BABYLON.GUI {
  75893. /**
  75894. * Class used to create 2D buttons
  75895. */
  75896. export class Button extends Rectangle {
  75897. name?: string | undefined;
  75898. /**
  75899. * Function called to generate a pointer enter animation
  75900. */
  75901. pointerEnterAnimation: () => void;
  75902. /**
  75903. * Function called to generate a pointer out animation
  75904. */
  75905. pointerOutAnimation: () => void;
  75906. /**
  75907. * Function called to generate a pointer down animation
  75908. */
  75909. pointerDownAnimation: () => void;
  75910. /**
  75911. * Function called to generate a pointer up animation
  75912. */
  75913. pointerUpAnimation: () => void;
  75914. /**
  75915. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75916. */
  75917. delegatePickingToChildren: boolean;
  75918. private _image;
  75919. /**
  75920. * Returns the image part of the button (if any)
  75921. */
  75922. get image(): BABYLON.Nullable<Image>;
  75923. private _textBlock;
  75924. /**
  75925. * Returns the image part of the button (if any)
  75926. */
  75927. get textBlock(): BABYLON.Nullable<TextBlock>;
  75928. /**
  75929. * Creates a new Button
  75930. * @param name defines the name of the button
  75931. */
  75932. constructor(name?: string | undefined);
  75933. protected _getTypeName(): string;
  75934. /** @hidden */
  75935. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75936. /** @hidden */
  75937. _onPointerEnter(target: Control): boolean;
  75938. /** @hidden */
  75939. _onPointerOut(target: Control, force?: boolean): void;
  75940. /** @hidden */
  75941. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75942. /** @hidden */
  75943. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75944. /**
  75945. * Creates a new button made with an image and a text
  75946. * @param name defines the name of the button
  75947. * @param text defines the text of the button
  75948. * @param imageUrl defines the url of the image
  75949. * @returns a new Button
  75950. */
  75951. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75952. /**
  75953. * Creates a new button made with an image
  75954. * @param name defines the name of the button
  75955. * @param imageUrl defines the url of the image
  75956. * @returns a new Button
  75957. */
  75958. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75959. /**
  75960. * Creates a new button made with a text
  75961. * @param name defines the name of the button
  75962. * @param text defines the text of the button
  75963. * @returns a new Button
  75964. */
  75965. static CreateSimpleButton(name: string, text: string): Button;
  75966. /**
  75967. * Creates a new button made with an image and a centered text
  75968. * @param name defines the name of the button
  75969. * @param text defines the text of the button
  75970. * @param imageUrl defines the url of the image
  75971. * @returns a new Button
  75972. */
  75973. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75974. }
  75975. }
  75976. declare module BABYLON.GUI {
  75977. /**
  75978. * Class used to create a 2D stack panel container
  75979. */
  75980. export class StackPanel extends Container {
  75981. name?: string | undefined;
  75982. private _isVertical;
  75983. private _manualWidth;
  75984. private _manualHeight;
  75985. private _doNotTrackManualChanges;
  75986. /**
  75987. * Gets or sets a boolean indicating that layou warnings should be ignored
  75988. */
  75989. ignoreLayoutWarnings: boolean;
  75990. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75991. get isVertical(): boolean;
  75992. set isVertical(value: boolean);
  75993. /**
  75994. * Gets or sets panel width.
  75995. * This value should not be set when in horizontal mode as it will be computed automatically
  75996. */
  75997. set width(value: string | number);
  75998. get width(): string | number;
  75999. /**
  76000. * Gets or sets panel height.
  76001. * This value should not be set when in vertical mode as it will be computed automatically
  76002. */
  76003. set height(value: string | number);
  76004. get height(): string | number;
  76005. /**
  76006. * Creates a new StackPanel
  76007. * @param name defines control name
  76008. */
  76009. constructor(name?: string | undefined);
  76010. protected _getTypeName(): string;
  76011. /** @hidden */
  76012. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76013. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76014. protected _postMeasure(): void;
  76015. }
  76016. }
  76017. declare module BABYLON.GUI {
  76018. /**
  76019. * Class used to represent a 2D checkbox
  76020. */
  76021. export class Checkbox extends Control {
  76022. name?: string | undefined;
  76023. private _isChecked;
  76024. private _background;
  76025. private _checkSizeRatio;
  76026. private _thickness;
  76027. /** Gets or sets border thickness */
  76028. get thickness(): number;
  76029. set thickness(value: number);
  76030. /**
  76031. * BABYLON.Observable raised when isChecked property changes
  76032. */
  76033. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76034. /** Gets or sets a value indicating the ratio between overall size and check size */
  76035. get checkSizeRatio(): number;
  76036. set checkSizeRatio(value: number);
  76037. /** Gets or sets background color */
  76038. get background(): string;
  76039. set background(value: string);
  76040. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76041. get isChecked(): boolean;
  76042. set isChecked(value: boolean);
  76043. /**
  76044. * Creates a new CheckBox
  76045. * @param name defines the control name
  76046. */
  76047. constructor(name?: string | undefined);
  76048. protected _getTypeName(): string;
  76049. /** @hidden */
  76050. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76051. /** @hidden */
  76052. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76053. /**
  76054. * Utility function to easily create a checkbox with a header
  76055. * @param title defines the label to use for the header
  76056. * @param onValueChanged defines the callback to call when value changes
  76057. * @returns a StackPanel containing the checkbox and a textBlock
  76058. */
  76059. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76060. }
  76061. }
  76062. declare module BABYLON.GUI {
  76063. /**
  76064. * Class used to store key control properties
  76065. */
  76066. export class KeyPropertySet {
  76067. /** Width */
  76068. width?: string;
  76069. /** Height */
  76070. height?: string;
  76071. /** Left padding */
  76072. paddingLeft?: string;
  76073. /** Right padding */
  76074. paddingRight?: string;
  76075. /** Top padding */
  76076. paddingTop?: string;
  76077. /** Bottom padding */
  76078. paddingBottom?: string;
  76079. /** Foreground color */
  76080. color?: string;
  76081. /** Background color */
  76082. background?: string;
  76083. }
  76084. /**
  76085. * Class used to create virtual keyboard
  76086. */
  76087. export class VirtualKeyboard extends StackPanel {
  76088. /** BABYLON.Observable raised when a key is pressed */
  76089. onKeyPressObservable: BABYLON.Observable<string>;
  76090. /** Gets or sets default key button width */
  76091. defaultButtonWidth: string;
  76092. /** Gets or sets default key button height */
  76093. defaultButtonHeight: string;
  76094. /** Gets or sets default key button left padding */
  76095. defaultButtonPaddingLeft: string;
  76096. /** Gets or sets default key button right padding */
  76097. defaultButtonPaddingRight: string;
  76098. /** Gets or sets default key button top padding */
  76099. defaultButtonPaddingTop: string;
  76100. /** Gets or sets default key button bottom padding */
  76101. defaultButtonPaddingBottom: string;
  76102. /** Gets or sets default key button foreground color */
  76103. defaultButtonColor: string;
  76104. /** Gets or sets default key button background color */
  76105. defaultButtonBackground: string;
  76106. /** Gets or sets shift button foreground color */
  76107. shiftButtonColor: string;
  76108. /** Gets or sets shift button thickness*/
  76109. selectedShiftThickness: number;
  76110. /** Gets shift key state */
  76111. shiftState: number;
  76112. protected _getTypeName(): string;
  76113. private _createKey;
  76114. /**
  76115. * Adds a new row of keys
  76116. * @param keys defines the list of keys to add
  76117. * @param propertySets defines the associated property sets
  76118. */
  76119. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76120. /**
  76121. * Set the shift key to a specific state
  76122. * @param shiftState defines the new shift state
  76123. */
  76124. applyShiftState(shiftState: number): void;
  76125. private _currentlyConnectedInputText;
  76126. private _connectedInputTexts;
  76127. private _onKeyPressObserver;
  76128. /** Gets the input text control currently attached to the keyboard */
  76129. get connectedInputText(): BABYLON.Nullable<InputText>;
  76130. /**
  76131. * Connects the keyboard with an input text control
  76132. *
  76133. * @param input defines the target control
  76134. */
  76135. connect(input: InputText): void;
  76136. /**
  76137. * Disconnects the keyboard from connected InputText controls
  76138. *
  76139. * @param input optionally defines a target control, otherwise all are disconnected
  76140. */
  76141. disconnect(input?: InputText): void;
  76142. private _removeConnectedInputObservables;
  76143. /**
  76144. * Release all resources
  76145. */
  76146. dispose(): void;
  76147. /**
  76148. * Creates a new keyboard using a default layout
  76149. *
  76150. * @param name defines control name
  76151. * @returns a new VirtualKeyboard
  76152. */
  76153. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76154. }
  76155. }
  76156. declare module BABYLON.GUI {
  76157. /**
  76158. * Class used to create input text control
  76159. */
  76160. export class InputText extends Control implements IFocusableControl {
  76161. name?: string | undefined;
  76162. private _text;
  76163. private _placeholderText;
  76164. private _background;
  76165. private _focusedBackground;
  76166. private _focusedColor;
  76167. private _placeholderColor;
  76168. private _thickness;
  76169. private _margin;
  76170. private _autoStretchWidth;
  76171. private _maxWidth;
  76172. private _isFocused;
  76173. private _blinkTimeout;
  76174. private _blinkIsEven;
  76175. private _cursorOffset;
  76176. private _scrollLeft;
  76177. private _textWidth;
  76178. private _clickedCoordinate;
  76179. private _deadKey;
  76180. private _addKey;
  76181. private _currentKey;
  76182. private _isTextHighlightOn;
  76183. private _textHighlightColor;
  76184. private _highligherOpacity;
  76185. private _highlightedText;
  76186. private _startHighlightIndex;
  76187. private _endHighlightIndex;
  76188. private _cursorIndex;
  76189. private _onFocusSelectAll;
  76190. private _isPointerDown;
  76191. private _onClipboardObserver;
  76192. private _onPointerDblTapObserver;
  76193. /** @hidden */
  76194. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76195. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76196. promptMessage: string;
  76197. /** Force disable prompt on mobile device */
  76198. disableMobilePrompt: boolean;
  76199. /** BABYLON.Observable raised when the text changes */
  76200. onTextChangedObservable: BABYLON.Observable<InputText>;
  76201. /** BABYLON.Observable raised just before an entered character is to be added */
  76202. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76203. /** BABYLON.Observable raised when the control gets the focus */
  76204. onFocusObservable: BABYLON.Observable<InputText>;
  76205. /** BABYLON.Observable raised when the control loses the focus */
  76206. onBlurObservable: BABYLON.Observable<InputText>;
  76207. /**Observable raised when the text is highlighted */
  76208. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76209. /**Observable raised when copy event is triggered */
  76210. onTextCopyObservable: BABYLON.Observable<InputText>;
  76211. /** BABYLON.Observable raised when cut event is triggered */
  76212. onTextCutObservable: BABYLON.Observable<InputText>;
  76213. /** BABYLON.Observable raised when paste event is triggered */
  76214. onTextPasteObservable: BABYLON.Observable<InputText>;
  76215. /** BABYLON.Observable raised when a key event was processed */
  76216. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76217. /** Gets or sets the maximum width allowed by the control */
  76218. get maxWidth(): string | number;
  76219. /** Gets the maximum width allowed by the control in pixels */
  76220. get maxWidthInPixels(): number;
  76221. set maxWidth(value: string | number);
  76222. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76223. get highligherOpacity(): number;
  76224. set highligherOpacity(value: number);
  76225. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76226. get onFocusSelectAll(): boolean;
  76227. set onFocusSelectAll(value: boolean);
  76228. /** Gets or sets the text hightlight color */
  76229. get textHighlightColor(): string;
  76230. set textHighlightColor(value: string);
  76231. /** Gets or sets control margin */
  76232. get margin(): string;
  76233. /** Gets control margin in pixels */
  76234. get marginInPixels(): number;
  76235. set margin(value: string);
  76236. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76237. get autoStretchWidth(): boolean;
  76238. set autoStretchWidth(value: boolean);
  76239. /** Gets or sets border thickness */
  76240. get thickness(): number;
  76241. set thickness(value: number);
  76242. /** Gets or sets the background color when focused */
  76243. get focusedBackground(): string;
  76244. set focusedBackground(value: string);
  76245. /** Gets or sets the background color when focused */
  76246. get focusedColor(): string;
  76247. set focusedColor(value: string);
  76248. /** Gets or sets the background color */
  76249. get background(): string;
  76250. set background(value: string);
  76251. /** Gets or sets the placeholder color */
  76252. get placeholderColor(): string;
  76253. set placeholderColor(value: string);
  76254. /** Gets or sets the text displayed when the control is empty */
  76255. get placeholderText(): string;
  76256. set placeholderText(value: string);
  76257. /** Gets or sets the dead key flag */
  76258. get deadKey(): boolean;
  76259. set deadKey(flag: boolean);
  76260. /** Gets or sets the highlight text */
  76261. get highlightedText(): string;
  76262. set highlightedText(text: string);
  76263. /** Gets or sets if the current key should be added */
  76264. get addKey(): boolean;
  76265. set addKey(flag: boolean);
  76266. /** Gets or sets the value of the current key being entered */
  76267. get currentKey(): string;
  76268. set currentKey(key: string);
  76269. /** Gets or sets the text displayed in the control */
  76270. get text(): string;
  76271. set text(value: string);
  76272. /** Gets or sets control width */
  76273. get width(): string | number;
  76274. set width(value: string | number);
  76275. /**
  76276. * Creates a new InputText
  76277. * @param name defines the control name
  76278. * @param text defines the text of the control
  76279. */
  76280. constructor(name?: string | undefined, text?: string);
  76281. /** @hidden */
  76282. onBlur(): void;
  76283. /** @hidden */
  76284. onFocus(): void;
  76285. protected _getTypeName(): string;
  76286. /**
  76287. * Function called to get the list of controls that should not steal the focus from this control
  76288. * @returns an array of controls
  76289. */
  76290. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76291. /** @hidden */
  76292. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76293. /** @hidden */
  76294. private _updateValueFromCursorIndex;
  76295. /** @hidden */
  76296. private _processDblClick;
  76297. /** @hidden */
  76298. private _selectAllText;
  76299. /**
  76300. * Handles the keyboard event
  76301. * @param evt Defines the KeyboardEvent
  76302. */
  76303. processKeyboard(evt: KeyboardEvent): void;
  76304. /** @hidden */
  76305. private _onCopyText;
  76306. /** @hidden */
  76307. private _onCutText;
  76308. /** @hidden */
  76309. private _onPasteText;
  76310. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76311. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76312. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76313. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76314. protected _beforeRenderText(text: string): string;
  76315. dispose(): void;
  76316. }
  76317. }
  76318. declare module BABYLON.GUI {
  76319. /**
  76320. * Class used to create a 2D grid container
  76321. */
  76322. export class Grid extends Container {
  76323. name?: string | undefined;
  76324. private _rowDefinitions;
  76325. private _columnDefinitions;
  76326. private _cells;
  76327. private _childControls;
  76328. /**
  76329. * Gets the number of columns
  76330. */
  76331. get columnCount(): number;
  76332. /**
  76333. * Gets the number of rows
  76334. */
  76335. get rowCount(): number;
  76336. /** Gets the list of children */
  76337. get children(): Control[];
  76338. /** Gets the list of cells (e.g. the containers) */
  76339. get cells(): {
  76340. [key: string]: Container;
  76341. };
  76342. /**
  76343. * Gets the definition of a specific row
  76344. * @param index defines the index of the row
  76345. * @returns the row definition
  76346. */
  76347. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76348. /**
  76349. * Gets the definition of a specific column
  76350. * @param index defines the index of the column
  76351. * @returns the column definition
  76352. */
  76353. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76354. /**
  76355. * Adds a new row to the grid
  76356. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76357. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76358. * @returns the current grid
  76359. */
  76360. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76361. /**
  76362. * Adds a new column to the grid
  76363. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76364. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76365. * @returns the current grid
  76366. */
  76367. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76368. /**
  76369. * Update a row definition
  76370. * @param index defines the index of the row to update
  76371. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76372. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76373. * @returns the current grid
  76374. */
  76375. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76376. /**
  76377. * Update a column definition
  76378. * @param index defines the index of the column to update
  76379. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76380. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76381. * @returns the current grid
  76382. */
  76383. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76384. /**
  76385. * Gets the list of children stored in a specific cell
  76386. * @param row defines the row to check
  76387. * @param column defines the column to check
  76388. * @returns the list of controls
  76389. */
  76390. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76391. /**
  76392. * Gets a string representing the child cell info (row x column)
  76393. * @param child defines the control to get info from
  76394. * @returns a string containing the child cell info (row x column)
  76395. */
  76396. getChildCellInfo(child: Control): string;
  76397. private _removeCell;
  76398. private _offsetCell;
  76399. /**
  76400. * Remove a column definition at specified index
  76401. * @param index defines the index of the column to remove
  76402. * @returns the current grid
  76403. */
  76404. removeColumnDefinition(index: number): Grid;
  76405. /**
  76406. * Remove a row definition at specified index
  76407. * @param index defines the index of the row to remove
  76408. * @returns the current grid
  76409. */
  76410. removeRowDefinition(index: number): Grid;
  76411. /**
  76412. * Adds a new control to the current grid
  76413. * @param control defines the control to add
  76414. * @param row defines the row where to add the control (0 by default)
  76415. * @param column defines the column where to add the control (0 by default)
  76416. * @returns the current grid
  76417. */
  76418. addControl(control: Control, row?: number, column?: number): Grid;
  76419. /**
  76420. * Removes a control from the current container
  76421. * @param control defines the control to remove
  76422. * @returns the current container
  76423. */
  76424. removeControl(control: Control): Container;
  76425. /**
  76426. * Creates a new Grid
  76427. * @param name defines control name
  76428. */
  76429. constructor(name?: string | undefined);
  76430. protected _getTypeName(): string;
  76431. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76432. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76433. _flagDescendantsAsMatrixDirty(): void;
  76434. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76435. /** Releases associated resources */
  76436. dispose(): void;
  76437. }
  76438. }
  76439. declare module BABYLON.GUI {
  76440. /** Class used to create color pickers */
  76441. export class ColorPicker extends Control {
  76442. name?: string | undefined;
  76443. private static _Epsilon;
  76444. private _colorWheelCanvas;
  76445. private _value;
  76446. private _tmpColor;
  76447. private _pointerStartedOnSquare;
  76448. private _pointerStartedOnWheel;
  76449. private _squareLeft;
  76450. private _squareTop;
  76451. private _squareSize;
  76452. private _h;
  76453. private _s;
  76454. private _v;
  76455. private _lastPointerDownID;
  76456. /**
  76457. * BABYLON.Observable raised when the value changes
  76458. */
  76459. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76460. /** Gets or sets the color of the color picker */
  76461. get value(): BABYLON.Color3;
  76462. set value(value: BABYLON.Color3);
  76463. /**
  76464. * Gets or sets control width
  76465. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76466. */
  76467. get width(): string | number;
  76468. set width(value: string | number);
  76469. /**
  76470. * Gets or sets control height
  76471. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76472. */
  76473. get height(): string | number;
  76474. /** Gets or sets control height */
  76475. set height(value: string | number);
  76476. /** Gets or sets control size */
  76477. get size(): string | number;
  76478. set size(value: string | number);
  76479. /**
  76480. * Creates a new ColorPicker
  76481. * @param name defines the control name
  76482. */
  76483. constructor(name?: string | undefined);
  76484. protected _getTypeName(): string;
  76485. /** @hidden */
  76486. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76487. private _updateSquareProps;
  76488. private _drawGradientSquare;
  76489. private _drawCircle;
  76490. private _createColorWheelCanvas;
  76491. /** @hidden */
  76492. _draw(context: CanvasRenderingContext2D): void;
  76493. private _pointerIsDown;
  76494. private _updateValueFromPointer;
  76495. private _isPointOnSquare;
  76496. private _isPointOnWheel;
  76497. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76498. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76499. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76500. /**
  76501. * This function expands the color picker by creating a color picker dialog with manual
  76502. * color value input and the ability to save colors into an array to be used later in
  76503. * subsequent launches of the dialogue.
  76504. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76505. * @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.
  76506. * @returns picked color as a hex string and the saved colors array as hex strings.
  76507. */
  76508. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76509. pickerWidth?: string;
  76510. pickerHeight?: string;
  76511. headerHeight?: string;
  76512. lastColor?: string;
  76513. swatchLimit?: number;
  76514. numSwatchesPerLine?: number;
  76515. savedColors?: Array<string>;
  76516. }): Promise<{
  76517. savedColors?: string[];
  76518. pickedColor: string;
  76519. }>;
  76520. }
  76521. }
  76522. declare module BABYLON.GUI {
  76523. /** Class used to create 2D ellipse containers */
  76524. export class Ellipse extends Container {
  76525. name?: string | undefined;
  76526. private _thickness;
  76527. /** Gets or sets border thickness */
  76528. get thickness(): number;
  76529. set thickness(value: number);
  76530. /**
  76531. * Creates a new Ellipse
  76532. * @param name defines the control name
  76533. */
  76534. constructor(name?: string | undefined);
  76535. protected _getTypeName(): string;
  76536. protected _localDraw(context: CanvasRenderingContext2D): void;
  76537. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76538. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76539. }
  76540. }
  76541. declare module BABYLON.GUI {
  76542. /**
  76543. * Class used to create a password control
  76544. */
  76545. export class InputPassword extends InputText {
  76546. protected _beforeRenderText(text: string): string;
  76547. }
  76548. }
  76549. declare module BABYLON.GUI {
  76550. /** Class used to render 2D lines */
  76551. export class Line extends Control {
  76552. name?: string | undefined;
  76553. private _lineWidth;
  76554. private _x1;
  76555. private _y1;
  76556. private _x2;
  76557. private _y2;
  76558. private _dash;
  76559. private _connectedControl;
  76560. private _connectedControlDirtyObserver;
  76561. /** Gets or sets the dash pattern */
  76562. get dash(): Array<number>;
  76563. set dash(value: Array<number>);
  76564. /** Gets or sets the control connected with the line end */
  76565. get connectedControl(): Control;
  76566. set connectedControl(value: Control);
  76567. /** Gets or sets start coordinates on X axis */
  76568. get x1(): string | number;
  76569. set x1(value: string | number);
  76570. /** Gets or sets start coordinates on Y axis */
  76571. get y1(): string | number;
  76572. set y1(value: string | number);
  76573. /** Gets or sets end coordinates on X axis */
  76574. get x2(): string | number;
  76575. set x2(value: string | number);
  76576. /** Gets or sets end coordinates on Y axis */
  76577. get y2(): string | number;
  76578. set y2(value: string | number);
  76579. /** Gets or sets line width */
  76580. get lineWidth(): number;
  76581. set lineWidth(value: number);
  76582. /** Gets or sets horizontal alignment */
  76583. set horizontalAlignment(value: number);
  76584. /** Gets or sets vertical alignment */
  76585. set verticalAlignment(value: number);
  76586. private get _effectiveX2();
  76587. private get _effectiveY2();
  76588. /**
  76589. * Creates a new Line
  76590. * @param name defines the control name
  76591. */
  76592. constructor(name?: string | undefined);
  76593. protected _getTypeName(): string;
  76594. _draw(context: CanvasRenderingContext2D): void;
  76595. _measure(): void;
  76596. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76597. /**
  76598. * Move one end of the line given 3D cartesian coordinates.
  76599. * @param position Targeted world position
  76600. * @param scene BABYLON.Scene
  76601. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76602. */
  76603. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76604. /**
  76605. * Move one end of the line to a position in screen absolute space.
  76606. * @param projectedPosition Position in screen absolute space (X, Y)
  76607. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76608. */
  76609. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76610. }
  76611. }
  76612. declare module BABYLON.GUI {
  76613. /**
  76614. * Class used to store a point for a MultiLine object.
  76615. * The point can be pure 2D coordinates, a mesh or a control
  76616. */
  76617. export class MultiLinePoint {
  76618. private _multiLine;
  76619. private _x;
  76620. private _y;
  76621. private _control;
  76622. private _mesh;
  76623. private _controlObserver;
  76624. private _meshObserver;
  76625. /** @hidden */
  76626. _point: BABYLON.Vector2;
  76627. /**
  76628. * Creates a new MultiLinePoint
  76629. * @param multiLine defines the source MultiLine object
  76630. */
  76631. constructor(multiLine: MultiLine);
  76632. /** Gets or sets x coordinate */
  76633. get x(): string | number;
  76634. set x(value: string | number);
  76635. /** Gets or sets y coordinate */
  76636. get y(): string | number;
  76637. set y(value: string | number);
  76638. /** Gets or sets the control associated with this point */
  76639. get control(): BABYLON.Nullable<Control>;
  76640. set control(value: BABYLON.Nullable<Control>);
  76641. /** Gets or sets the mesh associated with this point */
  76642. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76643. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76644. /** Resets links */
  76645. resetLinks(): void;
  76646. /**
  76647. * Gets a translation vector
  76648. * @returns the translation vector
  76649. */
  76650. translate(): BABYLON.Vector2;
  76651. private _translatePoint;
  76652. /** Release associated resources */
  76653. dispose(): void;
  76654. }
  76655. }
  76656. declare module BABYLON.GUI {
  76657. /**
  76658. * Class used to create multi line control
  76659. */
  76660. export class MultiLine extends Control {
  76661. name?: string | undefined;
  76662. private _lineWidth;
  76663. private _dash;
  76664. private _points;
  76665. private _minX;
  76666. private _minY;
  76667. private _maxX;
  76668. private _maxY;
  76669. /**
  76670. * Creates a new MultiLine
  76671. * @param name defines the control name
  76672. */
  76673. constructor(name?: string | undefined);
  76674. /** Gets or sets dash pattern */
  76675. get dash(): Array<number>;
  76676. set dash(value: Array<number>);
  76677. /**
  76678. * Gets point stored at specified index
  76679. * @param index defines the index to look for
  76680. * @returns the requested point if found
  76681. */
  76682. getAt(index: number): MultiLinePoint;
  76683. /** Function called when a point is updated */
  76684. onPointUpdate: () => void;
  76685. /**
  76686. * Adds new points to the point collection
  76687. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76688. * @returns the list of created MultiLinePoint
  76689. */
  76690. add(...items: (AbstractMesh | Control | {
  76691. x: string | number;
  76692. y: string | number;
  76693. })[]): MultiLinePoint[];
  76694. /**
  76695. * Adds a new point to the point collection
  76696. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76697. * @returns the created MultiLinePoint
  76698. */
  76699. push(item?: (AbstractMesh | Control | {
  76700. x: string | number;
  76701. y: string | number;
  76702. })): MultiLinePoint;
  76703. /**
  76704. * Remove a specific value or point from the active point collection
  76705. * @param value defines the value or point to remove
  76706. */
  76707. remove(value: number | MultiLinePoint): void;
  76708. /**
  76709. * Resets this object to initial state (no point)
  76710. */
  76711. reset(): void;
  76712. /**
  76713. * Resets all links
  76714. */
  76715. resetLinks(): void;
  76716. /** Gets or sets line width */
  76717. get lineWidth(): number;
  76718. set lineWidth(value: number);
  76719. set horizontalAlignment(value: number);
  76720. set verticalAlignment(value: number);
  76721. protected _getTypeName(): string;
  76722. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76723. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76724. _measure(): void;
  76725. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76726. dispose(): void;
  76727. }
  76728. }
  76729. declare module BABYLON.GUI {
  76730. /**
  76731. * Class used to create radio button controls
  76732. */
  76733. export class RadioButton extends Control {
  76734. name?: string | undefined;
  76735. private _isChecked;
  76736. private _background;
  76737. private _checkSizeRatio;
  76738. private _thickness;
  76739. /** Gets or sets border thickness */
  76740. get thickness(): number;
  76741. set thickness(value: number);
  76742. /** Gets or sets group name */
  76743. group: string;
  76744. /** BABYLON.Observable raised when isChecked is changed */
  76745. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76746. /** Gets or sets a value indicating the ratio between overall size and check size */
  76747. get checkSizeRatio(): number;
  76748. set checkSizeRatio(value: number);
  76749. /** Gets or sets background color */
  76750. get background(): string;
  76751. set background(value: string);
  76752. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76753. get isChecked(): boolean;
  76754. set isChecked(value: boolean);
  76755. /**
  76756. * Creates a new RadioButton
  76757. * @param name defines the control name
  76758. */
  76759. constructor(name?: string | undefined);
  76760. protected _getTypeName(): string;
  76761. _draw(context: CanvasRenderingContext2D): void;
  76762. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76763. /**
  76764. * Utility function to easily create a radio button with a header
  76765. * @param title defines the label to use for the header
  76766. * @param group defines the group to use for the radio button
  76767. * @param isChecked defines the initial state of the radio button
  76768. * @param onValueChanged defines the callback to call when value changes
  76769. * @returns a StackPanel containing the radio button and a textBlock
  76770. */
  76771. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76772. }
  76773. }
  76774. declare module BABYLON.GUI {
  76775. /**
  76776. * Class used to create slider controls
  76777. */
  76778. export class BaseSlider extends Control {
  76779. name?: string | undefined;
  76780. protected _thumbWidth: ValueAndUnit;
  76781. private _minimum;
  76782. private _maximum;
  76783. private _value;
  76784. private _isVertical;
  76785. protected _barOffset: ValueAndUnit;
  76786. private _isThumbClamped;
  76787. protected _displayThumb: boolean;
  76788. private _step;
  76789. private _lastPointerDownID;
  76790. protected _effectiveBarOffset: number;
  76791. protected _renderLeft: number;
  76792. protected _renderTop: number;
  76793. protected _renderWidth: number;
  76794. protected _renderHeight: number;
  76795. protected _backgroundBoxLength: number;
  76796. protected _backgroundBoxThickness: number;
  76797. protected _effectiveThumbThickness: number;
  76798. /** BABYLON.Observable raised when the sldier value changes */
  76799. onValueChangedObservable: BABYLON.Observable<number>;
  76800. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76801. get displayThumb(): boolean;
  76802. set displayThumb(value: boolean);
  76803. /** Gets or sets a step to apply to values (0 by default) */
  76804. get step(): number;
  76805. set step(value: number);
  76806. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76807. get barOffset(): string | number;
  76808. /** Gets main bar offset in pixels*/
  76809. get barOffsetInPixels(): number;
  76810. set barOffset(value: string | number);
  76811. /** Gets or sets thumb width */
  76812. get thumbWidth(): string | number;
  76813. /** Gets thumb width in pixels */
  76814. get thumbWidthInPixels(): number;
  76815. set thumbWidth(value: string | number);
  76816. /** Gets or sets minimum value */
  76817. get minimum(): number;
  76818. set minimum(value: number);
  76819. /** Gets or sets maximum value */
  76820. get maximum(): number;
  76821. set maximum(value: number);
  76822. /** Gets or sets current value */
  76823. get value(): number;
  76824. set value(value: number);
  76825. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76826. get isVertical(): boolean;
  76827. set isVertical(value: boolean);
  76828. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76829. get isThumbClamped(): boolean;
  76830. set isThumbClamped(value: boolean);
  76831. /**
  76832. * Creates a new BaseSlider
  76833. * @param name defines the control name
  76834. */
  76835. constructor(name?: string | undefined);
  76836. protected _getTypeName(): string;
  76837. protected _getThumbPosition(): number;
  76838. protected _getThumbThickness(type: string): number;
  76839. protected _prepareRenderingData(type: string): void;
  76840. private _pointerIsDown;
  76841. /** @hidden */
  76842. protected _updateValueFromPointer(x: number, y: number): void;
  76843. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76844. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76845. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76846. }
  76847. }
  76848. declare module BABYLON.GUI {
  76849. /**
  76850. * Class used to create slider controls
  76851. */
  76852. export class Slider extends BaseSlider {
  76853. name?: string | undefined;
  76854. private _background;
  76855. private _borderColor;
  76856. private _isThumbCircle;
  76857. protected _displayValueBar: boolean;
  76858. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76859. get displayValueBar(): boolean;
  76860. set displayValueBar(value: boolean);
  76861. /** Gets or sets border color */
  76862. get borderColor(): string;
  76863. set borderColor(value: string);
  76864. /** Gets or sets background color */
  76865. get background(): string;
  76866. set background(value: string);
  76867. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76868. get isThumbCircle(): boolean;
  76869. set isThumbCircle(value: boolean);
  76870. /**
  76871. * Creates a new Slider
  76872. * @param name defines the control name
  76873. */
  76874. constructor(name?: string | undefined);
  76875. protected _getTypeName(): string;
  76876. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76877. }
  76878. }
  76879. declare module BABYLON.GUI {
  76880. /** Class used to create a RadioGroup
  76881. * which contains groups of radio buttons
  76882. */
  76883. export class SelectorGroup {
  76884. /** name of SelectorGroup */
  76885. name: string;
  76886. private _groupPanel;
  76887. private _selectors;
  76888. private _groupHeader;
  76889. /**
  76890. * Creates a new SelectorGroup
  76891. * @param name of group, used as a group heading
  76892. */
  76893. constructor(
  76894. /** name of SelectorGroup */
  76895. name: string);
  76896. /** Gets the groupPanel of the SelectorGroup */
  76897. get groupPanel(): StackPanel;
  76898. /** Gets the selectors array */
  76899. get selectors(): StackPanel[];
  76900. /** Gets and sets the group header */
  76901. get header(): string;
  76902. set header(label: string);
  76903. /** @hidden */
  76904. private _addGroupHeader;
  76905. /** @hidden*/
  76906. _getSelector(selectorNb: number): StackPanel | undefined;
  76907. /** Removes the selector at the given position
  76908. * @param selectorNb the position of the selector within the group
  76909. */
  76910. removeSelector(selectorNb: number): void;
  76911. }
  76912. /** Class used to create a CheckboxGroup
  76913. * which contains groups of checkbox buttons
  76914. */
  76915. export class CheckboxGroup extends SelectorGroup {
  76916. /** Adds a checkbox as a control
  76917. * @param text is the label for the selector
  76918. * @param func is the function called when the Selector is checked
  76919. * @param checked is true when Selector is checked
  76920. */
  76921. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76922. /** @hidden */
  76923. _setSelectorLabel(selectorNb: number, label: string): void;
  76924. /** @hidden */
  76925. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76926. /** @hidden */
  76927. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76928. /** @hidden */
  76929. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76930. }
  76931. /** Class used to create a RadioGroup
  76932. * which contains groups of radio buttons
  76933. */
  76934. export class RadioGroup extends SelectorGroup {
  76935. private _selectNb;
  76936. /** Adds a radio button as a control
  76937. * @param label is the label for the selector
  76938. * @param func is the function called when the Selector is checked
  76939. * @param checked is true when Selector is checked
  76940. */
  76941. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76942. /** @hidden */
  76943. _setSelectorLabel(selectorNb: number, label: string): void;
  76944. /** @hidden */
  76945. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76946. /** @hidden */
  76947. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76948. /** @hidden */
  76949. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76950. }
  76951. /** Class used to create a SliderGroup
  76952. * which contains groups of slider buttons
  76953. */
  76954. export class SliderGroup extends SelectorGroup {
  76955. /**
  76956. * Adds a slider to the SelectorGroup
  76957. * @param label is the label for the SliderBar
  76958. * @param func is the function called when the Slider moves
  76959. * @param unit is a string describing the units used, eg degrees or metres
  76960. * @param min is the minimum value for the Slider
  76961. * @param max is the maximum value for the Slider
  76962. * @param value is the start value for the Slider between min and max
  76963. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76964. */
  76965. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76966. /** @hidden */
  76967. _setSelectorLabel(selectorNb: number, label: string): void;
  76968. /** @hidden */
  76969. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76970. /** @hidden */
  76971. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76972. /** @hidden */
  76973. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76974. }
  76975. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76976. * @see http://doc.babylonjs.com/how_to/selector
  76977. */
  76978. export class SelectionPanel extends Rectangle {
  76979. /** name of SelectionPanel */
  76980. name: string;
  76981. /** an array of SelectionGroups */
  76982. groups: SelectorGroup[];
  76983. private _panel;
  76984. private _buttonColor;
  76985. private _buttonBackground;
  76986. private _headerColor;
  76987. private _barColor;
  76988. private _barHeight;
  76989. private _spacerHeight;
  76990. private _labelColor;
  76991. private _groups;
  76992. private _bars;
  76993. /**
  76994. * Creates a new SelectionPanel
  76995. * @param name of SelectionPanel
  76996. * @param groups is an array of SelectionGroups
  76997. */
  76998. constructor(
  76999. /** name of SelectionPanel */
  77000. name: string,
  77001. /** an array of SelectionGroups */
  77002. groups?: SelectorGroup[]);
  77003. protected _getTypeName(): string;
  77004. /** Gets or sets the headerColor */
  77005. get headerColor(): string;
  77006. set headerColor(color: string);
  77007. private _setHeaderColor;
  77008. /** Gets or sets the button color */
  77009. get buttonColor(): string;
  77010. set buttonColor(color: string);
  77011. private _setbuttonColor;
  77012. /** Gets or sets the label color */
  77013. get labelColor(): string;
  77014. set labelColor(color: string);
  77015. private _setLabelColor;
  77016. /** Gets or sets the button background */
  77017. get buttonBackground(): string;
  77018. set buttonBackground(color: string);
  77019. private _setButtonBackground;
  77020. /** Gets or sets the color of separator bar */
  77021. get barColor(): string;
  77022. set barColor(color: string);
  77023. private _setBarColor;
  77024. /** Gets or sets the height of separator bar */
  77025. get barHeight(): string;
  77026. set barHeight(value: string);
  77027. private _setBarHeight;
  77028. /** Gets or sets the height of spacers*/
  77029. get spacerHeight(): string;
  77030. set spacerHeight(value: string);
  77031. private _setSpacerHeight;
  77032. /** Adds a bar between groups */
  77033. private _addSpacer;
  77034. /** Add a group to the selection panel
  77035. * @param group is the selector group to add
  77036. */
  77037. addGroup(group: SelectorGroup): void;
  77038. /** Remove the group from the given position
  77039. * @param groupNb is the position of the group in the list
  77040. */
  77041. removeGroup(groupNb: number): void;
  77042. /** Change a group header label
  77043. * @param label is the new group header label
  77044. * @param groupNb is the number of the group to relabel
  77045. * */
  77046. setHeaderName(label: string, groupNb: number): void;
  77047. /** Change selector label to the one given
  77048. * @param label is the new selector label
  77049. * @param groupNb is the number of the groupcontaining the selector
  77050. * @param selectorNb is the number of the selector within a group to relabel
  77051. * */
  77052. relabel(label: string, groupNb: number, selectorNb: number): void;
  77053. /** For a given group position remove the selector at the given position
  77054. * @param groupNb is the number of the group to remove the selector from
  77055. * @param selectorNb is the number of the selector within the group
  77056. */
  77057. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77058. /** For a given group position of correct type add a checkbox button
  77059. * @param groupNb is the number of the group to remove the selector from
  77060. * @param label is the label for the selector
  77061. * @param func is the function called when the Selector is checked
  77062. * @param checked is true when Selector is checked
  77063. */
  77064. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77065. /** For a given group position of correct type add a radio button
  77066. * @param groupNb is the number of the group to remove the selector from
  77067. * @param label is the label for the selector
  77068. * @param func is the function called when the Selector is checked
  77069. * @param checked is true when Selector is checked
  77070. */
  77071. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77072. /**
  77073. * For a given slider group add a slider
  77074. * @param groupNb is the number of the group to add the slider to
  77075. * @param label is the label for the Slider
  77076. * @param func is the function called when the Slider moves
  77077. * @param unit is a string describing the units used, eg degrees or metres
  77078. * @param min is the minimum value for the Slider
  77079. * @param max is the maximum value for the Slider
  77080. * @param value is the start value for the Slider between min and max
  77081. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77082. */
  77083. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77084. }
  77085. }
  77086. declare module BABYLON.GUI {
  77087. /**
  77088. * Class used to hold a the container for ScrollViewer
  77089. * @hidden
  77090. */
  77091. export class _ScrollViewerWindow extends Container {
  77092. parentClientWidth: number;
  77093. parentClientHeight: number;
  77094. private _freezeControls;
  77095. private _parentMeasure;
  77096. private _oldLeft;
  77097. private _oldTop;
  77098. get freezeControls(): boolean;
  77099. set freezeControls(value: boolean);
  77100. private _bucketWidth;
  77101. private _bucketHeight;
  77102. private _buckets;
  77103. private _bucketLen;
  77104. get bucketWidth(): number;
  77105. get bucketHeight(): number;
  77106. setBucketSizes(width: number, height: number): void;
  77107. private _useBuckets;
  77108. private _makeBuckets;
  77109. private _dispatchInBuckets;
  77110. private _updateMeasures;
  77111. private _updateChildrenMeasures;
  77112. private _restoreMeasures;
  77113. /**
  77114. * Creates a new ScrollViewerWindow
  77115. * @param name of ScrollViewerWindow
  77116. */
  77117. constructor(name?: string);
  77118. protected _getTypeName(): string;
  77119. /** @hidden */
  77120. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77121. /** @hidden */
  77122. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77123. private _scrollChildren;
  77124. private _scrollChildrenWithBuckets;
  77125. /** @hidden */
  77126. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77127. protected _postMeasure(): void;
  77128. }
  77129. }
  77130. declare module BABYLON.GUI {
  77131. /**
  77132. * Class used to create slider controls
  77133. */
  77134. export class ScrollBar extends BaseSlider {
  77135. name?: string | undefined;
  77136. private _background;
  77137. private _borderColor;
  77138. private _tempMeasure;
  77139. /** Gets or sets border color */
  77140. get borderColor(): string;
  77141. set borderColor(value: string);
  77142. /** Gets or sets background color */
  77143. get background(): string;
  77144. set background(value: string);
  77145. /**
  77146. * Creates a new Slider
  77147. * @param name defines the control name
  77148. */
  77149. constructor(name?: string | undefined);
  77150. protected _getTypeName(): string;
  77151. protected _getThumbThickness(): number;
  77152. _draw(context: CanvasRenderingContext2D): void;
  77153. private _first;
  77154. private _originX;
  77155. private _originY;
  77156. /** @hidden */
  77157. protected _updateValueFromPointer(x: number, y: number): void;
  77158. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77159. }
  77160. }
  77161. declare module BABYLON.GUI {
  77162. /**
  77163. * Class used to create slider controls
  77164. */
  77165. export class ImageScrollBar extends BaseSlider {
  77166. name?: string | undefined;
  77167. private _backgroundBaseImage;
  77168. private _backgroundImage;
  77169. private _thumbImage;
  77170. private _thumbBaseImage;
  77171. private _thumbLength;
  77172. private _thumbHeight;
  77173. private _barImageHeight;
  77174. private _tempMeasure;
  77175. /** Number of 90° rotation to apply on the images when in vertical mode */
  77176. num90RotationInVerticalMode: number;
  77177. /**
  77178. * Gets or sets the image used to render the background for horizontal bar
  77179. */
  77180. get backgroundImage(): Image;
  77181. set backgroundImage(value: Image);
  77182. /**
  77183. * Gets or sets the image used to render the thumb
  77184. */
  77185. get thumbImage(): Image;
  77186. set thumbImage(value: Image);
  77187. /**
  77188. * Gets or sets the length of the thumb
  77189. */
  77190. get thumbLength(): number;
  77191. set thumbLength(value: number);
  77192. /**
  77193. * Gets or sets the height of the thumb
  77194. */
  77195. get thumbHeight(): number;
  77196. set thumbHeight(value: number);
  77197. /**
  77198. * Gets or sets the height of the bar image
  77199. */
  77200. get barImageHeight(): number;
  77201. set barImageHeight(value: number);
  77202. /**
  77203. * Creates a new ImageScrollBar
  77204. * @param name defines the control name
  77205. */
  77206. constructor(name?: string | undefined);
  77207. protected _getTypeName(): string;
  77208. protected _getThumbThickness(): number;
  77209. _draw(context: CanvasRenderingContext2D): void;
  77210. private _first;
  77211. private _originX;
  77212. private _originY;
  77213. /** @hidden */
  77214. protected _updateValueFromPointer(x: number, y: number): void;
  77215. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77216. }
  77217. }
  77218. declare module BABYLON.GUI {
  77219. /**
  77220. * Class used to hold a viewer window and sliders in a grid
  77221. */
  77222. export class ScrollViewer extends Rectangle {
  77223. private _grid;
  77224. private _horizontalBarSpace;
  77225. private _verticalBarSpace;
  77226. private _dragSpace;
  77227. private _horizontalBar;
  77228. private _verticalBar;
  77229. private _barColor;
  77230. private _barBackground;
  77231. private _barImage;
  77232. private _horizontalBarImage;
  77233. private _verticalBarImage;
  77234. private _barBackgroundImage;
  77235. private _horizontalBarBackgroundImage;
  77236. private _verticalBarBackgroundImage;
  77237. private _barSize;
  77238. private _window;
  77239. private _pointerIsOver;
  77240. private _wheelPrecision;
  77241. private _onWheelObserver;
  77242. private _clientWidth;
  77243. private _clientHeight;
  77244. private _useImageBar;
  77245. private _thumbLength;
  77246. private _thumbHeight;
  77247. private _barImageHeight;
  77248. private _horizontalBarImageHeight;
  77249. private _verticalBarImageHeight;
  77250. private _oldWindowContentsWidth;
  77251. private _oldWindowContentsHeight;
  77252. /**
  77253. * Gets the horizontal scrollbar
  77254. */
  77255. get horizontalBar(): ScrollBar | ImageScrollBar;
  77256. /**
  77257. * Gets the vertical scrollbar
  77258. */
  77259. get verticalBar(): ScrollBar | ImageScrollBar;
  77260. /**
  77261. * Adds a new control to the current container
  77262. * @param control defines the control to add
  77263. * @returns the current container
  77264. */
  77265. addControl(control: BABYLON.Nullable<Control>): Container;
  77266. /**
  77267. * Removes a control from the current container
  77268. * @param control defines the control to remove
  77269. * @returns the current container
  77270. */
  77271. removeControl(control: Control): Container;
  77272. /** Gets the list of children */
  77273. get children(): Control[];
  77274. _flagDescendantsAsMatrixDirty(): void;
  77275. /**
  77276. * Freezes or unfreezes the controls in the window.
  77277. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77278. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77279. */
  77280. get freezeControls(): boolean;
  77281. set freezeControls(value: boolean);
  77282. /** Gets the bucket width */
  77283. get bucketWidth(): number;
  77284. /** Gets the bucket height */
  77285. get bucketHeight(): number;
  77286. /**
  77287. * Sets the bucket sizes.
  77288. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77289. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77290. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77291. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77292. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77293. * used), that's why it is not enabled by default.
  77294. * @param width width of the bucket
  77295. * @param height height of the bucket
  77296. */
  77297. setBucketSizes(width: number, height: number): void;
  77298. private _forceHorizontalBar;
  77299. private _forceVerticalBar;
  77300. /**
  77301. * Forces the horizontal scroll bar to be displayed
  77302. */
  77303. get forceHorizontalBar(): boolean;
  77304. set forceHorizontalBar(value: boolean);
  77305. /**
  77306. * Forces the vertical scroll bar to be displayed
  77307. */
  77308. get forceVerticalBar(): boolean;
  77309. set forceVerticalBar(value: boolean);
  77310. /**
  77311. * Creates a new ScrollViewer
  77312. * @param name of ScrollViewer
  77313. */
  77314. constructor(name?: string, isImageBased?: boolean);
  77315. /** Reset the scroll viewer window to initial size */
  77316. resetWindow(): void;
  77317. protected _getTypeName(): string;
  77318. private _buildClientSizes;
  77319. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77320. protected _postMeasure(): void;
  77321. /**
  77322. * Gets or sets the mouse wheel precision
  77323. * from 0 to 1 with a default value of 0.05
  77324. * */
  77325. get wheelPrecision(): number;
  77326. set wheelPrecision(value: number);
  77327. /** Gets or sets the scroll bar container background color */
  77328. get scrollBackground(): string;
  77329. set scrollBackground(color: string);
  77330. /** Gets or sets the bar color */
  77331. get barColor(): string;
  77332. set barColor(color: string);
  77333. /** Gets or sets the bar image */
  77334. get thumbImage(): Image;
  77335. set thumbImage(value: Image);
  77336. /** Gets or sets the horizontal bar image */
  77337. get horizontalThumbImage(): Image;
  77338. set horizontalThumbImage(value: Image);
  77339. /** Gets or sets the vertical bar image */
  77340. get verticalThumbImage(): Image;
  77341. set verticalThumbImage(value: Image);
  77342. /** Gets or sets the size of the bar */
  77343. get barSize(): number;
  77344. set barSize(value: number);
  77345. /** Gets or sets the length of the thumb */
  77346. get thumbLength(): number;
  77347. set thumbLength(value: number);
  77348. /** Gets or sets the height of the thumb */
  77349. get thumbHeight(): number;
  77350. set thumbHeight(value: number);
  77351. /** Gets or sets the height of the bar image */
  77352. get barImageHeight(): number;
  77353. set barImageHeight(value: number);
  77354. /** Gets or sets the height of the horizontal bar image */
  77355. get horizontalBarImageHeight(): number;
  77356. set horizontalBarImageHeight(value: number);
  77357. /** Gets or sets the height of the vertical bar image */
  77358. get verticalBarImageHeight(): number;
  77359. set verticalBarImageHeight(value: number);
  77360. /** Gets or sets the bar background */
  77361. get barBackground(): string;
  77362. set barBackground(color: string);
  77363. /** Gets or sets the bar background image */
  77364. get barImage(): Image;
  77365. set barImage(value: Image);
  77366. /** Gets or sets the horizontal bar background image */
  77367. get horizontalBarImage(): Image;
  77368. set horizontalBarImage(value: Image);
  77369. /** Gets or sets the vertical bar background image */
  77370. get verticalBarImage(): Image;
  77371. set verticalBarImage(value: Image);
  77372. private _setWindowPosition;
  77373. /** @hidden */
  77374. private _updateScroller;
  77375. _link(host: AdvancedDynamicTexture): void;
  77376. /** @hidden */
  77377. private _addBar;
  77378. /** @hidden */
  77379. private _attachWheel;
  77380. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77381. /** Releases associated resources */
  77382. dispose(): void;
  77383. }
  77384. }
  77385. declare module BABYLON.GUI {
  77386. /** Class used to render a grid */
  77387. export class DisplayGrid extends Control {
  77388. name?: string | undefined;
  77389. private _cellWidth;
  77390. private _cellHeight;
  77391. private _minorLineTickness;
  77392. private _minorLineColor;
  77393. private _majorLineTickness;
  77394. private _majorLineColor;
  77395. private _majorLineFrequency;
  77396. private _background;
  77397. private _displayMajorLines;
  77398. private _displayMinorLines;
  77399. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77400. get displayMinorLines(): boolean;
  77401. set displayMinorLines(value: boolean);
  77402. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77403. get displayMajorLines(): boolean;
  77404. set displayMajorLines(value: boolean);
  77405. /** Gets or sets background color (Black by default) */
  77406. get background(): string;
  77407. set background(value: string);
  77408. /** Gets or sets the width of each cell (20 by default) */
  77409. get cellWidth(): number;
  77410. set cellWidth(value: number);
  77411. /** Gets or sets the height of each cell (20 by default) */
  77412. get cellHeight(): number;
  77413. set cellHeight(value: number);
  77414. /** Gets or sets the tickness of minor lines (1 by default) */
  77415. get minorLineTickness(): number;
  77416. set minorLineTickness(value: number);
  77417. /** Gets or sets the color of minor lines (DarkGray by default) */
  77418. get minorLineColor(): string;
  77419. set minorLineColor(value: string);
  77420. /** Gets or sets the tickness of major lines (2 by default) */
  77421. get majorLineTickness(): number;
  77422. set majorLineTickness(value: number);
  77423. /** Gets or sets the color of major lines (White by default) */
  77424. get majorLineColor(): string;
  77425. set majorLineColor(value: string);
  77426. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77427. get majorLineFrequency(): number;
  77428. set majorLineFrequency(value: number);
  77429. /**
  77430. * Creates a new GridDisplayRectangle
  77431. * @param name defines the control name
  77432. */
  77433. constructor(name?: string | undefined);
  77434. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77435. protected _getTypeName(): string;
  77436. }
  77437. }
  77438. declare module BABYLON.GUI {
  77439. /**
  77440. * Class used to create slider controls based on images
  77441. */
  77442. export class ImageBasedSlider extends BaseSlider {
  77443. name?: string | undefined;
  77444. private _backgroundImage;
  77445. private _thumbImage;
  77446. private _valueBarImage;
  77447. private _tempMeasure;
  77448. get displayThumb(): boolean;
  77449. set displayThumb(value: boolean);
  77450. /**
  77451. * Gets or sets the image used to render the background
  77452. */
  77453. get backgroundImage(): Image;
  77454. set backgroundImage(value: Image);
  77455. /**
  77456. * Gets or sets the image used to render the value bar
  77457. */
  77458. get valueBarImage(): Image;
  77459. set valueBarImage(value: Image);
  77460. /**
  77461. * Gets or sets the image used to render the thumb
  77462. */
  77463. get thumbImage(): Image;
  77464. set thumbImage(value: Image);
  77465. /**
  77466. * Creates a new ImageBasedSlider
  77467. * @param name defines the control name
  77468. */
  77469. constructor(name?: string | undefined);
  77470. protected _getTypeName(): string;
  77471. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77472. }
  77473. }
  77474. declare module BABYLON.GUI {
  77475. /**
  77476. * Forcing an export so that this code will execute
  77477. * @hidden
  77478. */
  77479. const name = "Statics";
  77480. }
  77481. declare module BABYLON.GUI {
  77482. /**
  77483. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77484. */
  77485. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77486. /**
  77487. * Define the instrumented AdvancedDynamicTexture.
  77488. */
  77489. texture: AdvancedDynamicTexture;
  77490. private _captureRenderTime;
  77491. private _renderTime;
  77492. private _captureLayoutTime;
  77493. private _layoutTime;
  77494. private _onBeginRenderObserver;
  77495. private _onEndRenderObserver;
  77496. private _onBeginLayoutObserver;
  77497. private _onEndLayoutObserver;
  77498. /**
  77499. * Gets the perf counter used to capture render time
  77500. */
  77501. get renderTimeCounter(): BABYLON.PerfCounter;
  77502. /**
  77503. * Gets the perf counter used to capture layout time
  77504. */
  77505. get layoutTimeCounter(): BABYLON.PerfCounter;
  77506. /**
  77507. * Enable or disable the render time capture
  77508. */
  77509. get captureRenderTime(): boolean;
  77510. set captureRenderTime(value: boolean);
  77511. /**
  77512. * Enable or disable the layout time capture
  77513. */
  77514. get captureLayoutTime(): boolean;
  77515. set captureLayoutTime(value: boolean);
  77516. /**
  77517. * Instantiates a new advanced dynamic texture instrumentation.
  77518. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77519. * @param texture Defines the AdvancedDynamicTexture to instrument
  77520. */
  77521. constructor(
  77522. /**
  77523. * Define the instrumented AdvancedDynamicTexture.
  77524. */
  77525. texture: AdvancedDynamicTexture);
  77526. /**
  77527. * Dispose and release associated resources.
  77528. */
  77529. dispose(): void;
  77530. }
  77531. }
  77532. declare module BABYLON.GUI {
  77533. /**
  77534. * Class used to load GUI via XML.
  77535. */
  77536. export class XmlLoader {
  77537. private _nodes;
  77538. private _nodeTypes;
  77539. private _isLoaded;
  77540. private _objectAttributes;
  77541. private _parentClass;
  77542. /**
  77543. * Create a new xml loader
  77544. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77545. */
  77546. constructor(parentClass?: null);
  77547. private _getChainElement;
  77548. private _getClassAttribute;
  77549. private _createGuiElement;
  77550. private _parseGrid;
  77551. private _parseElement;
  77552. private _prepareSourceElement;
  77553. private _parseElementsFromSource;
  77554. private _parseXml;
  77555. /**
  77556. * Gets if the loading has finished.
  77557. * @returns whether the loading has finished or not
  77558. */
  77559. isLoaded(): boolean;
  77560. /**
  77561. * Gets a loaded node / control by id.
  77562. * @param id the Controls id set in the xml
  77563. * @returns element of type Control
  77564. */
  77565. getNodeById(id: string): any;
  77566. /**
  77567. * Gets all loaded nodes / controls
  77568. * @returns Array of controls
  77569. */
  77570. getNodes(): any;
  77571. /**
  77572. * Initiates the xml layout loading
  77573. * @param xmlFile defines the xml layout to load
  77574. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77575. * @param callback defines the callback called on layout load.
  77576. */
  77577. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77578. }
  77579. }
  77580. declare module BABYLON.GUI {
  77581. /**
  77582. * Class used to create containers for controls
  77583. */
  77584. export class Container3D extends Control3D {
  77585. private _blockLayout;
  77586. /**
  77587. * Gets the list of child controls
  77588. */
  77589. protected _children: Control3D[];
  77590. /**
  77591. * Gets the list of child controls
  77592. */
  77593. get children(): Array<Control3D>;
  77594. /**
  77595. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77596. * This is helpful to optimize layout operation when adding multiple children in a row
  77597. */
  77598. get blockLayout(): boolean;
  77599. set blockLayout(value: boolean);
  77600. /**
  77601. * Creates a new container
  77602. * @param name defines the container name
  77603. */
  77604. constructor(name?: string);
  77605. /**
  77606. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77607. * @returns the current container
  77608. */
  77609. updateLayout(): Container3D;
  77610. /**
  77611. * Gets a boolean indicating if the given control is in the children of this control
  77612. * @param control defines the control to check
  77613. * @returns true if the control is in the child list
  77614. */
  77615. containsControl(control: Control3D): boolean;
  77616. /**
  77617. * Adds a control to the children of this control
  77618. * @param control defines the control to add
  77619. * @returns the current container
  77620. */
  77621. addControl(control: Control3D): Container3D;
  77622. /**
  77623. * This function will be called everytime a new control is added
  77624. */
  77625. protected _arrangeChildren(): void;
  77626. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77627. /**
  77628. * Removes a control from the children of this control
  77629. * @param control defines the control to remove
  77630. * @returns the current container
  77631. */
  77632. removeControl(control: Control3D): Container3D;
  77633. protected _getTypeName(): string;
  77634. /**
  77635. * Releases all associated resources
  77636. */
  77637. dispose(): void;
  77638. /** Control rotation will remain unchanged */
  77639. static readonly UNSET_ORIENTATION: number;
  77640. /** Control will rotate to make it look at sphere central axis */
  77641. static readonly FACEORIGIN_ORIENTATION: number;
  77642. /** Control will rotate to make it look back at sphere central axis */
  77643. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77644. /** Control will rotate to look at z axis (0, 0, 1) */
  77645. static readonly FACEFORWARD_ORIENTATION: number;
  77646. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77647. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77648. }
  77649. }
  77650. declare module BABYLON.GUI {
  77651. /**
  77652. * Class used to manage 3D user interface
  77653. * @see http://doc.babylonjs.com/how_to/gui3d
  77654. */
  77655. export class GUI3DManager implements BABYLON.IDisposable {
  77656. private _scene;
  77657. private _sceneDisposeObserver;
  77658. private _utilityLayer;
  77659. private _rootContainer;
  77660. private _pointerObserver;
  77661. private _pointerOutObserver;
  77662. /** @hidden */
  77663. _lastPickedControl: Control3D;
  77664. /** @hidden */
  77665. _lastControlOver: {
  77666. [pointerId: number]: Control3D;
  77667. };
  77668. /** @hidden */
  77669. _lastControlDown: {
  77670. [pointerId: number]: Control3D;
  77671. };
  77672. /**
  77673. * BABYLON.Observable raised when the point picked by the pointer events changed
  77674. */
  77675. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77676. /** @hidden */
  77677. _sharedMaterials: {
  77678. [key: string]: BABYLON.Material;
  77679. };
  77680. /** Gets the hosting scene */
  77681. get scene(): BABYLON.Scene;
  77682. /** Gets associated utility layer */
  77683. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77684. /**
  77685. * Creates a new GUI3DManager
  77686. * @param scene
  77687. */
  77688. constructor(scene?: BABYLON.Scene);
  77689. private _handlePointerOut;
  77690. private _doPicking;
  77691. /**
  77692. * Gets the root container
  77693. */
  77694. get rootContainer(): Container3D;
  77695. /**
  77696. * Gets a boolean indicating if the given control is in the root child list
  77697. * @param control defines the control to check
  77698. * @returns true if the control is in the root child list
  77699. */
  77700. containsControl(control: Control3D): boolean;
  77701. /**
  77702. * Adds a control to the root child list
  77703. * @param control defines the control to add
  77704. * @returns the current manager
  77705. */
  77706. addControl(control: Control3D): GUI3DManager;
  77707. /**
  77708. * Removes a control from the root child list
  77709. * @param control defines the control to remove
  77710. * @returns the current container
  77711. */
  77712. removeControl(control: Control3D): GUI3DManager;
  77713. /**
  77714. * Releases all associated resources
  77715. */
  77716. dispose(): void;
  77717. }
  77718. }
  77719. declare module BABYLON.GUI {
  77720. /**
  77721. * Class used to transport BABYLON.Vector3 information for pointer events
  77722. */
  77723. export class Vector3WithInfo extends BABYLON.Vector3 {
  77724. /** defines the current mouse button index */
  77725. buttonIndex: number;
  77726. /**
  77727. * Creates a new Vector3WithInfo
  77728. * @param source defines the vector3 data to transport
  77729. * @param buttonIndex defines the current mouse button index
  77730. */
  77731. constructor(source: BABYLON.Vector3,
  77732. /** defines the current mouse button index */
  77733. buttonIndex?: number);
  77734. }
  77735. }
  77736. declare module BABYLON.GUI {
  77737. /**
  77738. * Class used as base class for controls
  77739. */
  77740. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77741. /** Defines the control name */
  77742. name?: string | undefined;
  77743. /** @hidden */
  77744. _host: GUI3DManager;
  77745. private _node;
  77746. private _downCount;
  77747. private _enterCount;
  77748. private _downPointerIds;
  77749. private _isVisible;
  77750. /** Gets or sets the control position in world space */
  77751. get position(): BABYLON.Vector3;
  77752. set position(value: BABYLON.Vector3);
  77753. /** Gets or sets the control scaling in world space */
  77754. get scaling(): BABYLON.Vector3;
  77755. set scaling(value: BABYLON.Vector3);
  77756. /** Callback used to start pointer enter animation */
  77757. pointerEnterAnimation: () => void;
  77758. /** Callback used to start pointer out animation */
  77759. pointerOutAnimation: () => void;
  77760. /** Callback used to start pointer down animation */
  77761. pointerDownAnimation: () => void;
  77762. /** Callback used to start pointer up animation */
  77763. pointerUpAnimation: () => void;
  77764. /**
  77765. * An event triggered when the pointer move over the control
  77766. */
  77767. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77768. /**
  77769. * An event triggered when the pointer move out of the control
  77770. */
  77771. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77772. /**
  77773. * An event triggered when the pointer taps the control
  77774. */
  77775. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77776. /**
  77777. * An event triggered when pointer is up
  77778. */
  77779. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77780. /**
  77781. * An event triggered when a control is clicked on (with a mouse)
  77782. */
  77783. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77784. /**
  77785. * An event triggered when pointer enters the control
  77786. */
  77787. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77788. /**
  77789. * Gets or sets the parent container
  77790. */
  77791. parent: BABYLON.Nullable<Container3D>;
  77792. private _behaviors;
  77793. /**
  77794. * Gets the list of attached behaviors
  77795. * @see http://doc.babylonjs.com/features/behaviour
  77796. */
  77797. get behaviors(): BABYLON.Behavior<Control3D>[];
  77798. /**
  77799. * Attach a behavior to the control
  77800. * @see http://doc.babylonjs.com/features/behaviour
  77801. * @param behavior defines the behavior to attach
  77802. * @returns the current control
  77803. */
  77804. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77805. /**
  77806. * Remove an attached behavior
  77807. * @see http://doc.babylonjs.com/features/behaviour
  77808. * @param behavior defines the behavior to attach
  77809. * @returns the current control
  77810. */
  77811. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77812. /**
  77813. * Gets an attached behavior by name
  77814. * @param name defines the name of the behavior to look for
  77815. * @see http://doc.babylonjs.com/features/behaviour
  77816. * @returns null if behavior was not found else the requested behavior
  77817. */
  77818. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77819. /** Gets or sets a boolean indicating if the control is visible */
  77820. get isVisible(): boolean;
  77821. set isVisible(value: boolean);
  77822. /**
  77823. * Creates a new control
  77824. * @param name defines the control name
  77825. */
  77826. constructor(
  77827. /** Defines the control name */
  77828. name?: string | undefined);
  77829. /**
  77830. * Gets a string representing the class name
  77831. */
  77832. get typeName(): string;
  77833. /**
  77834. * Get the current class name of the control.
  77835. * @returns current class name
  77836. */
  77837. getClassName(): string;
  77838. protected _getTypeName(): string;
  77839. /**
  77840. * Gets the transform node used by this control
  77841. */
  77842. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77843. /**
  77844. * Gets the mesh used to render this control
  77845. */
  77846. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77847. /**
  77848. * Link the control as child of the given node
  77849. * @param node defines the node to link to. Use null to unlink the control
  77850. * @returns the current control
  77851. */
  77852. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77853. /** @hidden **/
  77854. _prepareNode(scene: BABYLON.Scene): void;
  77855. /**
  77856. * Node creation.
  77857. * Can be overriden by children
  77858. * @param scene defines the scene where the node must be attached
  77859. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77860. */
  77861. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77862. /**
  77863. * Affect a material to the given mesh
  77864. * @param mesh defines the mesh which will represent the control
  77865. */
  77866. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77867. /** @hidden */
  77868. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77869. /** @hidden */
  77870. _onPointerEnter(target: Control3D): boolean;
  77871. /** @hidden */
  77872. _onPointerOut(target: Control3D): void;
  77873. /** @hidden */
  77874. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77875. /** @hidden */
  77876. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77877. /** @hidden */
  77878. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77879. /** @hidden */
  77880. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77881. /** @hidden */
  77882. _disposeNode(): void;
  77883. /**
  77884. * Releases all associated resources
  77885. */
  77886. dispose(): void;
  77887. }
  77888. }
  77889. declare module BABYLON.GUI {
  77890. /**
  77891. * Class used as a root to all buttons
  77892. */
  77893. export class AbstractButton3D extends Control3D {
  77894. /**
  77895. * Creates a new button
  77896. * @param name defines the control name
  77897. */
  77898. constructor(name?: string);
  77899. protected _getTypeName(): string;
  77900. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77901. }
  77902. }
  77903. declare module BABYLON.GUI {
  77904. /**
  77905. * Class used to create a button in 3D
  77906. */
  77907. export class Button3D extends AbstractButton3D {
  77908. /** @hidden */
  77909. protected _currentMaterial: BABYLON.Material;
  77910. private _facadeTexture;
  77911. private _content;
  77912. private _contentResolution;
  77913. private _contentScaleRatio;
  77914. /**
  77915. * Gets or sets the texture resolution used to render content (512 by default)
  77916. */
  77917. get contentResolution(): BABYLON.int;
  77918. set contentResolution(value: BABYLON.int);
  77919. /**
  77920. * Gets or sets the texture scale ratio used to render content (2 by default)
  77921. */
  77922. get contentScaleRatio(): number;
  77923. set contentScaleRatio(value: number);
  77924. protected _disposeFacadeTexture(): void;
  77925. protected _resetContent(): void;
  77926. /**
  77927. * Creates a new button
  77928. * @param name defines the control name
  77929. */
  77930. constructor(name?: string);
  77931. /**
  77932. * Gets or sets the GUI 2D content used to display the button's facade
  77933. */
  77934. get content(): Control;
  77935. set content(value: Control);
  77936. /**
  77937. * Apply the facade texture (created from the content property).
  77938. * This function can be overloaded by child classes
  77939. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77940. */
  77941. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77942. protected _getTypeName(): string;
  77943. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77944. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77945. /**
  77946. * Releases all associated resources
  77947. */
  77948. dispose(): void;
  77949. }
  77950. }
  77951. declare module BABYLON.GUI {
  77952. /**
  77953. * Abstract class used to create a container panel deployed on the surface of a volume
  77954. */
  77955. export abstract class VolumeBasedPanel extends Container3D {
  77956. private _columns;
  77957. private _rows;
  77958. private _rowThenColum;
  77959. private _orientation;
  77960. protected _cellWidth: number;
  77961. protected _cellHeight: number;
  77962. /**
  77963. * Gets or sets the distance between elements
  77964. */
  77965. margin: number;
  77966. /**
  77967. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77968. * | Value | Type | Description |
  77969. * | ----- | ----------------------------------- | ----------- |
  77970. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77971. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77972. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77973. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77974. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77975. */
  77976. get orientation(): number;
  77977. set orientation(value: number);
  77978. /**
  77979. * Gets or sets the number of columns requested (10 by default).
  77980. * The panel will automatically compute the number of rows based on number of child controls.
  77981. */
  77982. get columns(): BABYLON.int;
  77983. set columns(value: BABYLON.int);
  77984. /**
  77985. * Gets or sets a the number of rows requested.
  77986. * The panel will automatically compute the number of columns based on number of child controls.
  77987. */
  77988. get rows(): BABYLON.int;
  77989. set rows(value: BABYLON.int);
  77990. /**
  77991. * Creates new VolumeBasedPanel
  77992. */
  77993. constructor();
  77994. protected _arrangeChildren(): void;
  77995. /** Child classes must implement this function to provide correct control positioning */
  77996. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77997. /** Child classes can implement this function to provide additional processing */
  77998. protected _finalProcessing(): void;
  77999. }
  78000. }
  78001. declare module BABYLON.GUI {
  78002. /**
  78003. * Class used to create a container panel deployed on the surface of a cylinder
  78004. */
  78005. export class CylinderPanel extends VolumeBasedPanel {
  78006. private _radius;
  78007. /**
  78008. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78009. */
  78010. get radius(): BABYLON.float;
  78011. set radius(value: BABYLON.float);
  78012. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78013. private _cylindricalMapping;
  78014. }
  78015. }
  78016. declare module BABYLON.GUI {
  78017. /** @hidden */
  78018. export var fluentVertexShader: {
  78019. name: string;
  78020. shader: string;
  78021. };
  78022. }
  78023. declare module BABYLON.GUI {
  78024. /** @hidden */
  78025. export var fluentPixelShader: {
  78026. name: string;
  78027. shader: string;
  78028. };
  78029. }
  78030. declare module BABYLON.GUI {
  78031. /** @hidden */
  78032. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78033. INNERGLOW: boolean;
  78034. BORDER: boolean;
  78035. HOVERLIGHT: boolean;
  78036. TEXTURE: boolean;
  78037. constructor();
  78038. }
  78039. /**
  78040. * Class used to render controls with fluent desgin
  78041. */
  78042. export class FluentMaterial extends BABYLON.PushMaterial {
  78043. /**
  78044. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78045. */
  78046. innerGlowColorIntensity: number;
  78047. /**
  78048. * Gets or sets the inner glow color (white by default)
  78049. */
  78050. innerGlowColor: BABYLON.Color3;
  78051. /**
  78052. * Gets or sets alpha value (default is 1.0)
  78053. */
  78054. alpha: number;
  78055. /**
  78056. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78057. */
  78058. albedoColor: BABYLON.Color3;
  78059. /**
  78060. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78061. */
  78062. renderBorders: boolean;
  78063. /**
  78064. * Gets or sets border width (default is 0.5)
  78065. */
  78066. borderWidth: number;
  78067. /**
  78068. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78069. */
  78070. edgeSmoothingValue: number;
  78071. /**
  78072. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78073. */
  78074. borderMinValue: number;
  78075. /**
  78076. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78077. */
  78078. renderHoverLight: boolean;
  78079. /**
  78080. * Gets or sets the radius used to render the hover light (default is 1.0)
  78081. */
  78082. hoverRadius: number;
  78083. /**
  78084. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78085. */
  78086. hoverColor: BABYLON.Color4;
  78087. /**
  78088. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78089. */
  78090. hoverPosition: BABYLON.Vector3;
  78091. private _albedoTexture;
  78092. /** Gets or sets the texture to use for albedo color */
  78093. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78094. /**
  78095. * Creates a new Fluent material
  78096. * @param name defines the name of the material
  78097. * @param scene defines the hosting scene
  78098. */
  78099. constructor(name: string, scene: BABYLON.Scene);
  78100. needAlphaBlending(): boolean;
  78101. needAlphaTesting(): boolean;
  78102. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78103. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78104. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78105. getActiveTextures(): BABYLON.BaseTexture[];
  78106. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78107. dispose(forceDisposeEffect?: boolean): void;
  78108. clone(name: string): FluentMaterial;
  78109. serialize(): any;
  78110. getClassName(): string;
  78111. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78112. }
  78113. }
  78114. declare module BABYLON.GUI {
  78115. /**
  78116. * Class used to create a holographic button in 3D
  78117. */
  78118. export class HolographicButton extends Button3D {
  78119. private _backPlate;
  78120. private _textPlate;
  78121. private _frontPlate;
  78122. private _text;
  78123. private _imageUrl;
  78124. private _shareMaterials;
  78125. private _frontMaterial;
  78126. private _backMaterial;
  78127. private _plateMaterial;
  78128. private _pickedPointObserver;
  78129. private _tooltipFade;
  78130. private _tooltipTextBlock;
  78131. private _tooltipTexture;
  78132. private _tooltipMesh;
  78133. private _tooltipHoverObserver;
  78134. private _tooltipOutObserver;
  78135. private _disposeTooltip;
  78136. /**
  78137. * Rendering ground id of all the mesh in the button
  78138. */
  78139. set renderingGroupId(id: number);
  78140. get renderingGroupId(): number;
  78141. /**
  78142. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78143. */
  78144. set tooltipText(text: BABYLON.Nullable<string>);
  78145. get tooltipText(): BABYLON.Nullable<string>;
  78146. /**
  78147. * Gets or sets text for the button
  78148. */
  78149. get text(): string;
  78150. set text(value: string);
  78151. /**
  78152. * Gets or sets the image url for the button
  78153. */
  78154. get imageUrl(): string;
  78155. set imageUrl(value: string);
  78156. /**
  78157. * Gets the back material used by this button
  78158. */
  78159. get backMaterial(): FluentMaterial;
  78160. /**
  78161. * Gets the front material used by this button
  78162. */
  78163. get frontMaterial(): FluentMaterial;
  78164. /**
  78165. * Gets the plate material used by this button
  78166. */
  78167. get plateMaterial(): BABYLON.StandardMaterial;
  78168. /**
  78169. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78170. */
  78171. get shareMaterials(): boolean;
  78172. /**
  78173. * Creates a new button
  78174. * @param name defines the control name
  78175. */
  78176. constructor(name?: string, shareMaterials?: boolean);
  78177. protected _getTypeName(): string;
  78178. private _rebuildContent;
  78179. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78180. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78181. private _createBackMaterial;
  78182. private _createFrontMaterial;
  78183. private _createPlateMaterial;
  78184. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78185. /**
  78186. * Releases all associated resources
  78187. */
  78188. dispose(): void;
  78189. }
  78190. }
  78191. declare module BABYLON.GUI {
  78192. /**
  78193. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78194. */
  78195. export class MeshButton3D extends Button3D {
  78196. /** @hidden */
  78197. protected _currentMesh: BABYLON.Mesh;
  78198. /**
  78199. * Creates a new 3D button based on a mesh
  78200. * @param mesh mesh to become a 3D button
  78201. * @param name defines the control name
  78202. */
  78203. constructor(mesh: BABYLON.Mesh, name?: string);
  78204. protected _getTypeName(): string;
  78205. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78206. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78207. }
  78208. }
  78209. declare module BABYLON.GUI {
  78210. /**
  78211. * Class used to create a container panel deployed on the surface of a plane
  78212. */
  78213. export class PlanePanel extends VolumeBasedPanel {
  78214. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78215. }
  78216. }
  78217. declare module BABYLON.GUI {
  78218. /**
  78219. * Class used to create a container panel where items get randomized planar mapping
  78220. */
  78221. export class ScatterPanel extends VolumeBasedPanel {
  78222. private _iteration;
  78223. /**
  78224. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78225. */
  78226. get iteration(): BABYLON.float;
  78227. set iteration(value: BABYLON.float);
  78228. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78229. private _scatterMapping;
  78230. protected _finalProcessing(): void;
  78231. }
  78232. }
  78233. declare module BABYLON.GUI {
  78234. /**
  78235. * Class used to create a container panel deployed on the surface of a sphere
  78236. */
  78237. export class SpherePanel extends VolumeBasedPanel {
  78238. private _radius;
  78239. /**
  78240. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78241. */
  78242. get radius(): BABYLON.float;
  78243. set radius(value: BABYLON.float);
  78244. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78245. private _sphericalMapping;
  78246. }
  78247. }
  78248. declare module BABYLON.GUI {
  78249. /**
  78250. * Class used to create a stack panel in 3D on XY plane
  78251. */
  78252. export class StackPanel3D extends Container3D {
  78253. private _isVertical;
  78254. /**
  78255. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78256. */
  78257. get isVertical(): boolean;
  78258. set isVertical(value: boolean);
  78259. /**
  78260. * Gets or sets the distance between elements
  78261. */
  78262. margin: number;
  78263. /**
  78264. * Creates new StackPanel
  78265. * @param isVertical
  78266. */
  78267. constructor(isVertical?: boolean);
  78268. protected _arrangeChildren(): void;
  78269. }
  78270. }
  78271. declare module BABYLON {
  78272. /**
  78273. * Configuration for glTF validation
  78274. */
  78275. export interface IGLTFValidationConfiguration {
  78276. /**
  78277. * The url of the glTF validator.
  78278. */
  78279. url: string;
  78280. }
  78281. /**
  78282. * glTF validation
  78283. */
  78284. export class GLTFValidation {
  78285. /**
  78286. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78287. */
  78288. static Configuration: IGLTFValidationConfiguration;
  78289. private static _LoadScriptPromise;
  78290. /**
  78291. * Validate a glTF asset using the glTF-Validator.
  78292. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78293. * @param rootUrl The root url for the glTF
  78294. * @param fileName The file name for the glTF
  78295. * @param getExternalResource The callback to get external resources for the glTF validator
  78296. * @returns A promise that resolves with the glTF validation results once complete
  78297. */
  78298. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78299. }
  78300. }
  78301. declare module BABYLON {
  78302. /**
  78303. * Mode that determines the coordinate system to use.
  78304. */
  78305. export enum GLTFLoaderCoordinateSystemMode {
  78306. /**
  78307. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78308. */
  78309. AUTO = 0,
  78310. /**
  78311. * Sets the useRightHandedSystem flag on the scene.
  78312. */
  78313. FORCE_RIGHT_HANDED = 1
  78314. }
  78315. /**
  78316. * Mode that determines what animations will start.
  78317. */
  78318. export enum GLTFLoaderAnimationStartMode {
  78319. /**
  78320. * No animation will start.
  78321. */
  78322. NONE = 0,
  78323. /**
  78324. * The first animation will start.
  78325. */
  78326. FIRST = 1,
  78327. /**
  78328. * All animations will start.
  78329. */
  78330. ALL = 2
  78331. }
  78332. /**
  78333. * Interface that contains the data for the glTF asset.
  78334. */
  78335. export interface IGLTFLoaderData {
  78336. /**
  78337. * The object that represents the glTF JSON.
  78338. */
  78339. json: Object;
  78340. /**
  78341. * The BIN chunk of a binary glTF.
  78342. */
  78343. bin: Nullable<IDataBuffer>;
  78344. }
  78345. /**
  78346. * Interface for extending the loader.
  78347. */
  78348. export interface IGLTFLoaderExtension {
  78349. /**
  78350. * The name of this extension.
  78351. */
  78352. readonly name: string;
  78353. /**
  78354. * Defines whether this extension is enabled.
  78355. */
  78356. enabled: boolean;
  78357. /**
  78358. * Defines the order of this extension.
  78359. * The loader sorts the extensions using these values when loading.
  78360. */
  78361. order?: number;
  78362. }
  78363. /**
  78364. * Loader state.
  78365. */
  78366. export enum GLTFLoaderState {
  78367. /**
  78368. * The asset is loading.
  78369. */
  78370. LOADING = 0,
  78371. /**
  78372. * The asset is ready for rendering.
  78373. */
  78374. READY = 1,
  78375. /**
  78376. * The asset is completely loaded.
  78377. */
  78378. COMPLETE = 2
  78379. }
  78380. /** @hidden */
  78381. export interface IImportMeshAsyncOutput {
  78382. meshes: AbstractMesh[];
  78383. particleSystems: IParticleSystem[];
  78384. skeletons: Skeleton[];
  78385. animationGroups: AnimationGroup[];
  78386. lights: Light[];
  78387. transformNodes: TransformNode[];
  78388. }
  78389. /** @hidden */
  78390. export interface IGLTFLoader extends IDisposable {
  78391. readonly state: Nullable<GLTFLoaderState>;
  78392. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78393. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78394. }
  78395. /**
  78396. * File loader for loading glTF files into a scene.
  78397. */
  78398. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78399. /** @hidden */
  78400. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78401. /** @hidden */
  78402. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78403. /**
  78404. * Raised when the asset has been parsed
  78405. */
  78406. onParsedObservable: Observable<IGLTFLoaderData>;
  78407. private _onParsedObserver;
  78408. /**
  78409. * Raised when the asset has been parsed
  78410. */
  78411. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78412. /**
  78413. * 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.
  78414. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78415. * Defaults to true.
  78416. * @hidden
  78417. */
  78418. static IncrementalLoading: boolean;
  78419. /**
  78420. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78421. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78422. * @hidden
  78423. */
  78424. static HomogeneousCoordinates: boolean;
  78425. /**
  78426. * The coordinate system mode. Defaults to AUTO.
  78427. */
  78428. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78429. /**
  78430. * The animation start mode. Defaults to FIRST.
  78431. */
  78432. animationStartMode: GLTFLoaderAnimationStartMode;
  78433. /**
  78434. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78435. */
  78436. compileMaterials: boolean;
  78437. /**
  78438. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78439. */
  78440. useClipPlane: boolean;
  78441. /**
  78442. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78443. */
  78444. compileShadowGenerators: boolean;
  78445. /**
  78446. * Defines if the Alpha blended materials are only applied as coverage.
  78447. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78448. * If true, no extra effects are applied to transparent pixels.
  78449. */
  78450. transparencyAsCoverage: boolean;
  78451. /**
  78452. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78453. * Enabling will disable offline support and glTF validator.
  78454. * Defaults to false.
  78455. */
  78456. useRangeRequests: boolean;
  78457. /**
  78458. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78459. */
  78460. createInstances: boolean;
  78461. /**
  78462. * Function called before loading a url referenced by the asset.
  78463. */
  78464. preprocessUrlAsync: (url: string) => Promise<string>;
  78465. /**
  78466. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78467. */
  78468. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78469. private _onMeshLoadedObserver;
  78470. /**
  78471. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78472. */
  78473. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78474. /**
  78475. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78476. */
  78477. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78478. private _onTextureLoadedObserver;
  78479. /**
  78480. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78481. */
  78482. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78483. /**
  78484. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78485. */
  78486. readonly onMaterialLoadedObservable: Observable<Material>;
  78487. private _onMaterialLoadedObserver;
  78488. /**
  78489. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78490. */
  78491. set onMaterialLoaded(callback: (material: Material) => void);
  78492. /**
  78493. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78494. */
  78495. readonly onCameraLoadedObservable: Observable<Camera>;
  78496. private _onCameraLoadedObserver;
  78497. /**
  78498. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78499. */
  78500. set onCameraLoaded(callback: (camera: Camera) => void);
  78501. /**
  78502. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78503. * For assets with LODs, raised when all of the LODs are complete.
  78504. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78505. */
  78506. readonly onCompleteObservable: Observable<void>;
  78507. private _onCompleteObserver;
  78508. /**
  78509. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78510. * For assets with LODs, raised when all of the LODs are complete.
  78511. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78512. */
  78513. set onComplete(callback: () => void);
  78514. /**
  78515. * Observable raised when an error occurs.
  78516. */
  78517. readonly onErrorObservable: Observable<any>;
  78518. private _onErrorObserver;
  78519. /**
  78520. * Callback raised when an error occurs.
  78521. */
  78522. set onError(callback: (reason: any) => void);
  78523. /**
  78524. * Observable raised after the loader is disposed.
  78525. */
  78526. readonly onDisposeObservable: Observable<void>;
  78527. private _onDisposeObserver;
  78528. /**
  78529. * Callback raised after the loader is disposed.
  78530. */
  78531. set onDispose(callback: () => void);
  78532. /**
  78533. * Observable raised after a loader extension is created.
  78534. * Set additional options for a loader extension in this event.
  78535. */
  78536. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78537. private _onExtensionLoadedObserver;
  78538. /**
  78539. * Callback raised after a loader extension is created.
  78540. */
  78541. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78542. /**
  78543. * Defines if the loader logging is enabled.
  78544. */
  78545. get loggingEnabled(): boolean;
  78546. set loggingEnabled(value: boolean);
  78547. /**
  78548. * Defines if the loader should capture performance counters.
  78549. */
  78550. get capturePerformanceCounters(): boolean;
  78551. set capturePerformanceCounters(value: boolean);
  78552. /**
  78553. * Defines if the loader should validate the asset.
  78554. */
  78555. validate: boolean;
  78556. /**
  78557. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78558. */
  78559. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78560. private _onValidatedObserver;
  78561. /**
  78562. * Callback raised after a loader extension is created.
  78563. */
  78564. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78565. private _loader;
  78566. private _progressCallback?;
  78567. private _requests;
  78568. /**
  78569. * Name of the loader ("gltf")
  78570. */
  78571. name: string;
  78572. /** @hidden */
  78573. extensions: ISceneLoaderPluginExtensions;
  78574. /**
  78575. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78576. */
  78577. dispose(): void;
  78578. /** @hidden */
  78579. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78580. /** @hidden */
  78581. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78582. /** @hidden */
  78583. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78584. meshes: AbstractMesh[];
  78585. particleSystems: IParticleSystem[];
  78586. skeletons: Skeleton[];
  78587. animationGroups: AnimationGroup[];
  78588. }>;
  78589. /** @hidden */
  78590. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78591. /** @hidden */
  78592. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78593. /** @hidden */
  78594. canDirectLoad(data: string): boolean;
  78595. /** @hidden */
  78596. directLoad(scene: Scene, data: string): any;
  78597. /**
  78598. * The callback that allows custom handling of the root url based on the response url.
  78599. * @param rootUrl the original root url
  78600. * @param responseURL the response url if available
  78601. * @returns the new root url
  78602. */
  78603. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78604. /** @hidden */
  78605. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78606. /**
  78607. * The loader state or null if the loader is not active.
  78608. */
  78609. get loaderState(): Nullable<GLTFLoaderState>;
  78610. /**
  78611. * Returns a promise that resolves when the asset is completely loaded.
  78612. * @returns a promise that resolves when the asset is completely loaded.
  78613. */
  78614. whenCompleteAsync(): Promise<void>;
  78615. /** @hidden */
  78616. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  78617. /** @hidden */
  78618. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  78619. private _onProgress;
  78620. private _validate;
  78621. private _getLoader;
  78622. private _parseJson;
  78623. private _unpackBinaryAsync;
  78624. private _unpackBinaryV1Async;
  78625. private _unpackBinaryV2Async;
  78626. private static _parseVersion;
  78627. private static _compareVersion;
  78628. private static readonly _logSpaces;
  78629. private _logIndentLevel;
  78630. private _loggingEnabled;
  78631. /** @hidden */
  78632. _log: (message: string) => void;
  78633. /** @hidden */
  78634. _logOpen(message: string): void;
  78635. /** @hidden */
  78636. _logClose(): void;
  78637. private _logEnabled;
  78638. private _logDisabled;
  78639. private _capturePerformanceCounters;
  78640. /** @hidden */
  78641. _startPerformanceCounter: (counterName: string) => void;
  78642. /** @hidden */
  78643. _endPerformanceCounter: (counterName: string) => void;
  78644. private _startPerformanceCounterEnabled;
  78645. private _startPerformanceCounterDisabled;
  78646. private _endPerformanceCounterEnabled;
  78647. private _endPerformanceCounterDisabled;
  78648. }
  78649. }
  78650. declare module BABYLON.GLTF1 {
  78651. /**
  78652. * Enums
  78653. * @hidden
  78654. */
  78655. export enum EComponentType {
  78656. BYTE = 5120,
  78657. UNSIGNED_BYTE = 5121,
  78658. SHORT = 5122,
  78659. UNSIGNED_SHORT = 5123,
  78660. FLOAT = 5126
  78661. }
  78662. /** @hidden */
  78663. export enum EShaderType {
  78664. FRAGMENT = 35632,
  78665. VERTEX = 35633
  78666. }
  78667. /** @hidden */
  78668. export enum EParameterType {
  78669. BYTE = 5120,
  78670. UNSIGNED_BYTE = 5121,
  78671. SHORT = 5122,
  78672. UNSIGNED_SHORT = 5123,
  78673. INT = 5124,
  78674. UNSIGNED_INT = 5125,
  78675. FLOAT = 5126,
  78676. FLOAT_VEC2 = 35664,
  78677. FLOAT_VEC3 = 35665,
  78678. FLOAT_VEC4 = 35666,
  78679. INT_VEC2 = 35667,
  78680. INT_VEC3 = 35668,
  78681. INT_VEC4 = 35669,
  78682. BOOL = 35670,
  78683. BOOL_VEC2 = 35671,
  78684. BOOL_VEC3 = 35672,
  78685. BOOL_VEC4 = 35673,
  78686. FLOAT_MAT2 = 35674,
  78687. FLOAT_MAT3 = 35675,
  78688. FLOAT_MAT4 = 35676,
  78689. SAMPLER_2D = 35678
  78690. }
  78691. /** @hidden */
  78692. export enum ETextureWrapMode {
  78693. CLAMP_TO_EDGE = 33071,
  78694. MIRRORED_REPEAT = 33648,
  78695. REPEAT = 10497
  78696. }
  78697. /** @hidden */
  78698. export enum ETextureFilterType {
  78699. NEAREST = 9728,
  78700. LINEAR = 9728,
  78701. NEAREST_MIPMAP_NEAREST = 9984,
  78702. LINEAR_MIPMAP_NEAREST = 9985,
  78703. NEAREST_MIPMAP_LINEAR = 9986,
  78704. LINEAR_MIPMAP_LINEAR = 9987
  78705. }
  78706. /** @hidden */
  78707. export enum ETextureFormat {
  78708. ALPHA = 6406,
  78709. RGB = 6407,
  78710. RGBA = 6408,
  78711. LUMINANCE = 6409,
  78712. LUMINANCE_ALPHA = 6410
  78713. }
  78714. /** @hidden */
  78715. export enum ECullingType {
  78716. FRONT = 1028,
  78717. BACK = 1029,
  78718. FRONT_AND_BACK = 1032
  78719. }
  78720. /** @hidden */
  78721. export enum EBlendingFunction {
  78722. ZERO = 0,
  78723. ONE = 1,
  78724. SRC_COLOR = 768,
  78725. ONE_MINUS_SRC_COLOR = 769,
  78726. DST_COLOR = 774,
  78727. ONE_MINUS_DST_COLOR = 775,
  78728. SRC_ALPHA = 770,
  78729. ONE_MINUS_SRC_ALPHA = 771,
  78730. DST_ALPHA = 772,
  78731. ONE_MINUS_DST_ALPHA = 773,
  78732. CONSTANT_COLOR = 32769,
  78733. ONE_MINUS_CONSTANT_COLOR = 32770,
  78734. CONSTANT_ALPHA = 32771,
  78735. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78736. SRC_ALPHA_SATURATE = 776
  78737. }
  78738. /** @hidden */
  78739. export interface IGLTFProperty {
  78740. extensions?: {
  78741. [key: string]: any;
  78742. };
  78743. extras?: Object;
  78744. }
  78745. /** @hidden */
  78746. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78747. name?: string;
  78748. }
  78749. /** @hidden */
  78750. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78751. bufferView: string;
  78752. byteOffset: number;
  78753. byteStride: number;
  78754. count: number;
  78755. type: string;
  78756. componentType: EComponentType;
  78757. max?: number[];
  78758. min?: number[];
  78759. name?: string;
  78760. }
  78761. /** @hidden */
  78762. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78763. buffer: string;
  78764. byteOffset: number;
  78765. byteLength: number;
  78766. byteStride: number;
  78767. target?: number;
  78768. }
  78769. /** @hidden */
  78770. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78771. uri: string;
  78772. byteLength?: number;
  78773. type?: string;
  78774. }
  78775. /** @hidden */
  78776. export interface IGLTFShader extends IGLTFChildRootProperty {
  78777. uri: string;
  78778. type: EShaderType;
  78779. }
  78780. /** @hidden */
  78781. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78782. attributes: string[];
  78783. fragmentShader: string;
  78784. vertexShader: string;
  78785. }
  78786. /** @hidden */
  78787. export interface IGLTFTechniqueParameter {
  78788. type: number;
  78789. count?: number;
  78790. semantic?: string;
  78791. node?: string;
  78792. value?: number | boolean | string | Array<any>;
  78793. source?: string;
  78794. babylonValue?: any;
  78795. }
  78796. /** @hidden */
  78797. export interface IGLTFTechniqueCommonProfile {
  78798. lightingModel: string;
  78799. texcoordBindings: Object;
  78800. parameters?: Array<any>;
  78801. }
  78802. /** @hidden */
  78803. export interface IGLTFTechniqueStatesFunctions {
  78804. blendColor?: number[];
  78805. blendEquationSeparate?: number[];
  78806. blendFuncSeparate?: number[];
  78807. colorMask: boolean[];
  78808. cullFace: number[];
  78809. }
  78810. /** @hidden */
  78811. export interface IGLTFTechniqueStates {
  78812. enable: number[];
  78813. functions: IGLTFTechniqueStatesFunctions;
  78814. }
  78815. /** @hidden */
  78816. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78817. parameters: {
  78818. [key: string]: IGLTFTechniqueParameter;
  78819. };
  78820. program: string;
  78821. attributes: {
  78822. [key: string]: string;
  78823. };
  78824. uniforms: {
  78825. [key: string]: string;
  78826. };
  78827. states: IGLTFTechniqueStates;
  78828. }
  78829. /** @hidden */
  78830. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78831. technique?: string;
  78832. values: string[];
  78833. }
  78834. /** @hidden */
  78835. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78836. attributes: {
  78837. [key: string]: string;
  78838. };
  78839. indices: string;
  78840. material: string;
  78841. mode?: number;
  78842. }
  78843. /** @hidden */
  78844. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78845. primitives: IGLTFMeshPrimitive[];
  78846. }
  78847. /** @hidden */
  78848. export interface IGLTFImage extends IGLTFChildRootProperty {
  78849. uri: string;
  78850. }
  78851. /** @hidden */
  78852. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78853. magFilter?: number;
  78854. minFilter?: number;
  78855. wrapS?: number;
  78856. wrapT?: number;
  78857. }
  78858. /** @hidden */
  78859. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78860. sampler: string;
  78861. source: string;
  78862. format?: ETextureFormat;
  78863. internalFormat?: ETextureFormat;
  78864. target?: number;
  78865. type?: number;
  78866. babylonTexture?: Texture;
  78867. }
  78868. /** @hidden */
  78869. export interface IGLTFAmbienLight {
  78870. color?: number[];
  78871. }
  78872. /** @hidden */
  78873. export interface IGLTFDirectionalLight {
  78874. color?: number[];
  78875. }
  78876. /** @hidden */
  78877. export interface IGLTFPointLight {
  78878. color?: number[];
  78879. constantAttenuation?: number;
  78880. linearAttenuation?: number;
  78881. quadraticAttenuation?: number;
  78882. }
  78883. /** @hidden */
  78884. export interface IGLTFSpotLight {
  78885. color?: number[];
  78886. constantAttenuation?: number;
  78887. fallOfAngle?: number;
  78888. fallOffExponent?: number;
  78889. linearAttenuation?: number;
  78890. quadraticAttenuation?: number;
  78891. }
  78892. /** @hidden */
  78893. export interface IGLTFLight extends IGLTFChildRootProperty {
  78894. type: string;
  78895. }
  78896. /** @hidden */
  78897. export interface IGLTFCameraOrthographic {
  78898. xmag: number;
  78899. ymag: number;
  78900. zfar: number;
  78901. znear: number;
  78902. }
  78903. /** @hidden */
  78904. export interface IGLTFCameraPerspective {
  78905. aspectRatio: number;
  78906. yfov: number;
  78907. zfar: number;
  78908. znear: number;
  78909. }
  78910. /** @hidden */
  78911. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78912. type: string;
  78913. }
  78914. /** @hidden */
  78915. export interface IGLTFAnimationChannelTarget {
  78916. id: string;
  78917. path: string;
  78918. }
  78919. /** @hidden */
  78920. export interface IGLTFAnimationChannel {
  78921. sampler: string;
  78922. target: IGLTFAnimationChannelTarget;
  78923. }
  78924. /** @hidden */
  78925. export interface IGLTFAnimationSampler {
  78926. input: string;
  78927. output: string;
  78928. interpolation?: string;
  78929. }
  78930. /** @hidden */
  78931. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78932. channels?: IGLTFAnimationChannel[];
  78933. parameters?: {
  78934. [key: string]: string;
  78935. };
  78936. samplers?: {
  78937. [key: string]: IGLTFAnimationSampler;
  78938. };
  78939. }
  78940. /** @hidden */
  78941. export interface IGLTFNodeInstanceSkin {
  78942. skeletons: string[];
  78943. skin: string;
  78944. meshes: string[];
  78945. }
  78946. /** @hidden */
  78947. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78948. bindShapeMatrix: number[];
  78949. inverseBindMatrices: string;
  78950. jointNames: string[];
  78951. babylonSkeleton?: Skeleton;
  78952. }
  78953. /** @hidden */
  78954. export interface IGLTFNode extends IGLTFChildRootProperty {
  78955. camera?: string;
  78956. children: string[];
  78957. skin?: string;
  78958. jointName?: string;
  78959. light?: string;
  78960. matrix: number[];
  78961. mesh?: string;
  78962. meshes?: string[];
  78963. rotation?: number[];
  78964. scale?: number[];
  78965. translation?: number[];
  78966. babylonNode?: Node;
  78967. }
  78968. /** @hidden */
  78969. export interface IGLTFScene extends IGLTFChildRootProperty {
  78970. nodes: string[];
  78971. }
  78972. /** @hidden */
  78973. export interface IGLTFRuntime {
  78974. extensions: {
  78975. [key: string]: any;
  78976. };
  78977. accessors: {
  78978. [key: string]: IGLTFAccessor;
  78979. };
  78980. buffers: {
  78981. [key: string]: IGLTFBuffer;
  78982. };
  78983. bufferViews: {
  78984. [key: string]: IGLTFBufferView;
  78985. };
  78986. meshes: {
  78987. [key: string]: IGLTFMesh;
  78988. };
  78989. lights: {
  78990. [key: string]: IGLTFLight;
  78991. };
  78992. cameras: {
  78993. [key: string]: IGLTFCamera;
  78994. };
  78995. nodes: {
  78996. [key: string]: IGLTFNode;
  78997. };
  78998. images: {
  78999. [key: string]: IGLTFImage;
  79000. };
  79001. textures: {
  79002. [key: string]: IGLTFTexture;
  79003. };
  79004. shaders: {
  79005. [key: string]: IGLTFShader;
  79006. };
  79007. programs: {
  79008. [key: string]: IGLTFProgram;
  79009. };
  79010. samplers: {
  79011. [key: string]: IGLTFSampler;
  79012. };
  79013. techniques: {
  79014. [key: string]: IGLTFTechnique;
  79015. };
  79016. materials: {
  79017. [key: string]: IGLTFMaterial;
  79018. };
  79019. animations: {
  79020. [key: string]: IGLTFAnimation;
  79021. };
  79022. skins: {
  79023. [key: string]: IGLTFSkins;
  79024. };
  79025. currentScene?: Object;
  79026. scenes: {
  79027. [key: string]: IGLTFScene;
  79028. };
  79029. extensionsUsed: string[];
  79030. extensionsRequired?: string[];
  79031. buffersCount: number;
  79032. shaderscount: number;
  79033. scene: Scene;
  79034. rootUrl: string;
  79035. loadedBufferCount: number;
  79036. loadedBufferViews: {
  79037. [name: string]: ArrayBufferView;
  79038. };
  79039. loadedShaderCount: number;
  79040. importOnlyMeshes: boolean;
  79041. importMeshesNames?: string[];
  79042. dummyNodes: Node[];
  79043. forAssetContainer: boolean;
  79044. }
  79045. /** @hidden */
  79046. export interface INodeToRoot {
  79047. bone: Bone;
  79048. node: IGLTFNode;
  79049. id: string;
  79050. }
  79051. /** @hidden */
  79052. export interface IJointNode {
  79053. node: IGLTFNode;
  79054. id: string;
  79055. }
  79056. }
  79057. declare module BABYLON.GLTF1 {
  79058. /**
  79059. * Utils functions for GLTF
  79060. * @hidden
  79061. */
  79062. export class GLTFUtils {
  79063. /**
  79064. * Sets the given "parameter" matrix
  79065. * @param scene: the Scene object
  79066. * @param source: the source node where to pick the matrix
  79067. * @param parameter: the GLTF technique parameter
  79068. * @param uniformName: the name of the shader's uniform
  79069. * @param shaderMaterial: the shader material
  79070. */
  79071. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79072. /**
  79073. * Sets the given "parameter" matrix
  79074. * @param shaderMaterial: the shader material
  79075. * @param uniform: the name of the shader's uniform
  79076. * @param value: the value of the uniform
  79077. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79078. */
  79079. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79080. /**
  79081. * Returns the wrap mode of the texture
  79082. * @param mode: the mode value
  79083. */
  79084. static GetWrapMode(mode: number): number;
  79085. /**
  79086. * Returns the byte stride giving an accessor
  79087. * @param accessor: the GLTF accessor objet
  79088. */
  79089. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79090. /**
  79091. * Returns the texture filter mode giving a mode value
  79092. * @param mode: the filter mode value
  79093. */
  79094. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79095. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79096. /**
  79097. * Returns a buffer from its accessor
  79098. * @param gltfRuntime: the GLTF runtime
  79099. * @param accessor: the GLTF accessor
  79100. */
  79101. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79102. /**
  79103. * Decodes a buffer view into a string
  79104. * @param view: the buffer view
  79105. */
  79106. static DecodeBufferToText(view: ArrayBufferView): string;
  79107. /**
  79108. * Returns the default material of gltf. Related to
  79109. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79110. * @param scene: the Babylon.js scene
  79111. */
  79112. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79113. private static _DefaultMaterial;
  79114. }
  79115. }
  79116. declare module BABYLON.GLTF1 {
  79117. /**
  79118. * Implementation of the base glTF spec
  79119. * @hidden
  79120. */
  79121. export class GLTFLoaderBase {
  79122. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79123. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79124. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79125. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79126. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79127. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79128. }
  79129. /**
  79130. * glTF V1 Loader
  79131. * @hidden
  79132. */
  79133. export class GLTFLoader implements IGLTFLoader {
  79134. static Extensions: {
  79135. [name: string]: GLTFLoaderExtension;
  79136. };
  79137. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79138. state: Nullable<GLTFLoaderState>;
  79139. dispose(): void;
  79140. private _importMeshAsync;
  79141. /**
  79142. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79143. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79144. * @param scene the scene the meshes should be added to
  79145. * @param forAssetContainer defines if the entities must be stored in the scene
  79146. * @param data gltf data containing information of the meshes in a loaded file
  79147. * @param rootUrl root url to load from
  79148. * @param onProgress event that fires when loading progress has occured
  79149. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79150. */
  79151. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79152. private _loadAsync;
  79153. /**
  79154. * Imports all objects from a loaded gltf file and adds them to the scene
  79155. * @param scene the scene the objects should be added to
  79156. * @param data gltf data containing information of the meshes in a loaded file
  79157. * @param rootUrl root url to load from
  79158. * @param onProgress event that fires when loading progress has occured
  79159. * @returns a promise which completes when objects have been loaded to the scene
  79160. */
  79161. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79162. private _loadShadersAsync;
  79163. private _loadBuffersAsync;
  79164. private _createNodes;
  79165. }
  79166. /** @hidden */
  79167. export abstract class GLTFLoaderExtension {
  79168. private _name;
  79169. constructor(name: string);
  79170. get name(): string;
  79171. /**
  79172. * Defines an override for loading the runtime
  79173. * Return true to stop further extensions from loading the runtime
  79174. */
  79175. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79176. /**
  79177. * Defines an onverride for creating gltf runtime
  79178. * Return true to stop further extensions from creating the runtime
  79179. */
  79180. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79181. /**
  79182. * Defines an override for loading buffers
  79183. * Return true to stop further extensions from loading this buffer
  79184. */
  79185. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79186. /**
  79187. * Defines an override for loading texture buffers
  79188. * Return true to stop further extensions from loading this texture data
  79189. */
  79190. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79191. /**
  79192. * Defines an override for creating textures
  79193. * Return true to stop further extensions from loading this texture
  79194. */
  79195. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79196. /**
  79197. * Defines an override for loading shader strings
  79198. * Return true to stop further extensions from loading this shader data
  79199. */
  79200. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79201. /**
  79202. * Defines an override for loading materials
  79203. * Return true to stop further extensions from loading this material
  79204. */
  79205. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79206. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79207. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79208. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79209. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79210. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79211. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79212. private static LoadTextureBufferAsync;
  79213. private static CreateTextureAsync;
  79214. private static ApplyExtensions;
  79215. }
  79216. }
  79217. declare module BABYLON.GLTF1 {
  79218. /** @hidden */
  79219. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79220. private _bin;
  79221. constructor();
  79222. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79223. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79224. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79225. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79226. }
  79227. }
  79228. declare module BABYLON.GLTF1 {
  79229. /** @hidden */
  79230. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79231. constructor();
  79232. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79233. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79234. private _loadTexture;
  79235. }
  79236. }
  79237. declare module BABYLON.GLTF2.Loader {
  79238. /**
  79239. * Loader interface with an index field.
  79240. */
  79241. export interface IArrayItem {
  79242. /**
  79243. * The index of this item in the array.
  79244. */
  79245. index: number;
  79246. }
  79247. /**
  79248. * Loader interface with additional members.
  79249. */
  79250. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79251. /** @hidden */
  79252. _data?: Promise<ArrayBufferView>;
  79253. /** @hidden */
  79254. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79255. }
  79256. /**
  79257. * Loader interface with additional members.
  79258. */
  79259. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79260. }
  79261. /** @hidden */
  79262. export interface _IAnimationSamplerData {
  79263. input: Float32Array;
  79264. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79265. output: Float32Array;
  79266. }
  79267. /**
  79268. * Loader interface with additional members.
  79269. */
  79270. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79271. /** @hidden */
  79272. _data?: Promise<_IAnimationSamplerData>;
  79273. }
  79274. /**
  79275. * Loader interface with additional members.
  79276. */
  79277. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79278. channels: IAnimationChannel[];
  79279. samplers: IAnimationSampler[];
  79280. /** @hidden */
  79281. _babylonAnimationGroup?: AnimationGroup;
  79282. }
  79283. /**
  79284. * Loader interface with additional members.
  79285. */
  79286. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79287. /** @hidden */
  79288. _data?: Promise<ArrayBufferView>;
  79289. }
  79290. /**
  79291. * Loader interface with additional members.
  79292. */
  79293. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79294. /** @hidden */
  79295. _data?: Promise<ArrayBufferView>;
  79296. /** @hidden */
  79297. _babylonBuffer?: Promise<Buffer>;
  79298. }
  79299. /**
  79300. * Loader interface with additional members.
  79301. */
  79302. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79303. }
  79304. /**
  79305. * Loader interface with additional members.
  79306. */
  79307. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79308. /** @hidden */
  79309. _data?: Promise<ArrayBufferView>;
  79310. }
  79311. /**
  79312. * Loader interface with additional members.
  79313. */
  79314. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79315. }
  79316. /**
  79317. * Loader interface with additional members.
  79318. */
  79319. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79320. }
  79321. /**
  79322. * Loader interface with additional members.
  79323. */
  79324. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79325. baseColorTexture?: ITextureInfo;
  79326. metallicRoughnessTexture?: ITextureInfo;
  79327. }
  79328. /**
  79329. * Loader interface with additional members.
  79330. */
  79331. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79332. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79333. normalTexture?: IMaterialNormalTextureInfo;
  79334. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79335. emissiveTexture?: ITextureInfo;
  79336. /** @hidden */
  79337. _data?: {
  79338. [babylonDrawMode: number]: {
  79339. babylonMaterial: Material;
  79340. babylonMeshes: AbstractMesh[];
  79341. promise: Promise<void>;
  79342. };
  79343. };
  79344. }
  79345. /**
  79346. * Loader interface with additional members.
  79347. */
  79348. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79349. primitives: IMeshPrimitive[];
  79350. }
  79351. /**
  79352. * Loader interface with additional members.
  79353. */
  79354. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79355. /** @hidden */
  79356. _instanceData?: {
  79357. babylonSourceMesh: Mesh;
  79358. promise: Promise<any>;
  79359. };
  79360. }
  79361. /**
  79362. * Loader interface with additional members.
  79363. */
  79364. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79365. /**
  79366. * The parent glTF node.
  79367. */
  79368. parent?: INode;
  79369. /** @hidden */
  79370. _babylonTransformNode?: TransformNode;
  79371. /** @hidden */
  79372. _primitiveBabylonMeshes?: AbstractMesh[];
  79373. /** @hidden */
  79374. _babylonBones?: Bone[];
  79375. /** @hidden */
  79376. _numMorphTargets?: number;
  79377. }
  79378. /** @hidden */
  79379. export interface _ISamplerData {
  79380. noMipMaps: boolean;
  79381. samplingMode: number;
  79382. wrapU: number;
  79383. wrapV: number;
  79384. }
  79385. /**
  79386. * Loader interface with additional members.
  79387. */
  79388. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79389. /** @hidden */
  79390. _data?: _ISamplerData;
  79391. }
  79392. /**
  79393. * Loader interface with additional members.
  79394. */
  79395. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79396. }
  79397. /**
  79398. * Loader interface with additional members.
  79399. */
  79400. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79401. /** @hidden */
  79402. _data?: {
  79403. babylonSkeleton: Skeleton;
  79404. promise: Promise<void>;
  79405. };
  79406. }
  79407. /**
  79408. * Loader interface with additional members.
  79409. */
  79410. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79411. }
  79412. /**
  79413. * Loader interface with additional members.
  79414. */
  79415. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79416. }
  79417. /**
  79418. * Loader interface with additional members.
  79419. */
  79420. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79421. accessors?: IAccessor[];
  79422. animations?: IAnimation[];
  79423. buffers?: IBuffer[];
  79424. bufferViews?: IBufferView[];
  79425. cameras?: ICamera[];
  79426. images?: IImage[];
  79427. materials?: IMaterial[];
  79428. meshes?: IMesh[];
  79429. nodes?: INode[];
  79430. samplers?: ISampler[];
  79431. scenes?: IScene[];
  79432. skins?: ISkin[];
  79433. textures?: ITexture[];
  79434. }
  79435. }
  79436. declare module BABYLON.GLTF2 {
  79437. /**
  79438. * Interface for a glTF loader extension.
  79439. */
  79440. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79441. /**
  79442. * Called after the loader state changes to LOADING.
  79443. */
  79444. onLoading?(): void;
  79445. /**
  79446. * Called after the loader state changes to READY.
  79447. */
  79448. onReady?(): void;
  79449. /**
  79450. * Define this method to modify the default behavior when loading scenes.
  79451. * @param context The context when loading the asset
  79452. * @param scene The glTF scene property
  79453. * @returns A promise that resolves when the load is complete or null if not handled
  79454. */
  79455. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79456. /**
  79457. * Define this method to modify the default behavior when loading nodes.
  79458. * @param context The context when loading the asset
  79459. * @param node The glTF node property
  79460. * @param assign A function called synchronously after parsing the glTF properties
  79461. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79462. */
  79463. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79464. /**
  79465. * Define this method to modify the default behavior when loading cameras.
  79466. * @param context The context when loading the asset
  79467. * @param camera The glTF camera property
  79468. * @param assign A function called synchronously after parsing the glTF properties
  79469. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79470. */
  79471. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79472. /**
  79473. * @hidden
  79474. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79475. * @param context The context when loading the asset
  79476. * @param primitive The glTF mesh primitive property
  79477. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79478. */
  79479. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79480. /**
  79481. * @hidden
  79482. * Define this method to modify the default behavior when loading data for mesh primitives.
  79483. * @param context The context when loading the asset
  79484. * @param name The mesh name when loading the asset
  79485. * @param node The glTF node when loading the asset
  79486. * @param mesh The glTF mesh when loading the asset
  79487. * @param primitive The glTF mesh primitive property
  79488. * @param assign A function called synchronously after parsing the glTF properties
  79489. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79490. */
  79491. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79492. /**
  79493. * @hidden
  79494. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79495. * @param context The context when loading the asset
  79496. * @param material The glTF material property
  79497. * @param assign A function called synchronously after parsing the glTF properties
  79498. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79499. */
  79500. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79501. /**
  79502. * Define this method to modify the default behavior when creating materials.
  79503. * @param context The context when loading the asset
  79504. * @param material The glTF material property
  79505. * @param babylonDrawMode The draw mode for the Babylon material
  79506. * @returns The Babylon material or null if not handled
  79507. */
  79508. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79509. /**
  79510. * Define this method to modify the default behavior when loading material properties.
  79511. * @param context The context when loading the asset
  79512. * @param material The glTF material property
  79513. * @param babylonMaterial The Babylon material
  79514. * @returns A promise that resolves when the load is complete or null if not handled
  79515. */
  79516. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79517. /**
  79518. * Define this method to modify the default behavior when loading texture infos.
  79519. * @param context The context when loading the asset
  79520. * @param textureInfo The glTF texture info property
  79521. * @param assign A function called synchronously after parsing the glTF properties
  79522. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79523. */
  79524. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79525. /**
  79526. * @hidden
  79527. * Define this method to modify the default behavior when loading textures.
  79528. * @param context The context when loading the asset
  79529. * @param texture The glTF texture property
  79530. * @param assign A function called synchronously after parsing the glTF properties
  79531. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79532. */
  79533. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79534. /**
  79535. * Define this method to modify the default behavior when loading animations.
  79536. * @param context The context when loading the asset
  79537. * @param animation The glTF animation property
  79538. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79539. */
  79540. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79541. /**
  79542. * @hidden
  79543. * Define this method to modify the default behavior when loading skins.
  79544. * @param context The context when loading the asset
  79545. * @param node The glTF node property
  79546. * @param skin The glTF skin property
  79547. * @returns A promise that resolves when the load is complete or null if not handled
  79548. */
  79549. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79550. /**
  79551. * @hidden
  79552. * Define this method to modify the default behavior when loading uris.
  79553. * @param context The context when loading the asset
  79554. * @param property The glTF property associated with the uri
  79555. * @param uri The uri to load
  79556. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79557. */
  79558. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79559. /**
  79560. * Define this method to modify the default behavior when loading buffer views.
  79561. * @param context The context when loading the asset
  79562. * @param bufferView The glTF buffer view property
  79563. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79564. */
  79565. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79566. /**
  79567. * Define this method to modify the default behavior when loading buffers.
  79568. * @param context The context when loading the asset
  79569. * @param buffer The glTF buffer property
  79570. * @param byteOffset The byte offset to load
  79571. * @param byteLength The byte length to load
  79572. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79573. */
  79574. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79575. }
  79576. }
  79577. declare module BABYLON.GLTF2 {
  79578. /**
  79579. * Helper class for working with arrays when loading the glTF asset
  79580. */
  79581. export class ArrayItem {
  79582. /**
  79583. * Gets an item from the given array.
  79584. * @param context The context when loading the asset
  79585. * @param array The array to get the item from
  79586. * @param index The index to the array
  79587. * @returns The array item
  79588. */
  79589. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79590. /**
  79591. * Assign an `index` field to each item of the given array.
  79592. * @param array The array of items
  79593. */
  79594. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79595. }
  79596. /**
  79597. * The glTF 2.0 loader
  79598. */
  79599. export class GLTFLoader implements IGLTFLoader {
  79600. /** @hidden */
  79601. _completePromises: Promise<any>[];
  79602. /** @hidden */
  79603. _forAssetContainer: boolean;
  79604. /** Storage */
  79605. _babylonLights: Light[];
  79606. /** @hidden */
  79607. _disableInstancedMesh: number;
  79608. private _disposed;
  79609. private _parent;
  79610. private _state;
  79611. private _extensions;
  79612. private _rootUrl;
  79613. private _fileName;
  79614. private _uniqueRootUrl;
  79615. private _gltf;
  79616. private _bin;
  79617. private _babylonScene;
  79618. private _rootBabylonMesh;
  79619. private _defaultBabylonMaterialData;
  79620. private static _RegisteredExtensions;
  79621. /**
  79622. * The default glTF sampler.
  79623. */
  79624. static readonly DefaultSampler: ISampler;
  79625. /**
  79626. * Registers a loader extension.
  79627. * @param name The name of the loader extension.
  79628. * @param factory The factory function that creates the loader extension.
  79629. */
  79630. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79631. /**
  79632. * Unregisters a loader extension.
  79633. * @param name The name of the loader extension.
  79634. * @returns A boolean indicating whether the extension has been unregistered
  79635. */
  79636. static UnregisterExtension(name: string): boolean;
  79637. /**
  79638. * The loader state.
  79639. */
  79640. get state(): Nullable<GLTFLoaderState>;
  79641. /**
  79642. * The object that represents the glTF JSON.
  79643. */
  79644. get gltf(): IGLTF;
  79645. /**
  79646. * The BIN chunk of a binary glTF.
  79647. */
  79648. get bin(): Nullable<IDataBuffer>;
  79649. /**
  79650. * The parent file loader.
  79651. */
  79652. get parent(): GLTFFileLoader;
  79653. /**
  79654. * The Babylon scene when loading the asset.
  79655. */
  79656. get babylonScene(): Scene;
  79657. /**
  79658. * The root Babylon mesh when loading the asset.
  79659. */
  79660. get rootBabylonMesh(): Mesh;
  79661. /** @hidden */
  79662. constructor(parent: GLTFFileLoader);
  79663. /** @hidden */
  79664. dispose(): void;
  79665. /** @hidden */
  79666. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79667. /** @hidden */
  79668. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79669. private _loadAsync;
  79670. private _loadData;
  79671. private _setupData;
  79672. private _loadExtensions;
  79673. private _checkExtensions;
  79674. private _setState;
  79675. private _createRootNode;
  79676. /**
  79677. * Loads a glTF scene.
  79678. * @param context The context when loading the asset
  79679. * @param scene The glTF scene property
  79680. * @returns A promise that resolves when the load is complete
  79681. */
  79682. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79683. private _forEachPrimitive;
  79684. private _getMeshes;
  79685. private _getTransformNodes;
  79686. private _getSkeletons;
  79687. private _getAnimationGroups;
  79688. private _startAnimations;
  79689. /**
  79690. * Loads a glTF node.
  79691. * @param context The context when loading the asset
  79692. * @param node The glTF node property
  79693. * @param assign A function called synchronously after parsing the glTF properties
  79694. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79695. */
  79696. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79697. private _loadMeshAsync;
  79698. /**
  79699. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79700. * @param context The context when loading the asset
  79701. * @param name The mesh name when loading the asset
  79702. * @param node The glTF node when loading the asset
  79703. * @param mesh The glTF mesh when loading the asset
  79704. * @param primitive The glTF mesh primitive property
  79705. * @param assign A function called synchronously after parsing the glTF properties
  79706. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79707. */
  79708. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79709. private _loadVertexDataAsync;
  79710. private _createMorphTargets;
  79711. private _loadMorphTargetsAsync;
  79712. private _loadMorphTargetVertexDataAsync;
  79713. private static _LoadTransform;
  79714. private _loadSkinAsync;
  79715. private _loadBones;
  79716. private _loadBone;
  79717. private _loadSkinInverseBindMatricesDataAsync;
  79718. private _updateBoneMatrices;
  79719. private _getNodeMatrix;
  79720. /**
  79721. * Loads a glTF camera.
  79722. * @param context The context when loading the asset
  79723. * @param camera The glTF camera property
  79724. * @param assign A function called synchronously after parsing the glTF properties
  79725. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79726. */
  79727. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79728. private _loadAnimationsAsync;
  79729. /**
  79730. * Loads a glTF animation.
  79731. * @param context The context when loading the asset
  79732. * @param animation The glTF animation property
  79733. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79734. */
  79735. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79736. /**
  79737. * @hidden Loads a glTF animation channel.
  79738. * @param context The context when loading the asset
  79739. * @param animationContext The context of the animation when loading the asset
  79740. * @param animation The glTF animation property
  79741. * @param channel The glTF animation channel property
  79742. * @param babylonAnimationGroup The babylon animation group property
  79743. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79744. * @returns A void promise when the channel load is complete
  79745. */
  79746. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79747. private _loadAnimationSamplerAsync;
  79748. private _loadBufferAsync;
  79749. /**
  79750. * Loads a glTF buffer view.
  79751. * @param context The context when loading the asset
  79752. * @param bufferView The glTF buffer view property
  79753. * @returns A promise that resolves with the loaded data when the load is complete
  79754. */
  79755. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79756. private _loadAccessorAsync;
  79757. /** @hidden */
  79758. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79759. private _loadIndicesAccessorAsync;
  79760. private _loadVertexBufferViewAsync;
  79761. private _loadVertexAccessorAsync;
  79762. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79763. /** @hidden */
  79764. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79765. private _createDefaultMaterial;
  79766. /**
  79767. * Creates a Babylon material from a glTF material.
  79768. * @param context The context when loading the asset
  79769. * @param material The glTF material property
  79770. * @param babylonDrawMode The draw mode for the Babylon material
  79771. * @returns The Babylon material
  79772. */
  79773. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79774. /**
  79775. * Loads properties from a glTF material into a Babylon material.
  79776. * @param context The context when loading the asset
  79777. * @param material The glTF material property
  79778. * @param babylonMaterial The Babylon material
  79779. * @returns A promise that resolves when the load is complete
  79780. */
  79781. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79782. /**
  79783. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79784. * @param context The context when loading the asset
  79785. * @param material The glTF material property
  79786. * @param babylonMaterial The Babylon material
  79787. * @returns A promise that resolves when the load is complete
  79788. */
  79789. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79790. /**
  79791. * Loads the alpha properties from a glTF material into a Babylon material.
  79792. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79793. * @param context The context when loading the asset
  79794. * @param material The glTF material property
  79795. * @param babylonMaterial The Babylon material
  79796. */
  79797. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79798. /**
  79799. * Loads a glTF texture info.
  79800. * @param context The context when loading the asset
  79801. * @param textureInfo The glTF texture info property
  79802. * @param assign A function called synchronously after parsing the glTF properties
  79803. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79804. */
  79805. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79806. /** @hidden */
  79807. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79808. /** @hidden */
  79809. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79810. private _loadSampler;
  79811. /**
  79812. * Loads a glTF image.
  79813. * @param context The context when loading the asset
  79814. * @param image The glTF image property
  79815. * @returns A promise that resolves with the loaded data when the load is complete
  79816. */
  79817. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79818. /**
  79819. * Loads a glTF uri.
  79820. * @param context The context when loading the asset
  79821. * @param property The glTF property associated with the uri
  79822. * @param uri The base64 or relative uri
  79823. * @returns A promise that resolves with the loaded data when the load is complete
  79824. */
  79825. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79826. /**
  79827. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79828. * @param babylonObject the Babylon object with metadata
  79829. * @param pointer the JSON pointer
  79830. */
  79831. static AddPointerMetadata(babylonObject: {
  79832. metadata: any;
  79833. }, pointer: string): void;
  79834. private static _GetTextureWrapMode;
  79835. private static _GetTextureSamplingMode;
  79836. private static _GetTypedArrayConstructor;
  79837. private static _GetTypedArray;
  79838. private static _GetNumComponents;
  79839. private static _ValidateUri;
  79840. private static _GetDrawMode;
  79841. private _compileMaterialsAsync;
  79842. private _compileShadowGeneratorsAsync;
  79843. private _forEachExtensions;
  79844. private _applyExtensions;
  79845. private _extensionsOnLoading;
  79846. private _extensionsOnReady;
  79847. private _extensionsLoadSceneAsync;
  79848. private _extensionsLoadNodeAsync;
  79849. private _extensionsLoadCameraAsync;
  79850. private _extensionsLoadVertexDataAsync;
  79851. private _extensionsLoadMeshPrimitiveAsync;
  79852. private _extensionsLoadMaterialAsync;
  79853. private _extensionsCreateMaterial;
  79854. private _extensionsLoadMaterialPropertiesAsync;
  79855. private _extensionsLoadTextureInfoAsync;
  79856. private _extensionsLoadTextureAsync;
  79857. private _extensionsLoadAnimationAsync;
  79858. private _extensionsLoadSkinAsync;
  79859. private _extensionsLoadUriAsync;
  79860. private _extensionsLoadBufferViewAsync;
  79861. private _extensionsLoadBufferAsync;
  79862. /**
  79863. * Helper method called by a loader extension to load an glTF extension.
  79864. * @param context The context when loading the asset
  79865. * @param property The glTF property to load the extension from
  79866. * @param extensionName The name of the extension to load
  79867. * @param actionAsync The action to run
  79868. * @returns The promise returned by actionAsync or null if the extension does not exist
  79869. */
  79870. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79871. /**
  79872. * Helper method called by a loader extension to load a glTF extra.
  79873. * @param context The context when loading the asset
  79874. * @param property The glTF property to load the extra from
  79875. * @param extensionName The name of the extension to load
  79876. * @param actionAsync The action to run
  79877. * @returns The promise returned by actionAsync or null if the extra does not exist
  79878. */
  79879. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79880. /**
  79881. * Checks for presence of an extension.
  79882. * @param name The name of the extension to check
  79883. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79884. */
  79885. isExtensionUsed(name: string): boolean;
  79886. /**
  79887. * Increments the indentation level and logs a message.
  79888. * @param message The message to log
  79889. */
  79890. logOpen(message: string): void;
  79891. /**
  79892. * Decrements the indentation level.
  79893. */
  79894. logClose(): void;
  79895. /**
  79896. * Logs a message
  79897. * @param message The message to log
  79898. */
  79899. log(message: string): void;
  79900. /**
  79901. * Starts a performance counter.
  79902. * @param counterName The name of the performance counter
  79903. */
  79904. startPerformanceCounter(counterName: string): void;
  79905. /**
  79906. * Ends a performance counter.
  79907. * @param counterName The name of the performance counter
  79908. */
  79909. endPerformanceCounter(counterName: string): void;
  79910. }
  79911. }
  79912. declare module BABYLON.GLTF2.Loader.Extensions {
  79913. /**
  79914. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79915. */
  79916. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79917. /**
  79918. * The name of this extension.
  79919. */
  79920. readonly name: string;
  79921. /**
  79922. * Defines whether this extension is enabled.
  79923. */
  79924. enabled: boolean;
  79925. private _loader;
  79926. private _lights?;
  79927. /** @hidden */
  79928. constructor(loader: GLTFLoader);
  79929. /** @hidden */
  79930. dispose(): void;
  79931. /** @hidden */
  79932. onLoading(): void;
  79933. /** @hidden */
  79934. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79935. private _loadLightAsync;
  79936. }
  79937. }
  79938. declare module BABYLON.GLTF2.Loader.Extensions {
  79939. /**
  79940. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79941. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79942. * !!! Experimental Extension Subject to Changes !!!
  79943. */
  79944. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79945. /**
  79946. * The name of this extension.
  79947. */
  79948. readonly name: string;
  79949. /**
  79950. * Defines whether this extension is enabled.
  79951. */
  79952. enabled: boolean;
  79953. private _loader;
  79954. /** @hidden */
  79955. constructor(loader: GLTFLoader);
  79956. /** @hidden */
  79957. dispose(): void;
  79958. /** @hidden */
  79959. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79960. }
  79961. }
  79962. declare module BABYLON.GLTF2.Loader.Extensions {
  79963. /**
  79964. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79965. */
  79966. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79967. /**
  79968. * The name of this extension.
  79969. */
  79970. readonly name: string;
  79971. /**
  79972. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79973. */
  79974. dracoCompression?: DracoCompression;
  79975. /**
  79976. * Defines whether this extension is enabled.
  79977. */
  79978. enabled: boolean;
  79979. private _loader;
  79980. /** @hidden */
  79981. constructor(loader: GLTFLoader);
  79982. /** @hidden */
  79983. dispose(): void;
  79984. /** @hidden */
  79985. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79986. }
  79987. }
  79988. declare module BABYLON.GLTF2.Loader.Extensions {
  79989. /**
  79990. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79991. */
  79992. export class KHR_lights implements IGLTFLoaderExtension {
  79993. /**
  79994. * The name of this extension.
  79995. */
  79996. readonly name: string;
  79997. /**
  79998. * Defines whether this extension is enabled.
  79999. */
  80000. enabled: boolean;
  80001. private _loader;
  80002. private _lights?;
  80003. /** @hidden */
  80004. constructor(loader: GLTFLoader);
  80005. /** @hidden */
  80006. dispose(): void;
  80007. /** @hidden */
  80008. onLoading(): void;
  80009. /** @hidden */
  80010. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80011. }
  80012. }
  80013. declare module BABYLON.GLTF2.Loader.Extensions {
  80014. /**
  80015. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80016. */
  80017. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80018. /**
  80019. * The name of this extension.
  80020. */
  80021. readonly name: string;
  80022. /**
  80023. * Defines whether this extension is enabled.
  80024. */
  80025. enabled: boolean;
  80026. /**
  80027. * Defines a number that determines the order the extensions are applied.
  80028. */
  80029. order: number;
  80030. private _loader;
  80031. /** @hidden */
  80032. constructor(loader: GLTFLoader);
  80033. /** @hidden */
  80034. dispose(): void;
  80035. /** @hidden */
  80036. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80037. private _loadSpecularGlossinessPropertiesAsync;
  80038. }
  80039. }
  80040. declare module BABYLON.GLTF2.Loader.Extensions {
  80041. /**
  80042. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80043. */
  80044. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80045. /**
  80046. * The name of this extension.
  80047. */
  80048. readonly name: string;
  80049. /**
  80050. * Defines whether this extension is enabled.
  80051. */
  80052. enabled: boolean;
  80053. /**
  80054. * Defines a number that determines the order the extensions are applied.
  80055. */
  80056. order: number;
  80057. private _loader;
  80058. /** @hidden */
  80059. constructor(loader: GLTFLoader);
  80060. /** @hidden */
  80061. dispose(): void;
  80062. /** @hidden */
  80063. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80064. private _loadUnlitPropertiesAsync;
  80065. }
  80066. }
  80067. declare module BABYLON.GLTF2.Loader.Extensions {
  80068. /**
  80069. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80070. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80071. * !!! Experimental Extension Subject to Changes !!!
  80072. */
  80073. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80074. /**
  80075. * The name of this extension.
  80076. */
  80077. readonly name: string;
  80078. /**
  80079. * Defines whether this extension is enabled.
  80080. */
  80081. enabled: boolean;
  80082. /**
  80083. * Defines a number that determines the order the extensions are applied.
  80084. */
  80085. order: number;
  80086. private _loader;
  80087. /** @hidden */
  80088. constructor(loader: GLTFLoader);
  80089. /** @hidden */
  80090. dispose(): void;
  80091. /** @hidden */
  80092. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80093. private _loadClearCoatPropertiesAsync;
  80094. }
  80095. }
  80096. declare module BABYLON.GLTF2.Loader.Extensions {
  80097. /**
  80098. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80099. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80100. * !!! Experimental Extension Subject to Changes !!!
  80101. */
  80102. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80103. /**
  80104. * The name of this extension.
  80105. */
  80106. readonly name: string;
  80107. /**
  80108. * Defines whether this extension is enabled.
  80109. */
  80110. enabled: boolean;
  80111. /**
  80112. * Defines a number that determines the order the extensions are applied.
  80113. */
  80114. order: number;
  80115. private _loader;
  80116. /** @hidden */
  80117. constructor(loader: GLTFLoader);
  80118. /** @hidden */
  80119. dispose(): void;
  80120. /** @hidden */
  80121. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80122. private _loadSheenPropertiesAsync;
  80123. }
  80124. }
  80125. declare module BABYLON.GLTF2.Loader.Extensions {
  80126. /**
  80127. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80128. * !!! Experimental Extension Subject to Changes !!!
  80129. */
  80130. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80131. /**
  80132. * The name of this extension.
  80133. */
  80134. readonly name: string;
  80135. /**
  80136. * Defines whether this extension is enabled.
  80137. */
  80138. enabled: boolean;
  80139. /**
  80140. * Defines a number that determines the order the extensions are applied.
  80141. */
  80142. order: number;
  80143. private _loader;
  80144. /** @hidden */
  80145. constructor(loader: GLTFLoader);
  80146. /** @hidden */
  80147. dispose(): void;
  80148. /** @hidden */
  80149. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80150. private _loadSpecularPropertiesAsync;
  80151. }
  80152. }
  80153. declare module BABYLON.GLTF2.Loader.Extensions {
  80154. /**
  80155. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80156. * !!! Experimental Extension Subject to Changes !!!
  80157. */
  80158. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80159. /**
  80160. * Default ior Value from the spec.
  80161. */
  80162. private static readonly _DEFAULT_IOR;
  80163. /**
  80164. * The name of this extension.
  80165. */
  80166. readonly name: string;
  80167. /**
  80168. * Defines whether this extension is enabled.
  80169. */
  80170. enabled: boolean;
  80171. /**
  80172. * Defines a number that determines the order the extensions are applied.
  80173. */
  80174. order: number;
  80175. private _loader;
  80176. /** @hidden */
  80177. constructor(loader: GLTFLoader);
  80178. /** @hidden */
  80179. dispose(): void;
  80180. /** @hidden */
  80181. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80182. private _loadIorPropertiesAsync;
  80183. }
  80184. }
  80185. declare module BABYLON.GLTF2.Loader.Extensions {
  80186. /**
  80187. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80188. * !!! Experimental Extension Subject to Changes !!!
  80189. */
  80190. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80191. /**
  80192. * The name of this extension.
  80193. */
  80194. readonly name: string;
  80195. /**
  80196. * Defines whether this extension is enabled.
  80197. */
  80198. enabled: boolean;
  80199. private _loader;
  80200. /**
  80201. * The default variant name.
  80202. */
  80203. defaultVariant: string | undefined;
  80204. private _tagsToMap;
  80205. /** @hidden */
  80206. constructor(loader: GLTFLoader);
  80207. /** @hidden */
  80208. dispose(): void;
  80209. /**
  80210. * Return a list of available variants for this asset.
  80211. * @returns {string[]}
  80212. */
  80213. getVariants(): string[];
  80214. /**
  80215. * Select a variant by providing a list of variant tag names.
  80216. *
  80217. * @param {(string | string[])} variantName
  80218. */
  80219. selectVariant(variantName: string | string[]): void;
  80220. /**
  80221. * Select a variant by providing a single variant tag.
  80222. *
  80223. * @param {string} variantName
  80224. */
  80225. selectVariantTag(variantName: string): void;
  80226. /** @hidden */
  80227. onLoading(): void;
  80228. /** @hidden */
  80229. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80230. }
  80231. }
  80232. declare module BABYLON.GLTF2.Loader.Extensions {
  80233. /**
  80234. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80235. * !!! Experimental Extension Subject to Changes !!!
  80236. */
  80237. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80238. /**
  80239. * The name of this extension.
  80240. */
  80241. readonly name: string;
  80242. /**
  80243. * Defines whether this extension is enabled.
  80244. */
  80245. enabled: boolean;
  80246. /**
  80247. * Defines a number that determines the order the extensions are applied.
  80248. */
  80249. order: number;
  80250. private _loader;
  80251. /** @hidden */
  80252. constructor(loader: GLTFLoader);
  80253. /** @hidden */
  80254. dispose(): void;
  80255. /** @hidden */
  80256. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80257. private _loadTransparentPropertiesAsync;
  80258. }
  80259. }
  80260. declare module BABYLON.GLTF2.Loader.Extensions {
  80261. /**
  80262. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80263. */
  80264. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80265. /**
  80266. * The name of this extension.
  80267. */
  80268. readonly name: string;
  80269. /**
  80270. * Defines whether this extension is enabled.
  80271. */
  80272. enabled: boolean;
  80273. /** @hidden */
  80274. constructor(loader: GLTFLoader);
  80275. /** @hidden */
  80276. dispose(): void;
  80277. }
  80278. }
  80279. declare module BABYLON.GLTF2.Loader.Extensions {
  80280. /**
  80281. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80282. * !!! Experimental Extension Subject to Changes !!!
  80283. */
  80284. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80285. /** The name of this extension. */
  80286. readonly name: string;
  80287. /** Defines whether this extension is enabled. */
  80288. enabled: boolean;
  80289. private _loader;
  80290. /** @hidden */
  80291. constructor(loader: GLTFLoader);
  80292. /** @hidden */
  80293. dispose(): void;
  80294. /** @hidden */
  80295. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80296. }
  80297. }
  80298. declare module BABYLON.GLTF2.Loader.Extensions {
  80299. /**
  80300. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80301. */
  80302. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80303. /**
  80304. * The name of this extension.
  80305. */
  80306. readonly name: string;
  80307. /**
  80308. * Defines whether this extension is enabled.
  80309. */
  80310. enabled: boolean;
  80311. private _loader;
  80312. /** @hidden */
  80313. constructor(loader: GLTFLoader);
  80314. /** @hidden */
  80315. dispose(): void;
  80316. /** @hidden */
  80317. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80318. }
  80319. }
  80320. declare module BABYLON.GLTF2.Loader.Extensions {
  80321. /**
  80322. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80323. * !!! Experimental Extension Subject to Changes !!!
  80324. */
  80325. export class KHR_xmp implements IGLTFLoaderExtension {
  80326. /**
  80327. * The name of this extension.
  80328. */
  80329. readonly name: string;
  80330. /**
  80331. * Defines whether this extension is enabled.
  80332. */
  80333. enabled: boolean;
  80334. /**
  80335. * Defines a number that determines the order the extensions are applied.
  80336. */
  80337. order: number;
  80338. private _loader;
  80339. /** @hidden */
  80340. constructor(loader: GLTFLoader);
  80341. /** @hidden */
  80342. dispose(): void;
  80343. /**
  80344. * Called after the loader state changes to LOADING.
  80345. */
  80346. onLoading(): void;
  80347. }
  80348. }
  80349. declare module BABYLON.GLTF2.Loader.Extensions {
  80350. /**
  80351. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80352. */
  80353. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80354. /**
  80355. * The name of this extension.
  80356. */
  80357. readonly name: string;
  80358. /**
  80359. * Defines whether this extension is enabled.
  80360. */
  80361. enabled: boolean;
  80362. private _loader;
  80363. private _clips;
  80364. private _emitters;
  80365. /** @hidden */
  80366. constructor(loader: GLTFLoader);
  80367. /** @hidden */
  80368. dispose(): void;
  80369. /** @hidden */
  80370. onLoading(): void;
  80371. /** @hidden */
  80372. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80373. /** @hidden */
  80374. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80375. /** @hidden */
  80376. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80377. private _loadClipAsync;
  80378. private _loadEmitterAsync;
  80379. private _getEventAction;
  80380. private _loadAnimationEventAsync;
  80381. }
  80382. }
  80383. declare module BABYLON.GLTF2.Loader.Extensions {
  80384. /**
  80385. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80386. */
  80387. export class MSFT_lod implements IGLTFLoaderExtension {
  80388. /**
  80389. * The name of this extension.
  80390. */
  80391. readonly name: string;
  80392. /**
  80393. * Defines whether this extension is enabled.
  80394. */
  80395. enabled: boolean;
  80396. /**
  80397. * Defines a number that determines the order the extensions are applied.
  80398. */
  80399. order: number;
  80400. /**
  80401. * Maximum number of LODs to load, starting from the lowest LOD.
  80402. */
  80403. maxLODsToLoad: number;
  80404. /**
  80405. * Observable raised when all node LODs of one level are loaded.
  80406. * The event data is the index of the loaded LOD starting from zero.
  80407. * Dispose the loader to cancel the loading of the next level of LODs.
  80408. */
  80409. onNodeLODsLoadedObservable: Observable<number>;
  80410. /**
  80411. * Observable raised when all material LODs of one level are loaded.
  80412. * The event data is the index of the loaded LOD starting from zero.
  80413. * Dispose the loader to cancel the loading of the next level of LODs.
  80414. */
  80415. onMaterialLODsLoadedObservable: Observable<number>;
  80416. private _loader;
  80417. private _bufferLODs;
  80418. private _nodeIndexLOD;
  80419. private _nodeSignalLODs;
  80420. private _nodePromiseLODs;
  80421. private _nodeBufferLODs;
  80422. private _materialIndexLOD;
  80423. private _materialSignalLODs;
  80424. private _materialPromiseLODs;
  80425. private _materialBufferLODs;
  80426. /** @hidden */
  80427. constructor(loader: GLTFLoader);
  80428. /** @hidden */
  80429. dispose(): void;
  80430. /** @hidden */
  80431. onReady(): void;
  80432. /** @hidden */
  80433. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80434. /** @hidden */
  80435. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80436. /** @hidden */
  80437. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80438. /** @hidden */
  80439. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80440. /** @hidden */
  80441. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80442. private _loadBufferLOD;
  80443. /**
  80444. * Gets an array of LOD properties from lowest to highest.
  80445. */
  80446. private _getLODs;
  80447. private _disposeTransformNode;
  80448. private _disposeMaterials;
  80449. }
  80450. }
  80451. declare module BABYLON.GLTF2.Loader.Extensions {
  80452. /** @hidden */
  80453. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80454. readonly name: string;
  80455. enabled: boolean;
  80456. private _loader;
  80457. constructor(loader: GLTFLoader);
  80458. dispose(): void;
  80459. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80460. }
  80461. }
  80462. declare module BABYLON.GLTF2.Loader.Extensions {
  80463. /** @hidden */
  80464. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80465. readonly name: string;
  80466. enabled: boolean;
  80467. private _loader;
  80468. constructor(loader: GLTFLoader);
  80469. dispose(): void;
  80470. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80471. }
  80472. }
  80473. declare module BABYLON.GLTF2.Loader.Extensions {
  80474. /**
  80475. * Store glTF extras (if present) in BJS objects' metadata
  80476. */
  80477. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80478. /**
  80479. * The name of this extension.
  80480. */
  80481. readonly name: string;
  80482. /**
  80483. * Defines whether this extension is enabled.
  80484. */
  80485. enabled: boolean;
  80486. private _loader;
  80487. private _assignExtras;
  80488. /** @hidden */
  80489. constructor(loader: GLTFLoader);
  80490. /** @hidden */
  80491. dispose(): void;
  80492. /** @hidden */
  80493. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80494. /** @hidden */
  80495. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80496. /** @hidden */
  80497. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80498. }
  80499. }
  80500. declare module BABYLON {
  80501. /**
  80502. * Class reading and parsing the MTL file bundled with the obj file.
  80503. */
  80504. export class MTLFileLoader {
  80505. /**
  80506. * Invert Y-Axis of referenced textures on load
  80507. */
  80508. static INVERT_TEXTURE_Y: boolean;
  80509. /**
  80510. * All material loaded from the mtl will be set here
  80511. */
  80512. materials: StandardMaterial[];
  80513. /**
  80514. * This function will read the mtl file and create each material described inside
  80515. * This function could be improve by adding :
  80516. * -some component missing (Ni, Tf...)
  80517. * -including the specific options available
  80518. *
  80519. * @param scene defines the scene the material will be created in
  80520. * @param data defines the mtl data to parse
  80521. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80522. * @param forAssetContainer defines if the material should be registered in the scene
  80523. */
  80524. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80525. /**
  80526. * Gets the texture for the material.
  80527. *
  80528. * If the material is imported from input file,
  80529. * We sanitize the url to ensure it takes the textre from aside the material.
  80530. *
  80531. * @param rootUrl The root url to load from
  80532. * @param value The value stored in the mtl
  80533. * @return The Texture
  80534. */
  80535. private static _getTexture;
  80536. }
  80537. }
  80538. declare module BABYLON {
  80539. /**
  80540. * Options for loading OBJ/MTL files
  80541. */
  80542. type MeshLoadOptions = {
  80543. /**
  80544. * Defines if UVs are optimized by default during load.
  80545. */
  80546. OptimizeWithUV: boolean;
  80547. /**
  80548. * Defines custom scaling of UV coordinates of loaded meshes.
  80549. */
  80550. UVScaling: Vector2;
  80551. /**
  80552. * Invert model on y-axis (does a model scaling inversion)
  80553. */
  80554. InvertY: boolean;
  80555. /**
  80556. * Invert Y-Axis of referenced textures on load
  80557. */
  80558. InvertTextureY: boolean;
  80559. /**
  80560. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80561. */
  80562. ImportVertexColors: boolean;
  80563. /**
  80564. * Compute the normals for the model, even if normals are present in the file.
  80565. */
  80566. ComputeNormals: boolean;
  80567. /**
  80568. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80569. */
  80570. SkipMaterials: boolean;
  80571. /**
  80572. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80573. */
  80574. MaterialLoadingFailsSilently: boolean;
  80575. };
  80576. /**
  80577. * OBJ file type loader.
  80578. * This is a babylon scene loader plugin.
  80579. */
  80580. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80581. /**
  80582. * Defines if UVs are optimized by default during load.
  80583. */
  80584. static OPTIMIZE_WITH_UV: boolean;
  80585. /**
  80586. * Invert model on y-axis (does a model scaling inversion)
  80587. */
  80588. static INVERT_Y: boolean;
  80589. /**
  80590. * Invert Y-Axis of referenced textures on load
  80591. */
  80592. static get INVERT_TEXTURE_Y(): boolean;
  80593. static set INVERT_TEXTURE_Y(value: boolean);
  80594. /**
  80595. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80596. */
  80597. static IMPORT_VERTEX_COLORS: boolean;
  80598. /**
  80599. * Compute the normals for the model, even if normals are present in the file.
  80600. */
  80601. static COMPUTE_NORMALS: boolean;
  80602. /**
  80603. * Defines custom scaling of UV coordinates of loaded meshes.
  80604. */
  80605. static UV_SCALING: Vector2;
  80606. /**
  80607. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80608. */
  80609. static SKIP_MATERIALS: boolean;
  80610. /**
  80611. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80612. *
  80613. * Defaults to true for backwards compatibility.
  80614. */
  80615. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80616. /**
  80617. * Defines the name of the plugin.
  80618. */
  80619. name: string;
  80620. /**
  80621. * Defines the extension the plugin is able to load.
  80622. */
  80623. extensions: string;
  80624. /** @hidden */
  80625. obj: RegExp;
  80626. /** @hidden */
  80627. group: RegExp;
  80628. /** @hidden */
  80629. mtllib: RegExp;
  80630. /** @hidden */
  80631. usemtl: RegExp;
  80632. /** @hidden */
  80633. smooth: RegExp;
  80634. /** @hidden */
  80635. vertexPattern: RegExp;
  80636. /** @hidden */
  80637. normalPattern: RegExp;
  80638. /** @hidden */
  80639. uvPattern: RegExp;
  80640. /** @hidden */
  80641. facePattern1: RegExp;
  80642. /** @hidden */
  80643. facePattern2: RegExp;
  80644. /** @hidden */
  80645. facePattern3: RegExp;
  80646. /** @hidden */
  80647. facePattern4: RegExp;
  80648. /** @hidden */
  80649. facePattern5: RegExp;
  80650. private _forAssetContainer;
  80651. private _meshLoadOptions;
  80652. /**
  80653. * Creates loader for .OBJ files
  80654. *
  80655. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80656. */
  80657. constructor(meshLoadOptions?: MeshLoadOptions);
  80658. private static get currentMeshLoadOptions();
  80659. /**
  80660. * Calls synchronously the MTL file attached to this obj.
  80661. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80662. * Without this function materials are not displayed in the first frame (but displayed after).
  80663. * In consequence it is impossible to get material information in your HTML file
  80664. *
  80665. * @param url The URL of the MTL file
  80666. * @param rootUrl
  80667. * @param onSuccess Callback function to be called when the MTL file is loaded
  80668. * @private
  80669. */
  80670. private _loadMTL;
  80671. /**
  80672. * Instantiates a OBJ file loader plugin.
  80673. * @returns the created plugin
  80674. */
  80675. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80676. /**
  80677. * If the data string can be loaded directly.
  80678. *
  80679. * @param data string containing the file data
  80680. * @returns if the data can be loaded directly
  80681. */
  80682. canDirectLoad(data: string): boolean;
  80683. /**
  80684. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80685. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80686. * @param scene the scene the meshes should be added to
  80687. * @param data the OBJ data to load
  80688. * @param rootUrl root url to load from
  80689. * @param onProgress event that fires when loading progress has occured
  80690. * @param fileName Defines the name of the file to load
  80691. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80692. */
  80693. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80694. meshes: AbstractMesh[];
  80695. particleSystems: IParticleSystem[];
  80696. skeletons: Skeleton[];
  80697. animationGroups: AnimationGroup[];
  80698. }>;
  80699. /**
  80700. * Imports all objects from the loaded OBJ data and adds them to the scene
  80701. * @param scene the scene the objects should be added to
  80702. * @param data the OBJ data to load
  80703. * @param rootUrl root url to load from
  80704. * @param onProgress event that fires when loading progress has occured
  80705. * @param fileName Defines the name of the file to load
  80706. * @returns a promise which completes when objects have been loaded to the scene
  80707. */
  80708. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80709. /**
  80710. * Load into an asset container.
  80711. * @param scene The scene to load into
  80712. * @param data The data to import
  80713. * @param rootUrl The root url for scene and resources
  80714. * @param onProgress The callback when the load progresses
  80715. * @param fileName Defines the name of the file to load
  80716. * @returns The loaded asset container
  80717. */
  80718. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80719. /**
  80720. * Read the OBJ file and create an Array of meshes.
  80721. * Each mesh contains all information given by the OBJ and the MTL file.
  80722. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80723. *
  80724. * @param meshesNames
  80725. * @param scene Scene The scene where are displayed the data
  80726. * @param data String The content of the obj file
  80727. * @param rootUrl String The path to the folder
  80728. * @returns Array<AbstractMesh>
  80729. * @private
  80730. */
  80731. private _parseSolid;
  80732. }
  80733. }
  80734. declare module BABYLON {
  80735. /**
  80736. * STL file type loader.
  80737. * This is a babylon scene loader plugin.
  80738. */
  80739. export class STLFileLoader implements ISceneLoaderPlugin {
  80740. /** @hidden */
  80741. solidPattern: RegExp;
  80742. /** @hidden */
  80743. facetsPattern: RegExp;
  80744. /** @hidden */
  80745. normalPattern: RegExp;
  80746. /** @hidden */
  80747. vertexPattern: RegExp;
  80748. /**
  80749. * Defines the name of the plugin.
  80750. */
  80751. name: string;
  80752. /**
  80753. * Defines the extensions the stl loader is able to load.
  80754. * force data to come in as an ArrayBuffer
  80755. * we'll convert to string if it looks like it's an ASCII .stl
  80756. */
  80757. extensions: ISceneLoaderPluginExtensions;
  80758. /**
  80759. * Import meshes into a scene.
  80760. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80761. * @param scene The scene to import into
  80762. * @param data The data to import
  80763. * @param rootUrl The root url for scene and resources
  80764. * @param meshes The meshes array to import into
  80765. * @param particleSystems The particle systems array to import into
  80766. * @param skeletons The skeletons array to import into
  80767. * @param onError The callback when import fails
  80768. * @returns True if successful or false otherwise
  80769. */
  80770. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80771. /**
  80772. * Load into a scene.
  80773. * @param scene The scene to load into
  80774. * @param data The data to import
  80775. * @param rootUrl The root url for scene and resources
  80776. * @param onError The callback when import fails
  80777. * @returns true if successful or false otherwise
  80778. */
  80779. load(scene: Scene, data: any, rootUrl: string): boolean;
  80780. /**
  80781. * Load into an asset container.
  80782. * @param scene The scene to load into
  80783. * @param data The data to import
  80784. * @param rootUrl The root url for scene and resources
  80785. * @param onError The callback when import fails
  80786. * @returns The loaded asset container
  80787. */
  80788. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80789. private _isBinary;
  80790. private _parseBinary;
  80791. private _parseASCII;
  80792. }
  80793. }
  80794. declare module BABYLON {
  80795. /**
  80796. * Class for generating OBJ data from a Babylon scene.
  80797. */
  80798. export class OBJExport {
  80799. /**
  80800. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80801. * @param mesh defines the list of meshes to serialize
  80802. * @param materials defines if materials should be exported
  80803. * @param matlibname defines the name of the associated mtl file
  80804. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80805. * @returns the OBJ content
  80806. */
  80807. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80808. /**
  80809. * Exports the material(s) of a mesh in .MTL file format (text)
  80810. * @param mesh defines the mesh to extract the material from
  80811. * @returns the mtl content
  80812. */
  80813. static MTL(mesh: Mesh): string;
  80814. }
  80815. }
  80816. declare module BABYLON {
  80817. /** @hidden */
  80818. export var __IGLTFExporterExtension: number;
  80819. /**
  80820. * Interface for extending the exporter
  80821. * @hidden
  80822. */
  80823. export interface IGLTFExporterExtension {
  80824. /**
  80825. * The name of this extension
  80826. */
  80827. readonly name: string;
  80828. /**
  80829. * Defines whether this extension is enabled
  80830. */
  80831. enabled: boolean;
  80832. /**
  80833. * Defines whether this extension is required
  80834. */
  80835. required: boolean;
  80836. }
  80837. }
  80838. declare module BABYLON.GLTF2.Exporter {
  80839. /** @hidden */
  80840. export var __IGLTFExporterExtensionV2: number;
  80841. /**
  80842. * Interface for a glTF exporter extension
  80843. * @hidden
  80844. */
  80845. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80846. /**
  80847. * Define this method to modify the default behavior before exporting a texture
  80848. * @param context The context when loading the asset
  80849. * @param babylonTexture The Babylon.js texture
  80850. * @param mimeType The mime-type of the generated image
  80851. * @returns A promise that resolves with the exported texture
  80852. */
  80853. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80854. /**
  80855. * Define this method to get notified when a texture info is created
  80856. * @param context The context when loading the asset
  80857. * @param textureInfo The glTF texture info
  80858. * @param babylonTexture The Babylon.js texture
  80859. */
  80860. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80861. /**
  80862. * Define this method to modify the default behavior when exporting texture info
  80863. * @param context The context when loading the asset
  80864. * @param meshPrimitive glTF mesh primitive
  80865. * @param babylonSubMesh Babylon submesh
  80866. * @param binaryWriter glTF serializer binary writer instance
  80867. * @returns nullable IMeshPrimitive promise
  80868. */
  80869. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80870. /**
  80871. * Define this method to modify the default behavior when exporting a node
  80872. * @param context The context when exporting the node
  80873. * @param node glTF node
  80874. * @param babylonNode BabylonJS node
  80875. * @returns nullable INode promise
  80876. */
  80877. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80878. [key: number]: number;
  80879. }): Promise<Nullable<INode>>;
  80880. /**
  80881. * Define this method to modify the default behavior when exporting a material
  80882. * @param material glTF material
  80883. * @param babylonMaterial BabylonJS material
  80884. * @returns nullable IMaterial promise
  80885. */
  80886. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80887. /**
  80888. * Define this method to return additional textures to export from a material
  80889. * @param material glTF material
  80890. * @param babylonMaterial BabylonJS material
  80891. * @returns List of textures
  80892. */
  80893. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80894. /** Gets a boolean indicating that this extension was used */
  80895. wasUsed: boolean;
  80896. /** Gets a boolean indicating that this extension is required for the file to work */
  80897. required: boolean;
  80898. /**
  80899. * Called after the exporter state changes to EXPORTING
  80900. */
  80901. onExporting?(): void;
  80902. }
  80903. }
  80904. declare module BABYLON.GLTF2.Exporter {
  80905. /**
  80906. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80907. * @hidden
  80908. */
  80909. export class _GLTFMaterialExporter {
  80910. /**
  80911. * Represents the dielectric specular values for R, G and B
  80912. */
  80913. private static readonly _DielectricSpecular;
  80914. /**
  80915. * Allows the maximum specular power to be defined for material calculations
  80916. */
  80917. private static readonly _MaxSpecularPower;
  80918. /**
  80919. * Mapping to store textures
  80920. */
  80921. private _textureMap;
  80922. /**
  80923. * Numeric tolerance value
  80924. */
  80925. private static readonly _Epsilon;
  80926. /**
  80927. * Reference to the glTF Exporter
  80928. */
  80929. private _exporter;
  80930. constructor(exporter: _Exporter);
  80931. /**
  80932. * Specifies if two colors are approximately equal in value
  80933. * @param color1 first color to compare to
  80934. * @param color2 second color to compare to
  80935. * @param epsilon threshold value
  80936. */
  80937. private static FuzzyEquals;
  80938. /**
  80939. * Gets the materials from a Babylon scene and converts them to glTF materials
  80940. * @param scene babylonjs scene
  80941. * @param mimeType texture mime type
  80942. * @param images array of images
  80943. * @param textures array of textures
  80944. * @param materials array of materials
  80945. * @param imageData mapping of texture names to base64 textures
  80946. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80947. */
  80948. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80949. /**
  80950. * Makes a copy of the glTF material without the texture parameters
  80951. * @param originalMaterial original glTF material
  80952. * @returns glTF material without texture parameters
  80953. */
  80954. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80955. /**
  80956. * Specifies if the material has any texture parameters present
  80957. * @param material glTF Material
  80958. * @returns boolean specifying if texture parameters are present
  80959. */
  80960. _hasTexturesPresent(material: IMaterial): boolean;
  80961. /**
  80962. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80963. * @param babylonStandardMaterial
  80964. * @returns glTF Metallic Roughness Material representation
  80965. */
  80966. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80967. /**
  80968. * Computes the metallic factor
  80969. * @param diffuse diffused value
  80970. * @param specular specular value
  80971. * @param oneMinusSpecularStrength one minus the specular strength
  80972. * @returns metallic value
  80973. */
  80974. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80975. /**
  80976. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80977. * @param glTFMaterial glTF material
  80978. * @param babylonMaterial Babylon material
  80979. */
  80980. private static _SetAlphaMode;
  80981. /**
  80982. * Converts a Babylon Standard Material to a glTF Material
  80983. * @param babylonStandardMaterial BJS Standard Material
  80984. * @param mimeType mime type to use for the textures
  80985. * @param images array of glTF image interfaces
  80986. * @param textures array of glTF texture interfaces
  80987. * @param materials array of glTF material interfaces
  80988. * @param imageData map of image file name to data
  80989. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80990. */
  80991. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80992. private _finishMaterial;
  80993. /**
  80994. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80995. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80996. * @param mimeType mime type to use for the textures
  80997. * @param images array of glTF image interfaces
  80998. * @param textures array of glTF texture interfaces
  80999. * @param materials array of glTF material interfaces
  81000. * @param imageData map of image file name to data
  81001. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81002. */
  81003. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81004. /**
  81005. * Converts an image typed array buffer to a base64 image
  81006. * @param buffer typed array buffer
  81007. * @param width width of the image
  81008. * @param height height of the image
  81009. * @param mimeType mimetype of the image
  81010. * @returns base64 image string
  81011. */
  81012. private _createBase64FromCanvasAsync;
  81013. /**
  81014. * Generates a white texture based on the specified width and height
  81015. * @param width width of the texture in pixels
  81016. * @param height height of the texture in pixels
  81017. * @param scene babylonjs scene
  81018. * @returns white texture
  81019. */
  81020. private _createWhiteTexture;
  81021. /**
  81022. * 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
  81023. * @param texture1 first texture to resize
  81024. * @param texture2 second texture to resize
  81025. * @param scene babylonjs scene
  81026. * @returns resized textures or null
  81027. */
  81028. private _resizeTexturesToSameDimensions;
  81029. /**
  81030. * Converts an array of pixels to a Float32Array
  81031. * Throws an error if the pixel format is not supported
  81032. * @param pixels - array buffer containing pixel values
  81033. * @returns Float32 of pixels
  81034. */
  81035. private _convertPixelArrayToFloat32;
  81036. /**
  81037. * Convert Specular Glossiness Textures to Metallic Roughness
  81038. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81039. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81040. * @param diffuseTexture texture used to store diffuse information
  81041. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81042. * @param factors specular glossiness material factors
  81043. * @param mimeType the mime type to use for the texture
  81044. * @returns pbr metallic roughness interface or null
  81045. */
  81046. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81047. /**
  81048. * Converts specular glossiness material properties to metallic roughness
  81049. * @param specularGlossiness interface with specular glossiness material properties
  81050. * @returns interface with metallic roughness material properties
  81051. */
  81052. private _convertSpecularGlossinessToMetallicRoughness;
  81053. /**
  81054. * Calculates the surface reflectance, independent of lighting conditions
  81055. * @param color Color source to calculate brightness from
  81056. * @returns number representing the perceived brightness, or zero if color is undefined
  81057. */
  81058. private _getPerceivedBrightness;
  81059. /**
  81060. * Returns the maximum color component value
  81061. * @param color
  81062. * @returns maximum color component value, or zero if color is null or undefined
  81063. */
  81064. private _getMaxComponent;
  81065. /**
  81066. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81067. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81068. * @param mimeType mime type to use for the textures
  81069. * @param images array of glTF image interfaces
  81070. * @param textures array of glTF texture interfaces
  81071. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81072. * @param imageData map of image file name to data
  81073. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81074. * @returns glTF PBR Metallic Roughness factors
  81075. */
  81076. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81077. private _getGLTFTextureSampler;
  81078. private _getGLTFTextureWrapMode;
  81079. private _getGLTFTextureWrapModesSampler;
  81080. /**
  81081. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81082. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81083. * @param mimeType mime type to use for the textures
  81084. * @param images array of glTF image interfaces
  81085. * @param textures array of glTF texture interfaces
  81086. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81087. * @param imageData map of image file name to data
  81088. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81089. * @returns glTF PBR Metallic Roughness factors
  81090. */
  81091. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81092. /**
  81093. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81094. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81095. * @param mimeType mime type to use for the textures
  81096. * @param images array of glTF image interfaces
  81097. * @param textures array of glTF texture interfaces
  81098. * @param materials array of glTF material interfaces
  81099. * @param imageData map of image file name to data
  81100. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81101. */
  81102. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81103. private setMetallicRoughnessPbrMaterial;
  81104. private getPixelsFromTexture;
  81105. /**
  81106. * Extracts a texture from a Babylon texture into file data and glTF data
  81107. * @param babylonTexture Babylon texture to extract
  81108. * @param mimeType Mime Type of the babylonTexture
  81109. * @return glTF texture info, or null if the texture format is not supported
  81110. */
  81111. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81112. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81113. /**
  81114. * Builds a texture from base64 string
  81115. * @param base64Texture base64 texture string
  81116. * @param baseTextureName Name to use for the texture
  81117. * @param mimeType image mime type for the texture
  81118. * @param images array of images
  81119. * @param textures array of textures
  81120. * @param imageData map of image data
  81121. * @returns glTF texture info, or null if the texture format is not supported
  81122. */
  81123. private _getTextureInfoFromBase64;
  81124. }
  81125. }
  81126. declare module BABYLON {
  81127. /**
  81128. * Class for holding and downloading glTF file data
  81129. */
  81130. export class GLTFData {
  81131. /**
  81132. * Object which contains the file name as the key and its data as the value
  81133. */
  81134. glTFFiles: {
  81135. [fileName: string]: string | Blob;
  81136. };
  81137. /**
  81138. * Initializes the glTF file object
  81139. */
  81140. constructor();
  81141. /**
  81142. * Downloads the glTF data as files based on their names and data
  81143. */
  81144. downloadFiles(): void;
  81145. }
  81146. }
  81147. declare module BABYLON {
  81148. /**
  81149. * Holds a collection of exporter options and parameters
  81150. */
  81151. export interface IExportOptions {
  81152. /**
  81153. * Function which indicates whether a babylon node should be exported or not
  81154. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81155. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81156. */
  81157. shouldExportNode?(node: Node): boolean;
  81158. /**
  81159. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81160. * @param metadata source metadata to read from
  81161. * @returns the data to store to glTF node extras
  81162. */
  81163. metadataSelector?(metadata: any): any;
  81164. /**
  81165. * The sample rate to bake animation curves
  81166. */
  81167. animationSampleRate?: number;
  81168. /**
  81169. * Begin serialization without waiting for the scene to be ready
  81170. */
  81171. exportWithoutWaitingForScene?: boolean;
  81172. /**
  81173. * Indicates if coordinate system swapping root nodes should be included in export
  81174. */
  81175. includeCoordinateSystemConversionNodes?: boolean;
  81176. }
  81177. /**
  81178. * Class for generating glTF data from a Babylon scene.
  81179. */
  81180. export class GLTF2Export {
  81181. /**
  81182. * Exports the geometry of the scene to .gltf file format asynchronously
  81183. * @param scene Babylon scene with scene hierarchy information
  81184. * @param filePrefix File prefix to use when generating the glTF file
  81185. * @param options Exporter options
  81186. * @returns Returns an object with a .gltf file and associates texture names
  81187. * as keys and their data and paths as values
  81188. */
  81189. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81190. private static _PreExportAsync;
  81191. private static _PostExportAsync;
  81192. /**
  81193. * Exports the geometry of the scene to .glb file format asychronously
  81194. * @param scene Babylon scene with scene hierarchy information
  81195. * @param filePrefix File prefix to use when generating glb file
  81196. * @param options Exporter options
  81197. * @returns Returns an object with a .glb filename as key and data as value
  81198. */
  81199. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81200. }
  81201. }
  81202. declare module BABYLON.GLTF2.Exporter {
  81203. /**
  81204. * @hidden
  81205. */
  81206. export class _GLTFUtilities {
  81207. /**
  81208. * Creates a buffer view based on the supplied arguments
  81209. * @param bufferIndex index value of the specified buffer
  81210. * @param byteOffset byte offset value
  81211. * @param byteLength byte length of the bufferView
  81212. * @param byteStride byte distance between conequential elements
  81213. * @param name name of the buffer view
  81214. * @returns bufferView for glTF
  81215. */
  81216. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81217. /**
  81218. * Creates an accessor based on the supplied arguments
  81219. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81220. * @param name The name of the accessor
  81221. * @param type The type of the accessor
  81222. * @param componentType The datatype of components in the attribute
  81223. * @param count The number of attributes referenced by this accessor
  81224. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81225. * @param min Minimum value of each component in this attribute
  81226. * @param max Maximum value of each component in this attribute
  81227. * @returns accessor for glTF
  81228. */
  81229. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81230. /**
  81231. * Calculates the minimum and maximum values of an array of position floats
  81232. * @param positions Positions array of a mesh
  81233. * @param vertexStart Starting vertex offset to calculate min and max values
  81234. * @param vertexCount Number of vertices to check for min and max values
  81235. * @returns min number array and max number array
  81236. */
  81237. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81238. min: number[];
  81239. max: number[];
  81240. };
  81241. /**
  81242. * Converts a new right-handed Vector3
  81243. * @param vector vector3 array
  81244. * @returns right-handed Vector3
  81245. */
  81246. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81247. /**
  81248. * Converts a Vector3 to right-handed
  81249. * @param vector Vector3 to convert to right-handed
  81250. */
  81251. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81252. /**
  81253. * Converts a three element number array to right-handed
  81254. * @param vector number array to convert to right-handed
  81255. */
  81256. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81257. /**
  81258. * Converts a new right-handed Vector3
  81259. * @param vector vector3 array
  81260. * @returns right-handed Vector3
  81261. */
  81262. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81263. /**
  81264. * Converts a Vector3 to right-handed
  81265. * @param vector Vector3 to convert to right-handed
  81266. */
  81267. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81268. /**
  81269. * Converts a three element number array to right-handed
  81270. * @param vector number array to convert to right-handed
  81271. */
  81272. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81273. /**
  81274. * Converts a Vector4 to right-handed
  81275. * @param vector Vector4 to convert to right-handed
  81276. */
  81277. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81278. /**
  81279. * Converts a Vector4 to right-handed
  81280. * @param vector Vector4 to convert to right-handed
  81281. */
  81282. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81283. /**
  81284. * Converts a Quaternion to right-handed
  81285. * @param quaternion Source quaternion to convert to right-handed
  81286. */
  81287. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81288. /**
  81289. * Converts a Quaternion to right-handed
  81290. * @param quaternion Source quaternion to convert to right-handed
  81291. */
  81292. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81293. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81294. }
  81295. }
  81296. declare module BABYLON.GLTF2.Exporter {
  81297. /**
  81298. * Converts Babylon Scene into glTF 2.0.
  81299. * @hidden
  81300. */
  81301. export class _Exporter {
  81302. /**
  81303. * Stores the glTF to export
  81304. */
  81305. _glTF: IGLTF;
  81306. /**
  81307. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81308. */
  81309. _bufferViews: IBufferView[];
  81310. /**
  81311. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81312. */
  81313. _accessors: IAccessor[];
  81314. /**
  81315. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81316. */
  81317. _nodes: INode[];
  81318. /**
  81319. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81320. */
  81321. private _scenes;
  81322. /**
  81323. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81324. */
  81325. private _meshes;
  81326. /**
  81327. * Stores all the generated material information, which represents the appearance of each primitive
  81328. */
  81329. _materials: IMaterial[];
  81330. _materialMap: {
  81331. [materialID: number]: number;
  81332. };
  81333. /**
  81334. * Stores all the generated texture information, which is referenced by glTF materials
  81335. */
  81336. _textures: ITexture[];
  81337. /**
  81338. * Stores all the generated image information, which is referenced by glTF textures
  81339. */
  81340. _images: IImage[];
  81341. /**
  81342. * Stores all the texture samplers
  81343. */
  81344. _samplers: ISampler[];
  81345. /**
  81346. * Stores all the generated animation samplers, which is referenced by glTF animations
  81347. */
  81348. /**
  81349. * Stores the animations for glTF models
  81350. */
  81351. private _animations;
  81352. /**
  81353. * Stores the total amount of bytes stored in the glTF buffer
  81354. */
  81355. private _totalByteLength;
  81356. /**
  81357. * Stores a reference to the Babylon scene containing the source geometry and material information
  81358. */
  81359. _babylonScene: Scene;
  81360. /**
  81361. * Stores a map of the image data, where the key is the file name and the value
  81362. * is the image data
  81363. */
  81364. _imageData: {
  81365. [fileName: string]: {
  81366. data: Uint8Array;
  81367. mimeType: ImageMimeType;
  81368. };
  81369. };
  81370. /**
  81371. * Stores a map of the unique id of a node to its index in the node array
  81372. */
  81373. _nodeMap: {
  81374. [key: number]: number;
  81375. };
  81376. /**
  81377. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81378. */
  81379. _convertToRightHandedSystem: boolean;
  81380. /**
  81381. * Specifies if a Babylon node should be converted to right-handed on export
  81382. */
  81383. _convertToRightHandedSystemMap: {
  81384. [nodeId: number]: boolean;
  81385. };
  81386. _includeCoordinateSystemConversionNodes: boolean;
  81387. /**
  81388. * Baked animation sample rate
  81389. */
  81390. private _animationSampleRate;
  81391. private _options;
  81392. private _localEngine;
  81393. _glTFMaterialExporter: _GLTFMaterialExporter;
  81394. private _extensions;
  81395. private static _ExtensionNames;
  81396. private static _ExtensionFactories;
  81397. private _applyExtension;
  81398. private _applyExtensions;
  81399. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81400. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81401. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81402. [key: number]: number;
  81403. }): Promise<Nullable<INode>>;
  81404. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81405. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81406. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81407. private _forEachExtensions;
  81408. private _extensionsOnExporting;
  81409. /**
  81410. * Load glTF serializer extensions
  81411. */
  81412. private _loadExtensions;
  81413. /**
  81414. * Creates a glTF Exporter instance, which can accept optional exporter options
  81415. * @param babylonScene Babylon scene object
  81416. * @param options Options to modify the behavior of the exporter
  81417. */
  81418. constructor(babylonScene: Scene, options?: IExportOptions);
  81419. dispose(): void;
  81420. /**
  81421. * Registers a glTF exporter extension
  81422. * @param name Name of the extension to export
  81423. * @param factory The factory function that creates the exporter extension
  81424. */
  81425. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81426. /**
  81427. * Un-registers an exporter extension
  81428. * @param name The name fo the exporter extension
  81429. * @returns A boolean indicating whether the extension has been un-registered
  81430. */
  81431. static UnregisterExtension(name: string): boolean;
  81432. /**
  81433. * Lazy load a local engine
  81434. */
  81435. _getLocalEngine(): Engine;
  81436. private reorderIndicesBasedOnPrimitiveMode;
  81437. /**
  81438. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81439. * clock-wise during export to glTF
  81440. * @param submesh BabylonJS submesh
  81441. * @param primitiveMode Primitive mode of the mesh
  81442. * @param sideOrientation the winding order of the submesh
  81443. * @param vertexBufferKind The type of vertex attribute
  81444. * @param meshAttributeArray The vertex attribute data
  81445. * @param byteOffset The offset to the binary data
  81446. * @param binaryWriter The binary data for the glTF file
  81447. * @param convertToRightHandedSystem Converts the values to right-handed
  81448. */
  81449. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81450. /**
  81451. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81452. * clock-wise during export to glTF
  81453. * @param submesh BabylonJS submesh
  81454. * @param primitiveMode Primitive mode of the mesh
  81455. * @param sideOrientation the winding order of the submesh
  81456. * @param vertexBufferKind The type of vertex attribute
  81457. * @param meshAttributeArray The vertex attribute data
  81458. * @param byteOffset The offset to the binary data
  81459. * @param binaryWriter The binary data for the glTF file
  81460. * @param convertToRightHandedSystem Converts the values to right-handed
  81461. */
  81462. private reorderTriangleFillMode;
  81463. /**
  81464. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81465. * clock-wise during export to glTF
  81466. * @param submesh BabylonJS submesh
  81467. * @param primitiveMode Primitive mode of the mesh
  81468. * @param sideOrientation the winding order of the submesh
  81469. * @param vertexBufferKind The type of vertex attribute
  81470. * @param meshAttributeArray The vertex attribute data
  81471. * @param byteOffset The offset to the binary data
  81472. * @param binaryWriter The binary data for the glTF file
  81473. * @param convertToRightHandedSystem Converts the values to right-handed
  81474. */
  81475. private reorderTriangleStripDrawMode;
  81476. /**
  81477. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81478. * clock-wise during export to glTF
  81479. * @param submesh BabylonJS submesh
  81480. * @param primitiveMode Primitive mode of the mesh
  81481. * @param sideOrientation the winding order of the submesh
  81482. * @param vertexBufferKind The type of vertex attribute
  81483. * @param meshAttributeArray The vertex attribute data
  81484. * @param byteOffset The offset to the binary data
  81485. * @param binaryWriter The binary data for the glTF file
  81486. * @param convertToRightHandedSystem Converts the values to right-handed
  81487. */
  81488. private reorderTriangleFanMode;
  81489. /**
  81490. * Writes the vertex attribute data to binary
  81491. * @param vertices The vertices to write to the binary writer
  81492. * @param byteOffset The offset into the binary writer to overwrite binary data
  81493. * @param vertexAttributeKind The vertex attribute type
  81494. * @param meshAttributeArray The vertex attribute data
  81495. * @param binaryWriter The writer containing the binary data
  81496. * @param convertToRightHandedSystem Converts the values to right-handed
  81497. */
  81498. private writeVertexAttributeData;
  81499. /**
  81500. * Writes mesh attribute data to a data buffer
  81501. * Returns the bytelength of the data
  81502. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81503. * @param meshAttributeArray Array containing the attribute data
  81504. * @param binaryWriter The buffer to write the binary data to
  81505. * @param indices Used to specify the order of the vertex data
  81506. * @param convertToRightHandedSystem Converts the values to right-handed
  81507. */
  81508. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81509. /**
  81510. * Generates glTF json data
  81511. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81512. * @param glTFPrefix Text to use when prefixing a glTF file
  81513. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81514. * @returns json data as string
  81515. */
  81516. private generateJSON;
  81517. /**
  81518. * Generates data for .gltf and .bin files based on the glTF prefix string
  81519. * @param glTFPrefix Text to use when prefixing a glTF file
  81520. * @param dispose Dispose the exporter
  81521. * @returns GLTFData with glTF file data
  81522. */
  81523. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81524. /**
  81525. * Creates a binary buffer for glTF
  81526. * @returns array buffer for binary data
  81527. */
  81528. private _generateBinaryAsync;
  81529. /**
  81530. * Pads the number to a multiple of 4
  81531. * @param num number to pad
  81532. * @returns padded number
  81533. */
  81534. private _getPadding;
  81535. /**
  81536. * @hidden
  81537. */
  81538. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81539. /**
  81540. * Sets the TRS for each node
  81541. * @param node glTF Node for storing the transformation data
  81542. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  81543. * @param convertToRightHandedSystem Converts the values to right-handed
  81544. */
  81545. private setNodeTransformation;
  81546. private getVertexBufferFromMesh;
  81547. /**
  81548. * Creates a bufferview based on the vertices type for the Babylon mesh
  81549. * @param kind Indicates the type of vertices data
  81550. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  81551. * @param binaryWriter The buffer to write the bufferview data to
  81552. * @param convertToRightHandedSystem Converts the values to right-handed
  81553. */
  81554. private createBufferViewKind;
  81555. /**
  81556. * The primitive mode of the Babylon mesh
  81557. * @param babylonMesh The BabylonJS mesh
  81558. */
  81559. private getMeshPrimitiveMode;
  81560. /**
  81561. * Sets the primitive mode of the glTF mesh primitive
  81562. * @param meshPrimitive glTF mesh primitive
  81563. * @param primitiveMode The primitive mode
  81564. */
  81565. private setPrimitiveMode;
  81566. /**
  81567. * Sets the vertex attribute accessor based of the glTF mesh primitive
  81568. * @param meshPrimitive glTF mesh primitive
  81569. * @param attributeKind vertex attribute
  81570. * @returns boolean specifying if uv coordinates are present
  81571. */
  81572. private setAttributeKind;
  81573. /**
  81574. * Sets data for the primitive attributes of each submesh
  81575. * @param mesh glTF Mesh object to store the primitive attribute information
  81576. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  81577. * @param binaryWriter Buffer to write the attribute data to
  81578. * @param convertToRightHandedSystem Converts the values to right-handed
  81579. */
  81580. private setPrimitiveAttributesAsync;
  81581. /**
  81582. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  81583. * @param node The node to check
  81584. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81585. */
  81586. private isBabylonCoordinateSystemConvertingNode;
  81587. /**
  81588. * Creates a glTF scene based on the array of meshes
  81589. * Returns the the total byte offset
  81590. * @param babylonScene Babylon scene to get the mesh data from
  81591. * @param binaryWriter Buffer to write binary data to
  81592. */
  81593. private createSceneAsync;
  81594. /**
  81595. * Creates a mapping of Node unique id to node index and handles animations
  81596. * @param babylonScene Babylon Scene
  81597. * @param nodes Babylon transform nodes
  81598. * @param binaryWriter Buffer to write binary data to
  81599. * @returns Node mapping of unique id to index
  81600. */
  81601. private createNodeMapAndAnimationsAsync;
  81602. /**
  81603. * Creates a glTF node from a Babylon mesh
  81604. * @param babylonMesh Source Babylon mesh
  81605. * @param binaryWriter Buffer for storing geometry data
  81606. * @param convertToRightHandedSystem Converts the values to right-handed
  81607. * @param nodeMap Node mapping of unique id to glTF node index
  81608. * @returns glTF node
  81609. */
  81610. private createNodeAsync;
  81611. }
  81612. /**
  81613. * @hidden
  81614. *
  81615. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81616. */
  81617. export class _BinaryWriter {
  81618. /**
  81619. * Array buffer which stores all binary data
  81620. */
  81621. private _arrayBuffer;
  81622. /**
  81623. * View of the array buffer
  81624. */
  81625. private _dataView;
  81626. /**
  81627. * byte offset of data in array buffer
  81628. */
  81629. private _byteOffset;
  81630. /**
  81631. * Initialize binary writer with an initial byte length
  81632. * @param byteLength Initial byte length of the array buffer
  81633. */
  81634. constructor(byteLength: number);
  81635. /**
  81636. * Resize the array buffer to the specified byte length
  81637. * @param byteLength
  81638. */
  81639. private resizeBuffer;
  81640. /**
  81641. * Get an array buffer with the length of the byte offset
  81642. * @returns ArrayBuffer resized to the byte offset
  81643. */
  81644. getArrayBuffer(): ArrayBuffer;
  81645. /**
  81646. * Get the byte offset of the array buffer
  81647. * @returns byte offset
  81648. */
  81649. getByteOffset(): number;
  81650. /**
  81651. * Stores an UInt8 in the array buffer
  81652. * @param entry
  81653. * @param byteOffset If defined, specifies where to set the value as an offset.
  81654. */
  81655. setUInt8(entry: number, byteOffset?: number): void;
  81656. /**
  81657. * Gets an UInt32 in the array buffer
  81658. * @param entry
  81659. * @param byteOffset If defined, specifies where to set the value as an offset.
  81660. */
  81661. getUInt32(byteOffset: number): number;
  81662. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81663. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81664. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81665. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81666. /**
  81667. * Stores a Float32 in the array buffer
  81668. * @param entry
  81669. */
  81670. setFloat32(entry: number, byteOffset?: number): void;
  81671. /**
  81672. * Stores an UInt32 in the array buffer
  81673. * @param entry
  81674. * @param byteOffset If defined, specifies where to set the value as an offset.
  81675. */
  81676. setUInt32(entry: number, byteOffset?: number): void;
  81677. }
  81678. }
  81679. declare module BABYLON.GLTF2.Exporter {
  81680. /**
  81681. * @hidden
  81682. * Interface to store animation data.
  81683. */
  81684. export interface _IAnimationData {
  81685. /**
  81686. * Keyframe data.
  81687. */
  81688. inputs: number[];
  81689. /**
  81690. * Value data.
  81691. */
  81692. outputs: number[][];
  81693. /**
  81694. * Animation interpolation data.
  81695. */
  81696. samplerInterpolation: AnimationSamplerInterpolation;
  81697. /**
  81698. * Minimum keyframe value.
  81699. */
  81700. inputsMin: number;
  81701. /**
  81702. * Maximum keyframe value.
  81703. */
  81704. inputsMax: number;
  81705. }
  81706. /**
  81707. * @hidden
  81708. */
  81709. export interface _IAnimationInfo {
  81710. /**
  81711. * The target channel for the animation
  81712. */
  81713. animationChannelTargetPath: AnimationChannelTargetPath;
  81714. /**
  81715. * The glTF accessor type for the data.
  81716. */
  81717. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81718. /**
  81719. * Specifies if quaternions should be used.
  81720. */
  81721. useQuaternion: boolean;
  81722. }
  81723. /**
  81724. * @hidden
  81725. * Utility class for generating glTF animation data from BabylonJS.
  81726. */
  81727. export class _GLTFAnimation {
  81728. /**
  81729. * @ignore
  81730. *
  81731. * Creates glTF channel animation from BabylonJS animation.
  81732. * @param babylonTransformNode - BabylonJS mesh.
  81733. * @param animation - animation.
  81734. * @param animationChannelTargetPath - The target animation channel.
  81735. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81736. * @param useQuaternion - Specifies if quaternions are used.
  81737. * @returns nullable IAnimationData
  81738. */
  81739. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81740. private static _DeduceAnimationInfo;
  81741. /**
  81742. * @ignore
  81743. * Create node animations from the transform node animations
  81744. * @param babylonNode
  81745. * @param runtimeGLTFAnimation
  81746. * @param idleGLTFAnimations
  81747. * @param nodeMap
  81748. * @param nodes
  81749. * @param binaryWriter
  81750. * @param bufferViews
  81751. * @param accessors
  81752. * @param convertToRightHandedSystem
  81753. * @param animationSampleRate
  81754. */
  81755. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81756. [key: number]: number;
  81757. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81758. /**
  81759. * @ignore
  81760. * Create node animations from the animation groups
  81761. * @param babylonScene
  81762. * @param glTFAnimations
  81763. * @param nodeMap
  81764. * @param nodes
  81765. * @param binaryWriter
  81766. * @param bufferViews
  81767. * @param accessors
  81768. * @param convertToRightHandedSystemMap
  81769. * @param animationSampleRate
  81770. */
  81771. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81772. [key: number]: number;
  81773. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81774. [nodeId: number]: boolean;
  81775. }, animationSampleRate: number): void;
  81776. private static AddAnimation;
  81777. /**
  81778. * Create a baked animation
  81779. * @param babylonTransformNode BabylonJS mesh
  81780. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81781. * @param animationChannelTargetPath animation target channel
  81782. * @param minFrame minimum animation frame
  81783. * @param maxFrame maximum animation frame
  81784. * @param fps frames per second of the animation
  81785. * @param inputs input key frames of the animation
  81786. * @param outputs output key frame data of the animation
  81787. * @param convertToRightHandedSystem converts the values to right-handed
  81788. * @param useQuaternion specifies if quaternions should be used
  81789. */
  81790. private static _CreateBakedAnimation;
  81791. private static _ConvertFactorToVector3OrQuaternion;
  81792. private static _SetInterpolatedValue;
  81793. /**
  81794. * Creates linear animation from the animation key frames
  81795. * @param babylonTransformNode BabylonJS mesh
  81796. * @param animation BabylonJS animation
  81797. * @param animationChannelTargetPath The target animation channel
  81798. * @param frameDelta The difference between the last and first frame of the animation
  81799. * @param inputs Array to store the key frame times
  81800. * @param outputs Array to store the key frame data
  81801. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81802. * @param useQuaternion Specifies if quaternions are used in the animation
  81803. */
  81804. private static _CreateLinearOrStepAnimation;
  81805. /**
  81806. * Creates cubic spline animation from the animation key frames
  81807. * @param babylonTransformNode BabylonJS mesh
  81808. * @param animation BabylonJS animation
  81809. * @param animationChannelTargetPath The target animation channel
  81810. * @param frameDelta The difference between the last and first frame of the animation
  81811. * @param inputs Array to store the key frame times
  81812. * @param outputs Array to store the key frame data
  81813. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81814. * @param useQuaternion Specifies if quaternions are used in the animation
  81815. */
  81816. private static _CreateCubicSplineAnimation;
  81817. private static _GetBasePositionRotationOrScale;
  81818. /**
  81819. * Adds a key frame value
  81820. * @param keyFrame
  81821. * @param animation
  81822. * @param outputs
  81823. * @param animationChannelTargetPath
  81824. * @param basePositionRotationOrScale
  81825. * @param convertToRightHandedSystem
  81826. * @param useQuaternion
  81827. */
  81828. private static _AddKeyframeValue;
  81829. /**
  81830. * Determine the interpolation based on the key frames
  81831. * @param keyFrames
  81832. * @param animationChannelTargetPath
  81833. * @param useQuaternion
  81834. */
  81835. private static _DeduceInterpolation;
  81836. /**
  81837. * Adds an input tangent or output tangent to the output data
  81838. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81839. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81840. * @param outputs The animation data by keyframe
  81841. * @param animationChannelTargetPath The target animation channel
  81842. * @param interpolation The interpolation type
  81843. * @param keyFrame The key frame with the animation data
  81844. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81845. * @param useQuaternion Specifies if quaternions are used
  81846. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81847. */
  81848. private static AddSplineTangent;
  81849. /**
  81850. * Get the minimum and maximum key frames' frame values
  81851. * @param keyFrames animation key frames
  81852. * @returns the minimum and maximum key frame value
  81853. */
  81854. private static calculateMinMaxKeyFrames;
  81855. }
  81856. }
  81857. declare module BABYLON.GLTF2.Exporter {
  81858. /** @hidden */
  81859. export var textureTransformPixelShader: {
  81860. name: string;
  81861. shader: string;
  81862. };
  81863. }
  81864. declare module BABYLON.GLTF2.Exporter.Extensions {
  81865. /**
  81866. * @hidden
  81867. */
  81868. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81869. private _recordedTextures;
  81870. /** Name of this extension */
  81871. readonly name: string;
  81872. /** Defines whether this extension is enabled */
  81873. enabled: boolean;
  81874. /** Defines whether this extension is required */
  81875. required: boolean;
  81876. /** Reference to the glTF exporter */
  81877. private _wasUsed;
  81878. constructor(exporter: _Exporter);
  81879. dispose(): void;
  81880. /** @hidden */
  81881. get wasUsed(): boolean;
  81882. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81883. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81884. /**
  81885. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81886. * @param babylonTexture
  81887. * @param offset
  81888. * @param rotation
  81889. * @param scale
  81890. * @param scene
  81891. */
  81892. private _textureTransformTextureAsync;
  81893. }
  81894. }
  81895. declare module BABYLON.GLTF2.Exporter.Extensions {
  81896. /**
  81897. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81898. */
  81899. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81900. /** The name of this extension. */
  81901. readonly name: string;
  81902. /** Defines whether this extension is enabled. */
  81903. enabled: boolean;
  81904. /** Defines whether this extension is required */
  81905. required: boolean;
  81906. /** Reference to the glTF exporter */
  81907. private _exporter;
  81908. private _lights;
  81909. /** @hidden */
  81910. constructor(exporter: _Exporter);
  81911. /** @hidden */
  81912. dispose(): void;
  81913. /** @hidden */
  81914. get wasUsed(): boolean;
  81915. /** @hidden */
  81916. onExporting(): void;
  81917. /**
  81918. * Define this method to modify the default behavior when exporting a node
  81919. * @param context The context when exporting the node
  81920. * @param node glTF node
  81921. * @param babylonNode BabylonJS node
  81922. * @param nodeMap Node mapping of unique id to glTF node index
  81923. * @returns nullable INode promise
  81924. */
  81925. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81926. [key: number]: number;
  81927. }): Promise<Nullable<INode>>;
  81928. }
  81929. }
  81930. declare module BABYLON.GLTF2.Exporter.Extensions {
  81931. /**
  81932. * @hidden
  81933. */
  81934. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81935. /** Name of this extension */
  81936. readonly name: string;
  81937. /** Defines whether this extension is enabled */
  81938. enabled: boolean;
  81939. /** Defines whether this extension is required */
  81940. required: boolean;
  81941. /** Reference to the glTF exporter */
  81942. private _textureInfos;
  81943. private _exportedTextures;
  81944. private _wasUsed;
  81945. constructor(exporter: _Exporter);
  81946. dispose(): void;
  81947. /** @hidden */
  81948. get wasUsed(): boolean;
  81949. private _getTextureIndex;
  81950. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81951. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81952. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81953. }
  81954. }
  81955. declare module BABYLON {
  81956. /**
  81957. * Class for generating STL data from a Babylon scene.
  81958. */
  81959. export class STLExport {
  81960. /**
  81961. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81962. * @param meshes list defines the mesh to serialize
  81963. * @param download triggers the automatic download of the file.
  81964. * @param fileName changes the downloads fileName.
  81965. * @param binary changes the STL to a binary type.
  81966. * @param isLittleEndian toggle for binary type exporter.
  81967. * @returns the STL as UTF8 string
  81968. */
  81969. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81970. }
  81971. }
  81972. declare module "babylonjs-gltf2interface" {
  81973. export = BABYLON.GLTF2;
  81974. }
  81975. /**
  81976. * Module for glTF 2.0 Interface
  81977. */
  81978. declare module BABYLON.GLTF2 {
  81979. /**
  81980. * The datatype of the components in the attribute
  81981. */
  81982. const enum AccessorComponentType {
  81983. /**
  81984. * Byte
  81985. */
  81986. BYTE = 5120,
  81987. /**
  81988. * Unsigned Byte
  81989. */
  81990. UNSIGNED_BYTE = 5121,
  81991. /**
  81992. * Short
  81993. */
  81994. SHORT = 5122,
  81995. /**
  81996. * Unsigned Short
  81997. */
  81998. UNSIGNED_SHORT = 5123,
  81999. /**
  82000. * Unsigned Int
  82001. */
  82002. UNSIGNED_INT = 5125,
  82003. /**
  82004. * Float
  82005. */
  82006. FLOAT = 5126,
  82007. }
  82008. /**
  82009. * Specifies if the attirbute is a scalar, vector, or matrix
  82010. */
  82011. const enum AccessorType {
  82012. /**
  82013. * Scalar
  82014. */
  82015. SCALAR = "SCALAR",
  82016. /**
  82017. * Vector2
  82018. */
  82019. VEC2 = "VEC2",
  82020. /**
  82021. * Vector3
  82022. */
  82023. VEC3 = "VEC3",
  82024. /**
  82025. * Vector4
  82026. */
  82027. VEC4 = "VEC4",
  82028. /**
  82029. * Matrix2x2
  82030. */
  82031. MAT2 = "MAT2",
  82032. /**
  82033. * Matrix3x3
  82034. */
  82035. MAT3 = "MAT3",
  82036. /**
  82037. * Matrix4x4
  82038. */
  82039. MAT4 = "MAT4",
  82040. }
  82041. /**
  82042. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82043. */
  82044. const enum AnimationChannelTargetPath {
  82045. /**
  82046. * Translation
  82047. */
  82048. TRANSLATION = "translation",
  82049. /**
  82050. * Rotation
  82051. */
  82052. ROTATION = "rotation",
  82053. /**
  82054. * Scale
  82055. */
  82056. SCALE = "scale",
  82057. /**
  82058. * Weights
  82059. */
  82060. WEIGHTS = "weights",
  82061. }
  82062. /**
  82063. * Interpolation algorithm
  82064. */
  82065. const enum AnimationSamplerInterpolation {
  82066. /**
  82067. * The animated values are linearly interpolated between keyframes
  82068. */
  82069. LINEAR = "LINEAR",
  82070. /**
  82071. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82072. */
  82073. STEP = "STEP",
  82074. /**
  82075. * The animation's interpolation is computed using a cubic spline with specified tangents
  82076. */
  82077. CUBICSPLINE = "CUBICSPLINE",
  82078. }
  82079. /**
  82080. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82081. */
  82082. const enum CameraType {
  82083. /**
  82084. * A perspective camera containing properties to create a perspective projection matrix
  82085. */
  82086. PERSPECTIVE = "perspective",
  82087. /**
  82088. * An orthographic camera containing properties to create an orthographic projection matrix
  82089. */
  82090. ORTHOGRAPHIC = "orthographic",
  82091. }
  82092. /**
  82093. * The mime-type of the image
  82094. */
  82095. const enum ImageMimeType {
  82096. /**
  82097. * JPEG Mime-type
  82098. */
  82099. JPEG = "image/jpeg",
  82100. /**
  82101. * PNG Mime-type
  82102. */
  82103. PNG = "image/png",
  82104. }
  82105. /**
  82106. * The alpha rendering mode of the material
  82107. */
  82108. const enum MaterialAlphaMode {
  82109. /**
  82110. * The alpha value is ignored and the rendered output is fully opaque
  82111. */
  82112. OPAQUE = "OPAQUE",
  82113. /**
  82114. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82115. */
  82116. MASK = "MASK",
  82117. /**
  82118. * 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)
  82119. */
  82120. BLEND = "BLEND",
  82121. }
  82122. /**
  82123. * The type of the primitives to render
  82124. */
  82125. const enum MeshPrimitiveMode {
  82126. /**
  82127. * Points
  82128. */
  82129. POINTS = 0,
  82130. /**
  82131. * Lines
  82132. */
  82133. LINES = 1,
  82134. /**
  82135. * Line Loop
  82136. */
  82137. LINE_LOOP = 2,
  82138. /**
  82139. * Line Strip
  82140. */
  82141. LINE_STRIP = 3,
  82142. /**
  82143. * Triangles
  82144. */
  82145. TRIANGLES = 4,
  82146. /**
  82147. * Triangle Strip
  82148. */
  82149. TRIANGLE_STRIP = 5,
  82150. /**
  82151. * Triangle Fan
  82152. */
  82153. TRIANGLE_FAN = 6,
  82154. }
  82155. /**
  82156. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82157. */
  82158. const enum TextureMagFilter {
  82159. /**
  82160. * Nearest
  82161. */
  82162. NEAREST = 9728,
  82163. /**
  82164. * Linear
  82165. */
  82166. LINEAR = 9729,
  82167. }
  82168. /**
  82169. * Minification filter. All valid values correspond to WebGL enums
  82170. */
  82171. const enum TextureMinFilter {
  82172. /**
  82173. * Nearest
  82174. */
  82175. NEAREST = 9728,
  82176. /**
  82177. * Linear
  82178. */
  82179. LINEAR = 9729,
  82180. /**
  82181. * Nearest Mip-Map Nearest
  82182. */
  82183. NEAREST_MIPMAP_NEAREST = 9984,
  82184. /**
  82185. * Linear Mipmap Nearest
  82186. */
  82187. LINEAR_MIPMAP_NEAREST = 9985,
  82188. /**
  82189. * Nearest Mipmap Linear
  82190. */
  82191. NEAREST_MIPMAP_LINEAR = 9986,
  82192. /**
  82193. * Linear Mipmap Linear
  82194. */
  82195. LINEAR_MIPMAP_LINEAR = 9987,
  82196. }
  82197. /**
  82198. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82199. */
  82200. const enum TextureWrapMode {
  82201. /**
  82202. * Clamp to Edge
  82203. */
  82204. CLAMP_TO_EDGE = 33071,
  82205. /**
  82206. * Mirrored Repeat
  82207. */
  82208. MIRRORED_REPEAT = 33648,
  82209. /**
  82210. * Repeat
  82211. */
  82212. REPEAT = 10497,
  82213. }
  82214. /**
  82215. * glTF Property
  82216. */
  82217. interface IProperty {
  82218. /**
  82219. * Dictionary object with extension-specific objects
  82220. */
  82221. extensions?: {
  82222. [key: string]: any;
  82223. };
  82224. /**
  82225. * Application-Specific data
  82226. */
  82227. extras?: any;
  82228. }
  82229. /**
  82230. * glTF Child of Root Property
  82231. */
  82232. interface IChildRootProperty extends IProperty {
  82233. /**
  82234. * The user-defined name of this object
  82235. */
  82236. name?: string;
  82237. }
  82238. /**
  82239. * Indices of those attributes that deviate from their initialization value
  82240. */
  82241. interface IAccessorSparseIndices extends IProperty {
  82242. /**
  82243. * The index of the bufferView with sparse indices. 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. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82252. */
  82253. componentType: AccessorComponentType;
  82254. }
  82255. /**
  82256. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82257. */
  82258. interface IAccessorSparseValues extends IProperty {
  82259. /**
  82260. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82261. */
  82262. bufferView: number;
  82263. /**
  82264. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82265. */
  82266. byteOffset?: number;
  82267. }
  82268. /**
  82269. * Sparse storage of attributes that deviate from their initialization value
  82270. */
  82271. interface IAccessorSparse extends IProperty {
  82272. /**
  82273. * The number of attributes encoded in this sparse accessor
  82274. */
  82275. count: number;
  82276. /**
  82277. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82278. */
  82279. indices: IAccessorSparseIndices;
  82280. /**
  82281. * 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
  82282. */
  82283. values: IAccessorSparseValues;
  82284. }
  82285. /**
  82286. * 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
  82287. */
  82288. interface IAccessor extends IChildRootProperty {
  82289. /**
  82290. * The index of the bufferview
  82291. */
  82292. bufferView?: number;
  82293. /**
  82294. * The offset relative to the start of the bufferView in bytes
  82295. */
  82296. byteOffset?: number;
  82297. /**
  82298. * The datatype of components in the attribute
  82299. */
  82300. componentType: AccessorComponentType;
  82301. /**
  82302. * Specifies whether integer data values should be normalized
  82303. */
  82304. normalized?: boolean;
  82305. /**
  82306. * The number of attributes referenced by this accessor
  82307. */
  82308. count: number;
  82309. /**
  82310. * Specifies if the attribute is a scalar, vector, or matrix
  82311. */
  82312. type: AccessorType;
  82313. /**
  82314. * Maximum value of each component in this attribute
  82315. */
  82316. max?: number[];
  82317. /**
  82318. * Minimum value of each component in this attribute
  82319. */
  82320. min?: number[];
  82321. /**
  82322. * Sparse storage of attributes that deviate from their initialization value
  82323. */
  82324. sparse?: IAccessorSparse;
  82325. }
  82326. /**
  82327. * Targets an animation's sampler at a node's property
  82328. */
  82329. interface IAnimationChannel extends IProperty {
  82330. /**
  82331. * The index of a sampler in this animation used to compute the value for the target
  82332. */
  82333. sampler: number;
  82334. /**
  82335. * The index of the node and TRS property to target
  82336. */
  82337. target: IAnimationChannelTarget;
  82338. }
  82339. /**
  82340. * The index of the node and TRS property that an animation channel targets
  82341. */
  82342. interface IAnimationChannelTarget extends IProperty {
  82343. /**
  82344. * The index of the node to target
  82345. */
  82346. node: number;
  82347. /**
  82348. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82349. */
  82350. path: AnimationChannelTargetPath;
  82351. }
  82352. /**
  82353. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82354. */
  82355. interface IAnimationSampler extends IProperty {
  82356. /**
  82357. * The index of an accessor containing keyframe input values, e.g., time
  82358. */
  82359. input: number;
  82360. /**
  82361. * Interpolation algorithm
  82362. */
  82363. interpolation?: AnimationSamplerInterpolation;
  82364. /**
  82365. * The index of an accessor, containing keyframe output values
  82366. */
  82367. output: number;
  82368. }
  82369. /**
  82370. * A keyframe animation
  82371. */
  82372. interface IAnimation extends IChildRootProperty {
  82373. /**
  82374. * An array of channels, each of which targets an animation's sampler at a node's property
  82375. */
  82376. channels: IAnimationChannel[];
  82377. /**
  82378. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82379. */
  82380. samplers: IAnimationSampler[];
  82381. }
  82382. /**
  82383. * Metadata about the glTF asset
  82384. */
  82385. interface IAsset extends IChildRootProperty {
  82386. /**
  82387. * A copyright message suitable for display to credit the content creator
  82388. */
  82389. copyright?: string;
  82390. /**
  82391. * Tool that generated this glTF model. Useful for debugging
  82392. */
  82393. generator?: string;
  82394. /**
  82395. * The glTF version that this asset targets
  82396. */
  82397. version: string;
  82398. /**
  82399. * The minimum glTF version that this asset targets
  82400. */
  82401. minVersion?: string;
  82402. }
  82403. /**
  82404. * A buffer points to binary geometry, animation, or skins
  82405. */
  82406. interface IBuffer extends IChildRootProperty {
  82407. /**
  82408. * 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
  82409. */
  82410. uri?: string;
  82411. /**
  82412. * The length of the buffer in bytes
  82413. */
  82414. byteLength: number;
  82415. }
  82416. /**
  82417. * A view into a buffer generally representing a subset of the buffer
  82418. */
  82419. interface IBufferView extends IChildRootProperty {
  82420. /**
  82421. * The index of the buffer
  82422. */
  82423. buffer: number;
  82424. /**
  82425. * The offset into the buffer in bytes
  82426. */
  82427. byteOffset?: number;
  82428. /**
  82429. * The lenth of the bufferView in bytes
  82430. */
  82431. byteLength: number;
  82432. /**
  82433. * The stride, in bytes
  82434. */
  82435. byteStride?: number;
  82436. }
  82437. /**
  82438. * An orthographic camera containing properties to create an orthographic projection matrix
  82439. */
  82440. interface ICameraOrthographic extends IProperty {
  82441. /**
  82442. * The floating-point horizontal magnification of the view. Must not be zero
  82443. */
  82444. xmag: number;
  82445. /**
  82446. * The floating-point vertical magnification of the view. Must not be zero
  82447. */
  82448. ymag: number;
  82449. /**
  82450. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82451. */
  82452. zfar: number;
  82453. /**
  82454. * The floating-point distance to the near clipping plane
  82455. */
  82456. znear: number;
  82457. }
  82458. /**
  82459. * A perspective camera containing properties to create a perspective projection matrix
  82460. */
  82461. interface ICameraPerspective extends IProperty {
  82462. /**
  82463. * The floating-point aspect ratio of the field of view
  82464. */
  82465. aspectRatio?: number;
  82466. /**
  82467. * The floating-point vertical field of view in radians
  82468. */
  82469. yfov: number;
  82470. /**
  82471. * The floating-point distance to the far clipping plane
  82472. */
  82473. zfar?: number;
  82474. /**
  82475. * The floating-point distance to the near clipping plane
  82476. */
  82477. znear: number;
  82478. }
  82479. /**
  82480. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82481. */
  82482. interface ICamera extends IChildRootProperty {
  82483. /**
  82484. * An orthographic camera containing properties to create an orthographic projection matrix
  82485. */
  82486. orthographic?: ICameraOrthographic;
  82487. /**
  82488. * A perspective camera containing properties to create a perspective projection matrix
  82489. */
  82490. perspective?: ICameraPerspective;
  82491. /**
  82492. * Specifies if the camera uses a perspective or orthographic projection
  82493. */
  82494. type: CameraType;
  82495. }
  82496. /**
  82497. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82498. */
  82499. interface IImage extends IChildRootProperty {
  82500. /**
  82501. * 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
  82502. */
  82503. uri?: string;
  82504. /**
  82505. * The image's MIME type
  82506. */
  82507. mimeType?: ImageMimeType;
  82508. /**
  82509. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82510. */
  82511. bufferView?: number;
  82512. }
  82513. /**
  82514. * Material Normal Texture Info
  82515. */
  82516. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82517. /**
  82518. * The scalar multiplier applied to each normal vector of the normal texture
  82519. */
  82520. scale?: number;
  82521. }
  82522. /**
  82523. * Material Occlusion Texture Info
  82524. */
  82525. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82526. /**
  82527. * A scalar multiplier controlling the amount of occlusion applied
  82528. */
  82529. strength?: number;
  82530. }
  82531. /**
  82532. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  82533. */
  82534. interface IMaterialPbrMetallicRoughness {
  82535. /**
  82536. * The material's base color factor
  82537. */
  82538. baseColorFactor?: number[];
  82539. /**
  82540. * The base color texture
  82541. */
  82542. baseColorTexture?: ITextureInfo;
  82543. /**
  82544. * The metalness of the material
  82545. */
  82546. metallicFactor?: number;
  82547. /**
  82548. * The roughness of the material
  82549. */
  82550. roughnessFactor?: number;
  82551. /**
  82552. * The metallic-roughness texture
  82553. */
  82554. metallicRoughnessTexture?: ITextureInfo;
  82555. }
  82556. /**
  82557. * The material appearance of a primitive
  82558. */
  82559. interface IMaterial extends IChildRootProperty {
  82560. /**
  82561. * 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
  82562. */
  82563. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82564. /**
  82565. * The normal map texture
  82566. */
  82567. normalTexture?: IMaterialNormalTextureInfo;
  82568. /**
  82569. * The occlusion map texture
  82570. */
  82571. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82572. /**
  82573. * The emissive map texture
  82574. */
  82575. emissiveTexture?: ITextureInfo;
  82576. /**
  82577. * 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
  82578. */
  82579. emissiveFactor?: number[];
  82580. /**
  82581. * The alpha rendering mode of the material
  82582. */
  82583. alphaMode?: MaterialAlphaMode;
  82584. /**
  82585. * The alpha cutoff value of the material
  82586. */
  82587. alphaCutoff?: number;
  82588. /**
  82589. * Specifies whether the material is double sided
  82590. */
  82591. doubleSided?: boolean;
  82592. }
  82593. /**
  82594. * Geometry to be rendered with the given material
  82595. */
  82596. interface IMeshPrimitive extends IProperty {
  82597. /**
  82598. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82599. */
  82600. attributes: {
  82601. [name: string]: number;
  82602. };
  82603. /**
  82604. * The index of the accessor that contains the indices
  82605. */
  82606. indices?: number;
  82607. /**
  82608. * The index of the material to apply to this primitive when rendering
  82609. */
  82610. material?: number;
  82611. /**
  82612. * The type of primitives to render. All valid values correspond to WebGL enums
  82613. */
  82614. mode?: MeshPrimitiveMode;
  82615. /**
  82616. * 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
  82617. */
  82618. targets?: {
  82619. [name: string]: number;
  82620. }[];
  82621. }
  82622. /**
  82623. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82624. */
  82625. interface IMesh extends IChildRootProperty {
  82626. /**
  82627. * An array of primitives, each defining geometry to be rendered with a material
  82628. */
  82629. primitives: IMeshPrimitive[];
  82630. /**
  82631. * Array of weights to be applied to the Morph Targets
  82632. */
  82633. weights?: number[];
  82634. }
  82635. /**
  82636. * A node in the node hierarchy
  82637. */
  82638. interface INode extends IChildRootProperty {
  82639. /**
  82640. * The index of the camera referenced by this node
  82641. */
  82642. camera?: number;
  82643. /**
  82644. * The indices of this node's children
  82645. */
  82646. children?: number[];
  82647. /**
  82648. * The index of the skin referenced by this node
  82649. */
  82650. skin?: number;
  82651. /**
  82652. * A floating-point 4x4 transformation matrix stored in column-major order
  82653. */
  82654. matrix?: number[];
  82655. /**
  82656. * The index of the mesh in this node
  82657. */
  82658. mesh?: number;
  82659. /**
  82660. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82661. */
  82662. rotation?: number[];
  82663. /**
  82664. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82665. */
  82666. scale?: number[];
  82667. /**
  82668. * The node's translation along the x, y, and z axes
  82669. */
  82670. translation?: number[];
  82671. /**
  82672. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82673. */
  82674. weights?: number[];
  82675. }
  82676. /**
  82677. * Texture sampler properties for filtering and wrapping modes
  82678. */
  82679. interface ISampler extends IChildRootProperty {
  82680. /**
  82681. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82682. */
  82683. magFilter?: TextureMagFilter;
  82684. /**
  82685. * Minification filter. All valid values correspond to WebGL enums
  82686. */
  82687. minFilter?: TextureMinFilter;
  82688. /**
  82689. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82690. */
  82691. wrapS?: TextureWrapMode;
  82692. /**
  82693. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82694. */
  82695. wrapT?: TextureWrapMode;
  82696. }
  82697. /**
  82698. * The root nodes of a scene
  82699. */
  82700. interface IScene extends IChildRootProperty {
  82701. /**
  82702. * The indices of each root node
  82703. */
  82704. nodes: number[];
  82705. }
  82706. /**
  82707. * Joints and matrices defining a skin
  82708. */
  82709. interface ISkin extends IChildRootProperty {
  82710. /**
  82711. * 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
  82712. */
  82713. inverseBindMatrices?: number;
  82714. /**
  82715. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82716. */
  82717. skeleton?: number;
  82718. /**
  82719. * 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)
  82720. */
  82721. joints: number[];
  82722. }
  82723. /**
  82724. * A texture and its sampler
  82725. */
  82726. interface ITexture extends IChildRootProperty {
  82727. /**
  82728. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82729. */
  82730. sampler?: number;
  82731. /**
  82732. * The index of the image used by this texture
  82733. */
  82734. source: number;
  82735. }
  82736. /**
  82737. * Reference to a texture
  82738. */
  82739. interface ITextureInfo extends IProperty {
  82740. /**
  82741. * The index of the texture
  82742. */
  82743. index: number;
  82744. /**
  82745. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82746. */
  82747. texCoord?: number;
  82748. }
  82749. /**
  82750. * The root object for a glTF asset
  82751. */
  82752. interface IGLTF extends IProperty {
  82753. /**
  82754. * An array of accessors. An accessor is a typed view into a bufferView
  82755. */
  82756. accessors?: IAccessor[];
  82757. /**
  82758. * An array of keyframe animations
  82759. */
  82760. animations?: IAnimation[];
  82761. /**
  82762. * Metadata about the glTF asset
  82763. */
  82764. asset: IAsset;
  82765. /**
  82766. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82767. */
  82768. buffers?: IBuffer[];
  82769. /**
  82770. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82771. */
  82772. bufferViews?: IBufferView[];
  82773. /**
  82774. * An array of cameras
  82775. */
  82776. cameras?: ICamera[];
  82777. /**
  82778. * Names of glTF extensions used somewhere in this asset
  82779. */
  82780. extensionsUsed?: string[];
  82781. /**
  82782. * Names of glTF extensions required to properly load this asset
  82783. */
  82784. extensionsRequired?: string[];
  82785. /**
  82786. * An array of images. An image defines data used to create a texture
  82787. */
  82788. images?: IImage[];
  82789. /**
  82790. * An array of materials. A material defines the appearance of a primitive
  82791. */
  82792. materials?: IMaterial[];
  82793. /**
  82794. * An array of meshes. A mesh is a set of primitives to be rendered
  82795. */
  82796. meshes?: IMesh[];
  82797. /**
  82798. * An array of nodes
  82799. */
  82800. nodes?: INode[];
  82801. /**
  82802. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82803. */
  82804. samplers?: ISampler[];
  82805. /**
  82806. * The index of the default scene
  82807. */
  82808. scene?: number;
  82809. /**
  82810. * An array of scenes
  82811. */
  82812. scenes?: IScene[];
  82813. /**
  82814. * An array of skins. A skin is defined by joints and matrices
  82815. */
  82816. skins?: ISkin[];
  82817. /**
  82818. * An array of textures
  82819. */
  82820. textures?: ITexture[];
  82821. }
  82822. /**
  82823. * The glTF validation results
  82824. * @ignore
  82825. */
  82826. interface IGLTFValidationResults {
  82827. info: {
  82828. generator: string;
  82829. hasAnimations: boolean;
  82830. hasDefaultScene: boolean;
  82831. hasMaterials: boolean;
  82832. hasMorphTargets: boolean;
  82833. hasSkins: boolean;
  82834. hasTextures: boolean;
  82835. maxAttributesUsed: number;
  82836. primitivesCount: number
  82837. };
  82838. issues: {
  82839. messages: Array<string>;
  82840. numErrors: number;
  82841. numHints: number;
  82842. numInfos: number;
  82843. numWarnings: number;
  82844. truncated: boolean
  82845. };
  82846. mimeType: string;
  82847. uri: string;
  82848. validatedAt: string;
  82849. validatorVersion: string;
  82850. }
  82851. /**
  82852. * The glTF validation options
  82853. */
  82854. interface IGLTFValidationOptions {
  82855. /** Uri to use */
  82856. uri?: string;
  82857. /** Function used to load external resources */
  82858. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82859. /** Boolean indicating that we need to validate accessor data */
  82860. validateAccessorData?: boolean;
  82861. /** max number of issues allowed */
  82862. maxIssues?: number;
  82863. /** Ignored issues */
  82864. ignoredIssues?: Array<string>;
  82865. /** Value to override severy settings */
  82866. severityOverrides?: Object;
  82867. }
  82868. /**
  82869. * The glTF validator object
  82870. * @ignore
  82871. */
  82872. interface IGLTFValidator {
  82873. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82874. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82875. }
  82876. }
  82877. declare module BABYLON {
  82878. /** @hidden */
  82879. export var cellPixelShader: {
  82880. name: string;
  82881. shader: string;
  82882. };
  82883. }
  82884. declare module BABYLON {
  82885. /** @hidden */
  82886. export var cellVertexShader: {
  82887. name: string;
  82888. shader: string;
  82889. };
  82890. }
  82891. declare module BABYLON {
  82892. export class CellMaterial extends BABYLON.PushMaterial {
  82893. private _diffuseTexture;
  82894. diffuseTexture: BABYLON.BaseTexture;
  82895. diffuseColor: BABYLON.Color3;
  82896. _computeHighLevel: boolean;
  82897. computeHighLevel: boolean;
  82898. private _disableLighting;
  82899. disableLighting: boolean;
  82900. private _maxSimultaneousLights;
  82901. maxSimultaneousLights: number;
  82902. constructor(name: string, scene: BABYLON.Scene);
  82903. needAlphaBlending(): boolean;
  82904. needAlphaTesting(): boolean;
  82905. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82906. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82907. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82908. getAnimatables(): BABYLON.IAnimatable[];
  82909. getActiveTextures(): BABYLON.BaseTexture[];
  82910. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82911. dispose(forceDisposeEffect?: boolean): void;
  82912. getClassName(): string;
  82913. clone(name: string): CellMaterial;
  82914. serialize(): any;
  82915. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82916. }
  82917. }
  82918. declare module BABYLON {
  82919. export class CustomShaderStructure {
  82920. FragmentStore: string;
  82921. VertexStore: string;
  82922. constructor();
  82923. }
  82924. export class ShaderSpecialParts {
  82925. constructor();
  82926. Fragment_Begin: string;
  82927. Fragment_Definitions: string;
  82928. Fragment_MainBegin: string;
  82929. Fragment_Custom_Diffuse: string;
  82930. Fragment_Before_Lights: string;
  82931. Fragment_Before_Fog: string;
  82932. Fragment_Custom_Alpha: string;
  82933. Fragment_Before_FragColor: string;
  82934. Vertex_Begin: string;
  82935. Vertex_Definitions: string;
  82936. Vertex_MainBegin: string;
  82937. Vertex_Before_PositionUpdated: string;
  82938. Vertex_Before_NormalUpdated: string;
  82939. Vertex_After_WorldPosComputed: string;
  82940. Vertex_MainEnd: string;
  82941. }
  82942. export class CustomMaterial extends BABYLON.StandardMaterial {
  82943. static ShaderIndexer: number;
  82944. CustomParts: ShaderSpecialParts;
  82945. _isCreatedShader: boolean;
  82946. _createdShaderName: string;
  82947. _customUniform: string[];
  82948. _newUniforms: string[];
  82949. _newUniformInstances: {
  82950. [name: string]: any;
  82951. };
  82952. _newSamplerInstances: {
  82953. [name: string]: BABYLON.Texture;
  82954. };
  82955. _customAttributes: string[];
  82956. FragmentShader: string;
  82957. VertexShader: string;
  82958. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82959. ReviewUniform(name: string, arr: string[]): string[];
  82960. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82961. constructor(name: string, scene: BABYLON.Scene);
  82962. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82963. AddAttribute(name: string): CustomMaterial;
  82964. Fragment_Begin(shaderPart: string): CustomMaterial;
  82965. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82966. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82967. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82968. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82969. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82970. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82971. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82972. Vertex_Begin(shaderPart: string): CustomMaterial;
  82973. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82974. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82975. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82976. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82977. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82978. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82979. }
  82980. }
  82981. declare module BABYLON {
  82982. export class ShaderAlebdoParts {
  82983. constructor();
  82984. Fragment_Begin: string;
  82985. Fragment_Definitions: string;
  82986. Fragment_MainBegin: string;
  82987. Fragment_Custom_Albedo: string;
  82988. Fragment_Before_Lights: string;
  82989. Fragment_Custom_MetallicRoughness: string;
  82990. Fragment_Custom_MicroSurface: string;
  82991. Fragment_Before_Fog: string;
  82992. Fragment_Custom_Alpha: string;
  82993. Fragment_Before_FragColor: string;
  82994. Vertex_Begin: string;
  82995. Vertex_Definitions: string;
  82996. Vertex_MainBegin: string;
  82997. Vertex_Before_PositionUpdated: string;
  82998. Vertex_Before_NormalUpdated: string;
  82999. Vertex_After_WorldPosComputed: string;
  83000. Vertex_MainEnd: string;
  83001. }
  83002. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  83003. static ShaderIndexer: number;
  83004. CustomParts: ShaderAlebdoParts;
  83005. _isCreatedShader: boolean;
  83006. _createdShaderName: string;
  83007. _customUniform: string[];
  83008. _newUniforms: string[];
  83009. _newUniformInstances: {
  83010. [name: string]: any;
  83011. };
  83012. _newSamplerInstances: {
  83013. [name: string]: BABYLON.Texture;
  83014. };
  83015. _customAttributes: string[];
  83016. FragmentShader: string;
  83017. VertexShader: string;
  83018. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83019. ReviewUniform(name: string, arr: string[]): string[];
  83020. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83021. constructor(name: string, scene: BABYLON.Scene);
  83022. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83023. AddAttribute(name: string): PBRCustomMaterial;
  83024. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83025. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83026. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83027. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83028. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83029. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83030. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83031. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83032. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83033. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83034. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83035. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83036. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83037. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83038. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83039. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83040. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83041. }
  83042. }
  83043. declare module BABYLON {
  83044. /** @hidden */
  83045. export var firePixelShader: {
  83046. name: string;
  83047. shader: string;
  83048. };
  83049. }
  83050. declare module BABYLON {
  83051. /** @hidden */
  83052. export var fireVertexShader: {
  83053. name: string;
  83054. shader: string;
  83055. };
  83056. }
  83057. declare module BABYLON {
  83058. export class FireMaterial extends BABYLON.PushMaterial {
  83059. private _diffuseTexture;
  83060. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83061. private _distortionTexture;
  83062. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83063. private _opacityTexture;
  83064. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83065. diffuseColor: BABYLON.Color3;
  83066. speed: number;
  83067. private _scaledDiffuse;
  83068. private _lastTime;
  83069. constructor(name: string, scene: BABYLON.Scene);
  83070. needAlphaBlending(): boolean;
  83071. needAlphaTesting(): boolean;
  83072. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83073. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83074. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83075. getAnimatables(): BABYLON.IAnimatable[];
  83076. getActiveTextures(): BABYLON.BaseTexture[];
  83077. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83078. getClassName(): string;
  83079. dispose(forceDisposeEffect?: boolean): void;
  83080. clone(name: string): FireMaterial;
  83081. serialize(): any;
  83082. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83083. }
  83084. }
  83085. declare module BABYLON {
  83086. /** @hidden */
  83087. export var furPixelShader: {
  83088. name: string;
  83089. shader: string;
  83090. };
  83091. }
  83092. declare module BABYLON {
  83093. /** @hidden */
  83094. export var furVertexShader: {
  83095. name: string;
  83096. shader: string;
  83097. };
  83098. }
  83099. declare module BABYLON {
  83100. export class FurMaterial extends BABYLON.PushMaterial {
  83101. private _diffuseTexture;
  83102. diffuseTexture: BABYLON.BaseTexture;
  83103. private _heightTexture;
  83104. heightTexture: BABYLON.BaseTexture;
  83105. diffuseColor: BABYLON.Color3;
  83106. furLength: number;
  83107. furAngle: number;
  83108. furColor: BABYLON.Color3;
  83109. furOffset: number;
  83110. furSpacing: number;
  83111. furGravity: BABYLON.Vector3;
  83112. furSpeed: number;
  83113. furDensity: number;
  83114. furOcclusion: number;
  83115. furTexture: BABYLON.DynamicTexture;
  83116. private _disableLighting;
  83117. disableLighting: boolean;
  83118. private _maxSimultaneousLights;
  83119. maxSimultaneousLights: number;
  83120. highLevelFur: boolean;
  83121. _meshes: BABYLON.AbstractMesh[];
  83122. private _furTime;
  83123. constructor(name: string, scene: BABYLON.Scene);
  83124. get furTime(): number;
  83125. set furTime(furTime: number);
  83126. needAlphaBlending(): boolean;
  83127. needAlphaTesting(): boolean;
  83128. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83129. updateFur(): void;
  83130. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83131. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83132. getAnimatables(): BABYLON.IAnimatable[];
  83133. getActiveTextures(): BABYLON.BaseTexture[];
  83134. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83135. dispose(forceDisposeEffect?: boolean): void;
  83136. clone(name: string): FurMaterial;
  83137. serialize(): any;
  83138. getClassName(): string;
  83139. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  83140. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  83141. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  83142. }
  83143. }
  83144. declare module BABYLON {
  83145. /** @hidden */
  83146. export var gradientPixelShader: {
  83147. name: string;
  83148. shader: string;
  83149. };
  83150. }
  83151. declare module BABYLON {
  83152. /** @hidden */
  83153. export var gradientVertexShader: {
  83154. name: string;
  83155. shader: string;
  83156. };
  83157. }
  83158. declare module BABYLON {
  83159. export class GradientMaterial extends BABYLON.PushMaterial {
  83160. private _maxSimultaneousLights;
  83161. maxSimultaneousLights: number;
  83162. topColor: BABYLON.Color3;
  83163. topColorAlpha: number;
  83164. bottomColor: BABYLON.Color3;
  83165. bottomColorAlpha: number;
  83166. offset: number;
  83167. scale: number;
  83168. smoothness: number;
  83169. private _disableLighting;
  83170. disableLighting: boolean;
  83171. constructor(name: string, scene: BABYLON.Scene);
  83172. needAlphaBlending(): boolean;
  83173. needAlphaTesting(): boolean;
  83174. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83175. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83176. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83177. getAnimatables(): BABYLON.IAnimatable[];
  83178. dispose(forceDisposeEffect?: boolean): void;
  83179. clone(name: string): GradientMaterial;
  83180. serialize(): any;
  83181. getClassName(): string;
  83182. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83183. }
  83184. }
  83185. declare module BABYLON {
  83186. /** @hidden */
  83187. export var gridPixelShader: {
  83188. name: string;
  83189. shader: string;
  83190. };
  83191. }
  83192. declare module BABYLON {
  83193. /** @hidden */
  83194. export var gridVertexShader: {
  83195. name: string;
  83196. shader: string;
  83197. };
  83198. }
  83199. declare module BABYLON {
  83200. /**
  83201. * The grid materials allows you to wrap any shape with a grid.
  83202. * Colors are customizable.
  83203. */
  83204. export class GridMaterial extends BABYLON.PushMaterial {
  83205. /**
  83206. * Main color of the grid (e.g. between lines)
  83207. */
  83208. mainColor: BABYLON.Color3;
  83209. /**
  83210. * Color of the grid lines.
  83211. */
  83212. lineColor: BABYLON.Color3;
  83213. /**
  83214. * The scale of the grid compared to unit.
  83215. */
  83216. gridRatio: number;
  83217. /**
  83218. * Allows setting an offset for the grid lines.
  83219. */
  83220. gridOffset: BABYLON.Vector3;
  83221. /**
  83222. * The frequency of thicker lines.
  83223. */
  83224. majorUnitFrequency: number;
  83225. /**
  83226. * The visibility of minor units in the grid.
  83227. */
  83228. minorUnitVisibility: number;
  83229. /**
  83230. * The grid opacity outside of the lines.
  83231. */
  83232. opacity: number;
  83233. /**
  83234. * Determine RBG output is premultiplied by alpha value.
  83235. */
  83236. preMultiplyAlpha: boolean;
  83237. private _opacityTexture;
  83238. opacityTexture: BABYLON.BaseTexture;
  83239. private _gridControl;
  83240. /**
  83241. * constructor
  83242. * @param name The name given to the material in order to identify it afterwards.
  83243. * @param scene The scene the material is used in.
  83244. */
  83245. constructor(name: string, scene: BABYLON.Scene);
  83246. /**
  83247. * Returns wehter or not the grid requires alpha blending.
  83248. */
  83249. needAlphaBlending(): boolean;
  83250. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83251. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83252. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83253. /**
  83254. * Dispose the material and its associated resources.
  83255. * @param forceDisposeEffect will also dispose the used effect when true
  83256. */
  83257. dispose(forceDisposeEffect?: boolean): void;
  83258. clone(name: string): GridMaterial;
  83259. serialize(): any;
  83260. getClassName(): string;
  83261. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83262. }
  83263. }
  83264. declare module BABYLON {
  83265. /** @hidden */
  83266. export var lavaPixelShader: {
  83267. name: string;
  83268. shader: string;
  83269. };
  83270. }
  83271. declare module BABYLON {
  83272. /** @hidden */
  83273. export var lavaVertexShader: {
  83274. name: string;
  83275. shader: string;
  83276. };
  83277. }
  83278. declare module BABYLON {
  83279. export class LavaMaterial extends BABYLON.PushMaterial {
  83280. private _diffuseTexture;
  83281. diffuseTexture: BABYLON.BaseTexture;
  83282. noiseTexture: BABYLON.BaseTexture;
  83283. fogColor: BABYLON.Color3;
  83284. speed: number;
  83285. movingSpeed: number;
  83286. lowFrequencySpeed: number;
  83287. fogDensity: number;
  83288. private _lastTime;
  83289. diffuseColor: BABYLON.Color3;
  83290. private _disableLighting;
  83291. disableLighting: boolean;
  83292. private _unlit;
  83293. unlit: boolean;
  83294. private _maxSimultaneousLights;
  83295. maxSimultaneousLights: number;
  83296. private _scaledDiffuse;
  83297. constructor(name: string, scene: BABYLON.Scene);
  83298. needAlphaBlending(): boolean;
  83299. needAlphaTesting(): boolean;
  83300. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83301. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83302. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83303. getAnimatables(): BABYLON.IAnimatable[];
  83304. getActiveTextures(): BABYLON.BaseTexture[];
  83305. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83306. dispose(forceDisposeEffect?: boolean): void;
  83307. clone(name: string): LavaMaterial;
  83308. serialize(): any;
  83309. getClassName(): string;
  83310. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  83311. }
  83312. }
  83313. declare module BABYLON {
  83314. /** @hidden */
  83315. export var mixPixelShader: {
  83316. name: string;
  83317. shader: string;
  83318. };
  83319. }
  83320. declare module BABYLON {
  83321. /** @hidden */
  83322. export var mixVertexShader: {
  83323. name: string;
  83324. shader: string;
  83325. };
  83326. }
  83327. declare module BABYLON {
  83328. export class MixMaterial extends BABYLON.PushMaterial {
  83329. /**
  83330. * Mix textures
  83331. */
  83332. private _mixTexture1;
  83333. mixTexture1: BABYLON.BaseTexture;
  83334. private _mixTexture2;
  83335. mixTexture2: BABYLON.BaseTexture;
  83336. /**
  83337. * Diffuse textures
  83338. */
  83339. private _diffuseTexture1;
  83340. diffuseTexture1: BABYLON.Texture;
  83341. private _diffuseTexture2;
  83342. diffuseTexture2: BABYLON.Texture;
  83343. private _diffuseTexture3;
  83344. diffuseTexture3: BABYLON.Texture;
  83345. private _diffuseTexture4;
  83346. diffuseTexture4: BABYLON.Texture;
  83347. private _diffuseTexture5;
  83348. diffuseTexture5: BABYLON.Texture;
  83349. private _diffuseTexture6;
  83350. diffuseTexture6: BABYLON.Texture;
  83351. private _diffuseTexture7;
  83352. diffuseTexture7: BABYLON.Texture;
  83353. private _diffuseTexture8;
  83354. diffuseTexture8: BABYLON.Texture;
  83355. /**
  83356. * Uniforms
  83357. */
  83358. diffuseColor: BABYLON.Color3;
  83359. specularColor: BABYLON.Color3;
  83360. specularPower: number;
  83361. private _disableLighting;
  83362. disableLighting: boolean;
  83363. private _maxSimultaneousLights;
  83364. maxSimultaneousLights: number;
  83365. constructor(name: string, scene: BABYLON.Scene);
  83366. needAlphaBlending(): boolean;
  83367. needAlphaTesting(): boolean;
  83368. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83369. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83370. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83371. getAnimatables(): BABYLON.IAnimatable[];
  83372. getActiveTextures(): BABYLON.BaseTexture[];
  83373. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83374. dispose(forceDisposeEffect?: boolean): void;
  83375. clone(name: string): MixMaterial;
  83376. serialize(): any;
  83377. getClassName(): string;
  83378. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  83379. }
  83380. }
  83381. declare module BABYLON {
  83382. /** @hidden */
  83383. export var normalPixelShader: {
  83384. name: string;
  83385. shader: string;
  83386. };
  83387. }
  83388. declare module BABYLON {
  83389. /** @hidden */
  83390. export var normalVertexShader: {
  83391. name: string;
  83392. shader: string;
  83393. };
  83394. }
  83395. declare module BABYLON {
  83396. export class NormalMaterial extends BABYLON.PushMaterial {
  83397. private _diffuseTexture;
  83398. diffuseTexture: BABYLON.BaseTexture;
  83399. diffuseColor: BABYLON.Color3;
  83400. private _disableLighting;
  83401. disableLighting: boolean;
  83402. private _maxSimultaneousLights;
  83403. maxSimultaneousLights: number;
  83404. constructor(name: string, scene: BABYLON.Scene);
  83405. needAlphaBlending(): boolean;
  83406. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83407. needAlphaTesting(): boolean;
  83408. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83409. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83410. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83411. getAnimatables(): BABYLON.IAnimatable[];
  83412. getActiveTextures(): BABYLON.BaseTexture[];
  83413. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83414. dispose(forceDisposeEffect?: boolean): void;
  83415. clone(name: string): NormalMaterial;
  83416. serialize(): any;
  83417. getClassName(): string;
  83418. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  83419. }
  83420. }
  83421. declare module BABYLON {
  83422. /** @hidden */
  83423. export var shadowOnlyPixelShader: {
  83424. name: string;
  83425. shader: string;
  83426. };
  83427. }
  83428. declare module BABYLON {
  83429. /** @hidden */
  83430. export var shadowOnlyVertexShader: {
  83431. name: string;
  83432. shader: string;
  83433. };
  83434. }
  83435. declare module BABYLON {
  83436. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  83437. private _activeLight;
  83438. private _needAlphaBlending;
  83439. constructor(name: string, scene: BABYLON.Scene);
  83440. shadowColor: BABYLON.Color3;
  83441. needAlphaBlending(): boolean;
  83442. needAlphaTesting(): boolean;
  83443. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83444. get activeLight(): BABYLON.IShadowLight;
  83445. set activeLight(light: BABYLON.IShadowLight);
  83446. private _getFirstShadowLightForMesh;
  83447. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83448. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83449. clone(name: string): ShadowOnlyMaterial;
  83450. serialize(): any;
  83451. getClassName(): string;
  83452. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  83453. }
  83454. }
  83455. declare module BABYLON {
  83456. /** @hidden */
  83457. export var simplePixelShader: {
  83458. name: string;
  83459. shader: string;
  83460. };
  83461. }
  83462. declare module BABYLON {
  83463. /** @hidden */
  83464. export var simpleVertexShader: {
  83465. name: string;
  83466. shader: string;
  83467. };
  83468. }
  83469. declare module BABYLON {
  83470. export class SimpleMaterial extends BABYLON.PushMaterial {
  83471. private _diffuseTexture;
  83472. diffuseTexture: BABYLON.BaseTexture;
  83473. diffuseColor: BABYLON.Color3;
  83474. private _disableLighting;
  83475. disableLighting: boolean;
  83476. private _maxSimultaneousLights;
  83477. maxSimultaneousLights: number;
  83478. constructor(name: string, scene: BABYLON.Scene);
  83479. needAlphaBlending(): boolean;
  83480. needAlphaTesting(): boolean;
  83481. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83482. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83483. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83484. getAnimatables(): BABYLON.IAnimatable[];
  83485. getActiveTextures(): BABYLON.BaseTexture[];
  83486. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83487. dispose(forceDisposeEffect?: boolean): void;
  83488. clone(name: string): SimpleMaterial;
  83489. serialize(): any;
  83490. getClassName(): string;
  83491. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  83492. }
  83493. }
  83494. declare module BABYLON {
  83495. /** @hidden */
  83496. export var skyPixelShader: {
  83497. name: string;
  83498. shader: string;
  83499. };
  83500. }
  83501. declare module BABYLON {
  83502. /** @hidden */
  83503. export var skyVertexShader: {
  83504. name: string;
  83505. shader: string;
  83506. };
  83507. }
  83508. declare module BABYLON {
  83509. /**
  83510. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83511. * @see https://doc.babylonjs.com/extensions/sky
  83512. */
  83513. export class SkyMaterial extends BABYLON.PushMaterial {
  83514. /**
  83515. * Defines the overall luminance of sky in interval ]0, 1[.
  83516. */
  83517. luminance: number;
  83518. /**
  83519. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83520. */
  83521. turbidity: number;
  83522. /**
  83523. * Defines the sky appearance (light intensity).
  83524. */
  83525. rayleigh: number;
  83526. /**
  83527. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83528. */
  83529. mieCoefficient: number;
  83530. /**
  83531. * Defines the amount of haze particles following the Mie scattering theory.
  83532. */
  83533. mieDirectionalG: number;
  83534. /**
  83535. * Defines the distance of the sun according to the active scene camera.
  83536. */
  83537. distance: number;
  83538. /**
  83539. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  83540. * "inclined".
  83541. */
  83542. inclination: number;
  83543. /**
  83544. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  83545. * an object direction and a reference direction.
  83546. */
  83547. azimuth: number;
  83548. /**
  83549. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  83550. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  83551. */
  83552. sunPosition: BABYLON.Vector3;
  83553. /**
  83554. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  83555. * .sunPosition property.
  83556. */
  83557. useSunPosition: boolean;
  83558. /**
  83559. * Defines an offset vector used to get a horizon offset.
  83560. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  83561. */
  83562. cameraOffset: BABYLON.Vector3;
  83563. private _cameraPosition;
  83564. /**
  83565. * Instantiates a new sky material.
  83566. * This material allows to create dynamic and texture free
  83567. * effects for skyboxes by taking care of the atmosphere state.
  83568. * @see https://doc.babylonjs.com/extensions/sky
  83569. * @param name Define the name of the material in the scene
  83570. * @param scene Define the scene the material belong to
  83571. */
  83572. constructor(name: string, scene: BABYLON.Scene);
  83573. /**
  83574. * Specifies if the material will require alpha blending
  83575. * @returns a boolean specifying if alpha blending is needed
  83576. */
  83577. needAlphaBlending(): boolean;
  83578. /**
  83579. * Specifies if this material should be rendered in alpha test mode
  83580. * @returns false as the sky material doesn't need alpha testing.
  83581. */
  83582. needAlphaTesting(): boolean;
  83583. /**
  83584. * Get the texture used for alpha test purpose.
  83585. * @returns null as the sky material has no texture.
  83586. */
  83587. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83588. /**
  83589. * Get if the submesh is ready to be used and all its information available.
  83590. * Child classes can use it to update shaders
  83591. * @param mesh defines the mesh to check
  83592. * @param subMesh defines which submesh to check
  83593. * @param useInstances specifies that instances should be used
  83594. * @returns a boolean indicating that the submesh is ready or not
  83595. */
  83596. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83597. /**
  83598. * Binds the submesh to this material by preparing the effect and shader to draw
  83599. * @param world defines the world transformation matrix
  83600. * @param mesh defines the mesh containing the submesh
  83601. * @param subMesh defines the submesh to bind the material to
  83602. */
  83603. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83604. /**
  83605. * Get the list of animatables in the material.
  83606. * @returns the list of animatables object used in the material
  83607. */
  83608. getAnimatables(): BABYLON.IAnimatable[];
  83609. /**
  83610. * Disposes the material
  83611. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83612. */
  83613. dispose(forceDisposeEffect?: boolean): void;
  83614. /**
  83615. * Makes a duplicate of the material, and gives it a new name
  83616. * @param name defines the new name for the duplicated material
  83617. * @returns the cloned material
  83618. */
  83619. clone(name: string): SkyMaterial;
  83620. /**
  83621. * Serializes this material in a JSON representation
  83622. * @returns the serialized material object
  83623. */
  83624. serialize(): any;
  83625. /**
  83626. * Gets the current class name of the material e.g. "SkyMaterial"
  83627. * Mainly use in serialization.
  83628. * @returns the class name
  83629. */
  83630. getClassName(): string;
  83631. /**
  83632. * Creates a sky material from parsed material data
  83633. * @param source defines the JSON representation of the material
  83634. * @param scene defines the hosting scene
  83635. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83636. * @returns a new sky material
  83637. */
  83638. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83639. }
  83640. }
  83641. declare module BABYLON {
  83642. /** @hidden */
  83643. export var terrainPixelShader: {
  83644. name: string;
  83645. shader: string;
  83646. };
  83647. }
  83648. declare module BABYLON {
  83649. /** @hidden */
  83650. export var terrainVertexShader: {
  83651. name: string;
  83652. shader: string;
  83653. };
  83654. }
  83655. declare module BABYLON {
  83656. export class TerrainMaterial extends BABYLON.PushMaterial {
  83657. private _mixTexture;
  83658. mixTexture: BABYLON.BaseTexture;
  83659. private _diffuseTexture1;
  83660. diffuseTexture1: BABYLON.Texture;
  83661. private _diffuseTexture2;
  83662. diffuseTexture2: BABYLON.Texture;
  83663. private _diffuseTexture3;
  83664. diffuseTexture3: BABYLON.Texture;
  83665. private _bumpTexture1;
  83666. bumpTexture1: BABYLON.Texture;
  83667. private _bumpTexture2;
  83668. bumpTexture2: BABYLON.Texture;
  83669. private _bumpTexture3;
  83670. bumpTexture3: BABYLON.Texture;
  83671. diffuseColor: BABYLON.Color3;
  83672. specularColor: BABYLON.Color3;
  83673. specularPower: number;
  83674. private _disableLighting;
  83675. disableLighting: boolean;
  83676. private _maxSimultaneousLights;
  83677. maxSimultaneousLights: number;
  83678. constructor(name: string, scene: BABYLON.Scene);
  83679. needAlphaBlending(): boolean;
  83680. needAlphaTesting(): boolean;
  83681. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83682. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83683. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83684. getAnimatables(): BABYLON.IAnimatable[];
  83685. getActiveTextures(): BABYLON.BaseTexture[];
  83686. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83687. dispose(forceDisposeEffect?: boolean): void;
  83688. clone(name: string): TerrainMaterial;
  83689. serialize(): any;
  83690. getClassName(): string;
  83691. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83692. }
  83693. }
  83694. declare module BABYLON {
  83695. /** @hidden */
  83696. export var triplanarPixelShader: {
  83697. name: string;
  83698. shader: string;
  83699. };
  83700. }
  83701. declare module BABYLON {
  83702. /** @hidden */
  83703. export var triplanarVertexShader: {
  83704. name: string;
  83705. shader: string;
  83706. };
  83707. }
  83708. declare module BABYLON {
  83709. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83710. mixTexture: BABYLON.BaseTexture;
  83711. private _diffuseTextureX;
  83712. diffuseTextureX: BABYLON.BaseTexture;
  83713. private _diffuseTextureY;
  83714. diffuseTextureY: BABYLON.BaseTexture;
  83715. private _diffuseTextureZ;
  83716. diffuseTextureZ: BABYLON.BaseTexture;
  83717. private _normalTextureX;
  83718. normalTextureX: BABYLON.BaseTexture;
  83719. private _normalTextureY;
  83720. normalTextureY: BABYLON.BaseTexture;
  83721. private _normalTextureZ;
  83722. normalTextureZ: BABYLON.BaseTexture;
  83723. tileSize: number;
  83724. diffuseColor: BABYLON.Color3;
  83725. specularColor: BABYLON.Color3;
  83726. specularPower: number;
  83727. private _disableLighting;
  83728. disableLighting: boolean;
  83729. private _maxSimultaneousLights;
  83730. maxSimultaneousLights: number;
  83731. constructor(name: string, scene: BABYLON.Scene);
  83732. needAlphaBlending(): boolean;
  83733. needAlphaTesting(): boolean;
  83734. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83735. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83736. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83737. getAnimatables(): BABYLON.IAnimatable[];
  83738. getActiveTextures(): BABYLON.BaseTexture[];
  83739. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83740. dispose(forceDisposeEffect?: boolean): void;
  83741. clone(name: string): TriPlanarMaterial;
  83742. serialize(): any;
  83743. getClassName(): string;
  83744. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83745. }
  83746. }
  83747. declare module BABYLON {
  83748. /** @hidden */
  83749. export var waterPixelShader: {
  83750. name: string;
  83751. shader: string;
  83752. };
  83753. }
  83754. declare module BABYLON {
  83755. /** @hidden */
  83756. export var waterVertexShader: {
  83757. name: string;
  83758. shader: string;
  83759. };
  83760. }
  83761. declare module BABYLON {
  83762. export class WaterMaterial extends BABYLON.PushMaterial {
  83763. renderTargetSize: BABYLON.Vector2;
  83764. private _bumpTexture;
  83765. bumpTexture: BABYLON.BaseTexture;
  83766. diffuseColor: BABYLON.Color3;
  83767. specularColor: BABYLON.Color3;
  83768. specularPower: number;
  83769. private _disableLighting;
  83770. disableLighting: boolean;
  83771. private _maxSimultaneousLights;
  83772. maxSimultaneousLights: number;
  83773. /**
  83774. * @param {number}: Represents the wind force
  83775. */
  83776. windForce: number;
  83777. /**
  83778. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83779. */
  83780. windDirection: BABYLON.Vector2;
  83781. /**
  83782. * @param {number}: Wave height, represents the height of the waves
  83783. */
  83784. waveHeight: number;
  83785. /**
  83786. * @param {number}: Bump height, represents the bump height related to the bump map
  83787. */
  83788. bumpHeight: number;
  83789. /**
  83790. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83791. */
  83792. private _bumpSuperimpose;
  83793. bumpSuperimpose: boolean;
  83794. /**
  83795. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83796. */
  83797. private _fresnelSeparate;
  83798. fresnelSeparate: boolean;
  83799. /**
  83800. * @param {boolean}: bump Waves modify the reflection.
  83801. */
  83802. private _bumpAffectsReflection;
  83803. bumpAffectsReflection: boolean;
  83804. /**
  83805. * @param {number}: The water color blended with the refraction (near)
  83806. */
  83807. waterColor: BABYLON.Color3;
  83808. /**
  83809. * @param {number}: The blend factor related to the water color
  83810. */
  83811. colorBlendFactor: number;
  83812. /**
  83813. * @param {number}: The water color blended with the reflection (far)
  83814. */
  83815. waterColor2: BABYLON.Color3;
  83816. /**
  83817. * @param {number}: The blend factor related to the water color (reflection, far)
  83818. */
  83819. colorBlendFactor2: number;
  83820. /**
  83821. * @param {number}: Represents the maximum length of a wave
  83822. */
  83823. waveLength: number;
  83824. /**
  83825. * @param {number}: Defines the waves speed
  83826. */
  83827. waveSpeed: number;
  83828. /**
  83829. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83830. * will avoid calculating useless pixels in the pixel shader of the water material.
  83831. */
  83832. disableClipPlane: boolean;
  83833. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83834. private _mesh;
  83835. private _refractionRTT;
  83836. private _reflectionRTT;
  83837. private _reflectionTransform;
  83838. private _lastTime;
  83839. private _lastDeltaTime;
  83840. private _useLogarithmicDepth;
  83841. private _waitingRenderList;
  83842. private _imageProcessingConfiguration;
  83843. private _imageProcessingObserver;
  83844. /**
  83845. * Gets a boolean indicating that current material needs to register RTT
  83846. */
  83847. get hasRenderTargetTextures(): boolean;
  83848. /**
  83849. * Constructor
  83850. */
  83851. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83852. get useLogarithmicDepth(): boolean;
  83853. set useLogarithmicDepth(value: boolean);
  83854. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83855. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83856. addToRenderList(node: any): void;
  83857. enableRenderTargets(enable: boolean): void;
  83858. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83859. get renderTargetsEnabled(): boolean;
  83860. needAlphaBlending(): boolean;
  83861. needAlphaTesting(): boolean;
  83862. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83863. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83864. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83865. private _createRenderTargets;
  83866. getAnimatables(): BABYLON.IAnimatable[];
  83867. getActiveTextures(): BABYLON.BaseTexture[];
  83868. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83869. dispose(forceDisposeEffect?: boolean): void;
  83870. clone(name: string): WaterMaterial;
  83871. serialize(): any;
  83872. getClassName(): string;
  83873. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83874. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83875. }
  83876. }
  83877. declare module BABYLON {
  83878. /** @hidden */
  83879. export var asciiartPixelShader: {
  83880. name: string;
  83881. shader: string;
  83882. };
  83883. }
  83884. declare module BABYLON {
  83885. /**
  83886. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83887. *
  83888. * It basically takes care rendering the font front the given font size to a texture.
  83889. * This is used later on in the postprocess.
  83890. */
  83891. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83892. private _font;
  83893. private _text;
  83894. private _charSize;
  83895. /**
  83896. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83897. */
  83898. get charSize(): number;
  83899. /**
  83900. * Create a new instance of the Ascii Art FontTexture class
  83901. * @param name the name of the texture
  83902. * @param font the font to use, use the W3C CSS notation
  83903. * @param text the caracter set to use in the rendering.
  83904. * @param scene the scene that owns the texture
  83905. */
  83906. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83907. /**
  83908. * Gets the max char width of a font.
  83909. * @param font the font to use, use the W3C CSS notation
  83910. * @return the max char width
  83911. */
  83912. private getFontWidth;
  83913. /**
  83914. * Gets the max char height of a font.
  83915. * @param font the font to use, use the W3C CSS notation
  83916. * @return the max char height
  83917. */
  83918. private getFontHeight;
  83919. /**
  83920. * Clones the current AsciiArtTexture.
  83921. * @return the clone of the texture.
  83922. */
  83923. clone(): AsciiArtFontTexture;
  83924. /**
  83925. * Parses a json object representing the texture and returns an instance of it.
  83926. * @param source the source JSON representation
  83927. * @param scene the scene to create the texture for
  83928. * @return the parsed texture
  83929. */
  83930. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83931. }
  83932. /**
  83933. * Option available in the Ascii Art Post Process.
  83934. */
  83935. export interface IAsciiArtPostProcessOptions {
  83936. /**
  83937. * The font to use following the w3c font definition.
  83938. */
  83939. font?: string;
  83940. /**
  83941. * The character set to use in the postprocess.
  83942. */
  83943. characterSet?: string;
  83944. /**
  83945. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83946. * This number is defined between 0 and 1;
  83947. */
  83948. mixToTile?: number;
  83949. /**
  83950. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83951. * This number is defined between 0 and 1;
  83952. */
  83953. mixToNormal?: number;
  83954. }
  83955. /**
  83956. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83957. *
  83958. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83959. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83960. */
  83961. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83962. /**
  83963. * The font texture used to render the char in the post process.
  83964. */
  83965. private _asciiArtFontTexture;
  83966. /**
  83967. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83968. * This number is defined between 0 and 1;
  83969. */
  83970. mixToTile: number;
  83971. /**
  83972. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83973. * This number is defined between 0 and 1;
  83974. */
  83975. mixToNormal: number;
  83976. /**
  83977. * Instantiates a new Ascii Art Post Process.
  83978. * @param name the name to give to the postprocess
  83979. * @camera the camera to apply the post process to.
  83980. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83981. */
  83982. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83983. }
  83984. }
  83985. declare module BABYLON {
  83986. /** @hidden */
  83987. export var digitalrainPixelShader: {
  83988. name: string;
  83989. shader: string;
  83990. };
  83991. }
  83992. declare module BABYLON {
  83993. /**
  83994. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83995. *
  83996. * It basically takes care rendering the font front the given font size to a texture.
  83997. * This is used later on in the postprocess.
  83998. */
  83999. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  84000. private _font;
  84001. private _text;
  84002. private _charSize;
  84003. /**
  84004. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84005. */
  84006. get charSize(): number;
  84007. /**
  84008. * Create a new instance of the Digital Rain FontTexture class
  84009. * @param name the name of the texture
  84010. * @param font the font to use, use the W3C CSS notation
  84011. * @param text the caracter set to use in the rendering.
  84012. * @param scene the scene that owns the texture
  84013. */
  84014. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84015. /**
  84016. * Gets the max char width of a font.
  84017. * @param font the font to use, use the W3C CSS notation
  84018. * @return the max char width
  84019. */
  84020. private getFontWidth;
  84021. /**
  84022. * Gets the max char height of a font.
  84023. * @param font the font to use, use the W3C CSS notation
  84024. * @return the max char height
  84025. */
  84026. private getFontHeight;
  84027. /**
  84028. * Clones the current DigitalRainFontTexture.
  84029. * @return the clone of the texture.
  84030. */
  84031. clone(): DigitalRainFontTexture;
  84032. /**
  84033. * Parses a json object representing the texture and returns an instance of it.
  84034. * @param source the source JSON representation
  84035. * @param scene the scene to create the texture for
  84036. * @return the parsed texture
  84037. */
  84038. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84039. }
  84040. /**
  84041. * Option available in the Digital Rain Post Process.
  84042. */
  84043. export interface IDigitalRainPostProcessOptions {
  84044. /**
  84045. * The font to use following the w3c font definition.
  84046. */
  84047. font?: string;
  84048. /**
  84049. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84050. * This number is defined between 0 and 1;
  84051. */
  84052. mixToTile?: number;
  84053. /**
  84054. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84055. * This number is defined between 0 and 1;
  84056. */
  84057. mixToNormal?: number;
  84058. }
  84059. /**
  84060. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84061. *
  84062. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84063. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84064. */
  84065. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84066. /**
  84067. * The font texture used to render the char in the post process.
  84068. */
  84069. private _digitalRainFontTexture;
  84070. /**
  84071. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84072. * This number is defined between 0 and 1;
  84073. */
  84074. mixToTile: number;
  84075. /**
  84076. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84077. * This number is defined between 0 and 1;
  84078. */
  84079. mixToNormal: number;
  84080. /**
  84081. * Instantiates a new Digital Rain Post Process.
  84082. * @param name the name to give to the postprocess
  84083. * @camera the camera to apply the post process to.
  84084. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84085. */
  84086. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84087. }
  84088. }
  84089. declare module BABYLON {
  84090. /** @hidden */
  84091. export var brickProceduralTexturePixelShader: {
  84092. name: string;
  84093. shader: string;
  84094. };
  84095. }
  84096. declare module BABYLON {
  84097. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  84098. private _numberOfBricksHeight;
  84099. private _numberOfBricksWidth;
  84100. private _jointColor;
  84101. private _brickColor;
  84102. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84103. updateShaderUniforms(): void;
  84104. get numberOfBricksHeight(): number;
  84105. set numberOfBricksHeight(value: number);
  84106. get numberOfBricksWidth(): number;
  84107. set numberOfBricksWidth(value: number);
  84108. get jointColor(): BABYLON.Color3;
  84109. set jointColor(value: BABYLON.Color3);
  84110. get brickColor(): BABYLON.Color3;
  84111. set brickColor(value: BABYLON.Color3);
  84112. /**
  84113. * Serializes this brick procedural texture
  84114. * @returns a serialized brick procedural texture object
  84115. */
  84116. serialize(): any;
  84117. /**
  84118. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  84119. * @param parsedTexture defines parsed texture data
  84120. * @param scene defines the current scene
  84121. * @param rootUrl defines the root URL containing brick procedural texture information
  84122. * @returns a parsed Brick Procedural BABYLON.Texture
  84123. */
  84124. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  84125. }
  84126. }
  84127. declare module BABYLON {
  84128. /** @hidden */
  84129. export var cloudProceduralTexturePixelShader: {
  84130. name: string;
  84131. shader: string;
  84132. };
  84133. }
  84134. declare module BABYLON {
  84135. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  84136. private _skyColor;
  84137. private _cloudColor;
  84138. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84139. updateShaderUniforms(): void;
  84140. get skyColor(): BABYLON.Color4;
  84141. set skyColor(value: BABYLON.Color4);
  84142. get cloudColor(): BABYLON.Color4;
  84143. set cloudColor(value: BABYLON.Color4);
  84144. /**
  84145. * Serializes this cloud procedural texture
  84146. * @returns a serialized cloud procedural texture object
  84147. */
  84148. serialize(): any;
  84149. /**
  84150. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  84151. * @param parsedTexture defines parsed texture data
  84152. * @param scene defines the current scene
  84153. * @param rootUrl defines the root URL containing cloud procedural texture information
  84154. * @returns a parsed Cloud Procedural BABYLON.Texture
  84155. */
  84156. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  84157. }
  84158. }
  84159. declare module BABYLON {
  84160. /** @hidden */
  84161. export var fireProceduralTexturePixelShader: {
  84162. name: string;
  84163. shader: string;
  84164. };
  84165. }
  84166. declare module BABYLON {
  84167. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  84168. private _time;
  84169. private _speed;
  84170. private _autoGenerateTime;
  84171. private _fireColors;
  84172. private _alphaThreshold;
  84173. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84174. updateShaderUniforms(): void;
  84175. render(useCameraPostProcess?: boolean): void;
  84176. static get PurpleFireColors(): BABYLON.Color3[];
  84177. static get GreenFireColors(): BABYLON.Color3[];
  84178. static get RedFireColors(): BABYLON.Color3[];
  84179. static get BlueFireColors(): BABYLON.Color3[];
  84180. get autoGenerateTime(): boolean;
  84181. set autoGenerateTime(value: boolean);
  84182. get fireColors(): BABYLON.Color3[];
  84183. set fireColors(value: BABYLON.Color3[]);
  84184. get time(): number;
  84185. set time(value: number);
  84186. get speed(): BABYLON.Vector2;
  84187. set speed(value: BABYLON.Vector2);
  84188. get alphaThreshold(): number;
  84189. set alphaThreshold(value: number);
  84190. /**
  84191. * Serializes this fire procedural texture
  84192. * @returns a serialized fire procedural texture object
  84193. */
  84194. serialize(): any;
  84195. /**
  84196. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84197. * @param parsedTexture defines parsed texture data
  84198. * @param scene defines the current scene
  84199. * @param rootUrl defines the root URL containing fire procedural texture information
  84200. * @returns a parsed Fire Procedural BABYLON.Texture
  84201. */
  84202. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84203. }
  84204. }
  84205. declare module BABYLON {
  84206. /** @hidden */
  84207. export var grassProceduralTexturePixelShader: {
  84208. name: string;
  84209. shader: string;
  84210. };
  84211. }
  84212. declare module BABYLON {
  84213. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84214. private _grassColors;
  84215. private _groundColor;
  84216. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84217. updateShaderUniforms(): void;
  84218. get grassColors(): BABYLON.Color3[];
  84219. set grassColors(value: BABYLON.Color3[]);
  84220. get groundColor(): BABYLON.Color3;
  84221. set groundColor(value: BABYLON.Color3);
  84222. /**
  84223. * Serializes this grass procedural texture
  84224. * @returns a serialized grass procedural texture object
  84225. */
  84226. serialize(): any;
  84227. /**
  84228. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84229. * @param parsedTexture defines parsed texture data
  84230. * @param scene defines the current scene
  84231. * @param rootUrl defines the root URL containing grass procedural texture information
  84232. * @returns a parsed Grass Procedural BABYLON.Texture
  84233. */
  84234. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84235. }
  84236. }
  84237. declare module BABYLON {
  84238. /** @hidden */
  84239. export var marbleProceduralTexturePixelShader: {
  84240. name: string;
  84241. shader: string;
  84242. };
  84243. }
  84244. declare module BABYLON {
  84245. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84246. private _numberOfTilesHeight;
  84247. private _numberOfTilesWidth;
  84248. private _amplitude;
  84249. private _jointColor;
  84250. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84251. updateShaderUniforms(): void;
  84252. get numberOfTilesHeight(): number;
  84253. set numberOfTilesHeight(value: number);
  84254. get amplitude(): number;
  84255. set amplitude(value: number);
  84256. get numberOfTilesWidth(): number;
  84257. set numberOfTilesWidth(value: number);
  84258. get jointColor(): BABYLON.Color3;
  84259. set jointColor(value: BABYLON.Color3);
  84260. /**
  84261. * Serializes this marble procedural texture
  84262. * @returns a serialized marble procedural texture object
  84263. */
  84264. serialize(): any;
  84265. /**
  84266. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  84267. * @param parsedTexture defines parsed texture data
  84268. * @param scene defines the current scene
  84269. * @param rootUrl defines the root URL containing marble procedural texture information
  84270. * @returns a parsed Marble Procedural BABYLON.Texture
  84271. */
  84272. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  84273. }
  84274. }
  84275. declare module BABYLON {
  84276. /** @hidden */
  84277. export var normalMapProceduralTexturePixelShader: {
  84278. name: string;
  84279. shader: string;
  84280. };
  84281. }
  84282. declare module BABYLON {
  84283. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  84284. private _baseTexture;
  84285. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84286. updateShaderUniforms(): void;
  84287. render(useCameraPostProcess?: boolean): void;
  84288. resize(size: any, generateMipMaps: any): void;
  84289. get baseTexture(): BABYLON.Texture;
  84290. set baseTexture(texture: BABYLON.Texture);
  84291. /**
  84292. * Serializes this normal map procedural texture
  84293. * @returns a serialized normal map procedural texture object
  84294. */
  84295. serialize(): any;
  84296. /**
  84297. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  84298. * @param parsedTexture defines parsed texture data
  84299. * @param scene defines the current scene
  84300. * @param rootUrl defines the root URL containing normal map procedural texture information
  84301. * @returns a parsed Normal Map Procedural BABYLON.Texture
  84302. */
  84303. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  84304. }
  84305. }
  84306. declare module BABYLON {
  84307. /** @hidden */
  84308. export var perlinNoiseProceduralTexturePixelShader: {
  84309. name: string;
  84310. shader: string;
  84311. };
  84312. }
  84313. declare module BABYLON {
  84314. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  84315. time: number;
  84316. timeScale: number;
  84317. translationSpeed: number;
  84318. private _currentTranslation;
  84319. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84320. updateShaderUniforms(): void;
  84321. render(useCameraPostProcess?: boolean): void;
  84322. resize(size: any, generateMipMaps: any): void;
  84323. /**
  84324. * Serializes this perlin noise procedural texture
  84325. * @returns a serialized perlin noise procedural texture object
  84326. */
  84327. serialize(): any;
  84328. /**
  84329. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  84330. * @param parsedTexture defines parsed texture data
  84331. * @param scene defines the current scene
  84332. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  84333. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  84334. */
  84335. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  84336. }
  84337. }
  84338. declare module BABYLON {
  84339. /** @hidden */
  84340. export var roadProceduralTexturePixelShader: {
  84341. name: string;
  84342. shader: string;
  84343. };
  84344. }
  84345. declare module BABYLON {
  84346. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  84347. private _roadColor;
  84348. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84349. updateShaderUniforms(): void;
  84350. get roadColor(): BABYLON.Color3;
  84351. set roadColor(value: BABYLON.Color3);
  84352. /**
  84353. * Serializes this road procedural texture
  84354. * @returns a serialized road procedural texture object
  84355. */
  84356. serialize(): any;
  84357. /**
  84358. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  84359. * @param parsedTexture defines parsed texture data
  84360. * @param scene defines the current scene
  84361. * @param rootUrl defines the root URL containing road procedural texture information
  84362. * @returns a parsed Road Procedural BABYLON.Texture
  84363. */
  84364. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  84365. }
  84366. }
  84367. declare module BABYLON {
  84368. /** @hidden */
  84369. export var starfieldProceduralTexturePixelShader: {
  84370. name: string;
  84371. shader: string;
  84372. };
  84373. }
  84374. declare module BABYLON {
  84375. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  84376. private _time;
  84377. private _alpha;
  84378. private _beta;
  84379. private _zoom;
  84380. private _formuparam;
  84381. private _stepsize;
  84382. private _tile;
  84383. private _brightness;
  84384. private _darkmatter;
  84385. private _distfading;
  84386. private _saturation;
  84387. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84388. updateShaderUniforms(): void;
  84389. get time(): number;
  84390. set time(value: number);
  84391. get alpha(): number;
  84392. set alpha(value: number);
  84393. get beta(): number;
  84394. set beta(value: number);
  84395. get formuparam(): number;
  84396. set formuparam(value: number);
  84397. get stepsize(): number;
  84398. set stepsize(value: number);
  84399. get zoom(): number;
  84400. set zoom(value: number);
  84401. get tile(): number;
  84402. set tile(value: number);
  84403. get brightness(): number;
  84404. set brightness(value: number);
  84405. get darkmatter(): number;
  84406. set darkmatter(value: number);
  84407. get distfading(): number;
  84408. set distfading(value: number);
  84409. get saturation(): number;
  84410. set saturation(value: number);
  84411. /**
  84412. * Serializes this starfield procedural texture
  84413. * @returns a serialized starfield procedural texture object
  84414. */
  84415. serialize(): any;
  84416. /**
  84417. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  84418. * @param parsedTexture defines parsed texture data
  84419. * @param scene defines the current scene
  84420. * @param rootUrl defines the root URL containing startfield procedural texture information
  84421. * @returns a parsed Starfield Procedural BABYLON.Texture
  84422. */
  84423. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  84424. }
  84425. }
  84426. declare module BABYLON {
  84427. /** @hidden */
  84428. export var woodProceduralTexturePixelShader: {
  84429. name: string;
  84430. shader: string;
  84431. };
  84432. }
  84433. declare module BABYLON {
  84434. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  84435. private _ampScale;
  84436. private _woodColor;
  84437. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84438. updateShaderUniforms(): void;
  84439. get ampScale(): number;
  84440. set ampScale(value: number);
  84441. get woodColor(): BABYLON.Color3;
  84442. set woodColor(value: BABYLON.Color3);
  84443. /**
  84444. * Serializes this wood procedural texture
  84445. * @returns a serialized wood procedural texture object
  84446. */
  84447. serialize(): any;
  84448. /**
  84449. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  84450. * @param parsedTexture defines parsed texture data
  84451. * @param scene defines the current scene
  84452. * @param rootUrl defines the root URL containing wood procedural texture information
  84453. * @returns a parsed Wood Procedural BABYLON.Texture
  84454. */
  84455. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  84456. }
  84457. }